bugGNU gettext - Bugs: bug #54472, appdata.xml string extraction...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #54472: appdata.xml string extraction broken when root component has namespace

Submitter:  Claude Paroz <claudep>
Submitted:  Wed 08 Aug 2018 09:09:12 PM UTC
   
 
Category:  AppData Severity:  3 - Normal
Item Group:  None Status:  Fix Released
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed

Jump to the original submission

Sun 01 Dec 2024 04:33:05 PM UTC, comment #6: 

The fix is contained in gettext 0.23.

Bruno Haible <haible>
Group administrator
Fri 11 Oct 2024 11:08:51 AM UTC, comment #5: 

Patrick Storz wrote:

> We have the same issue in Inkscape
> They use the XML namespace "http://www.inkscape.org/namespace/inkscape/extension"


In this case, you need to duplicate the ITS rules in the *.its file, for this particular namespace, like I did in aforementioned commit.

If, however, you want to allow any namespace instead of a specific one, use the trick from https://stackoverflow.com/questions/5239685/ (mentioned by Daiki) that replaces XPath expressions like

/List/Fields/Field

with

/*[name()='List']/*[name()='Fields']/*[name()='Field']


Bruno Haible <haible>
Group administrator
Fri 11 Oct 2024 11:03:48 AM UTC, comment #4: 

Thanks for the report.

Indeed, the AppData / Metainfo specification at https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html says "The XML in metainfo files does not need any XML namespace, and adding one should generally be avoided. If you want to use a namespace though (maybe in case you want to embed the data in other contexts), the xmlns should be https://specifications.freedesktop.org/metainfo/1.0."

Fixed through https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=70c654cec7890690a96c4bef72d5adfe8c550c47 .

Note that the method recommended for validation of AppData files in https://docs.fedoraproject.org/en-US/packaging-guidelines/AppData/, namely "appstream-util validate-relax file.appdata.xml", is not strict enough: it allows any namespace, not only the missing namespace and "https://specifications.freedesktop.org/metainfo/1.0". See:

<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop" xmlns="https://example.com/any/namespace">
  <id>org.gnome.Characters.desktop</id>
  <name>GNOME Characters</name>
  <summary>Character map application</summary>
  <licence>CC0</licence>
  <description>
    <p>Happy new year!</p>
  </description>
</component>


$ appstream-util validate-relax mf.appdata.xml
mf.appdata.xml: OK


Bruno Haible <haible>
Group administrator
Wed 31 Jul 2019 05:24:52 AM UTC, comment #3: 

This sounds like a general question about XPath, not a deficiency in gettext itself.

If the upstream schema mandates a namespace, all the conforming data files should have an explicit xmlns.

If namespace is optional like metainfo, you can prepare the ITS rules to match against local names only:
https://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath

Daiki Ueno <ueno>
Group administrator
Mon 29 Jul 2019 09:04:51 PM UTC, comment #2: 

We have the same issue in Inkscape, where we want to extract translatable strings from the simple XML format that is used to describe the GUI-parts of Inkscape extensions (*.inx file format).

They use the XML namespace "http://www.inkscape.org/namespace/inkscape/extension" and look like the following:


<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
...
</inkscape-extension>


It's obviously neither a metainfo nor an appdata file format, but I had hoped xgettext would aim to support ITS rules in a more general way?

Patrick Storz <ede123>
Wed 08 Aug 2018 09:43:25 PM UTC, comment #1: 

The specification of the metainfo and appdata file format, https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#sect-Metadata-GenericComponent, says:

"The XML in metainfo files does not need any XML namespace, and adding one should generally be avoided. If you want to use a namespace though (maybe in case you want to embed the data in other contexts), the xmlns should be https://specifications.freedesktop.org/metainfo/1.0."

So, it should use https://specifications.freedesktop.org/metainfo/1.0 as the default namespace.

Bruno Haible <haible>
Group administrator
Wed 08 Aug 2018 09:09:12 PM UTC, original submission:  

Simply change gettext/gettext-tools/tests/xgettext-appdata-1:
-<component type="desktop">
+<component type="desktop" xmlns="https://specifications.freedesktop.org/metainfo/1.0">

and you'll see that ITS rules will no longer apply to string extraction (ie. all strings are extracted instead of a selection).

This was discovered in https://gitlab.gnome.org/GNOME/gucharmap/issues/11

Claude Paroz <claudep>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ueno (Posted a comment)
  • -email is unavailable- added by ede123 (Posted a comment)
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by claudep (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-12-01 haible StatusFixed Fix Released
    2024-10-11 haible Open/ClosedOpen Closed
    2024-10-11 haible Assigned toNone haible
    2024-10-11 haible StatusNone Fixed

    Back to the top

    Powered by Savane 3.15-26b0.
    Corresponding source code