Menu

#22 Please support querying unique XPaths to traverse each of the elements in the specified XML document

ungrouped
open
nobody
None
5
2025-03-19
2025-03-18
No

Hello, I tried to use this utility for processing ODF documents and noticed that it seems to be unable to generate unique XPaths to traverse each of the elements in an XML document.

For example, the following XML source markup snippet:

      <text:p text:style-name="Text_20_body"/>
      <text:h text:style-name="Heading_20_1" text:outline-level="1"><text:bookmark-start text:name="__RefHeading___Toc103_2364876554"/>References<text:bookmark-end text:name="__RefHeading___Toc103_2364876554"/></text:h>
      <text:p text:style-name="Text_20_body">T.B.D.</text:p>
      <text:p text:style-name="Text_20_body"/>
    </office:text>
  </office:body>
</office:document-content>

resulted in the following XPaths:

office:document-content/office:body/office:text/text:p[@text:style-name='Text_20_body']
office:document-content/office:body/office:text/text:h[@text:style-name='Heading_20_1' and @text:outline-level='1']
office:document-content/office:body/office:text/text:h/text:bookmark-start[@text:name='__RefHeading___Toc103_2364876554']
office:document-content/office:body/office:text/text:h/text:bookmark-end[@text:name='__RefHeading___Toc103_2364876554']
office:document-content/office:body/office:text/text:p[@text:style-name='Text_20_body']
office:document-content/office:body/office:text/text:p[@text:style-name='Text_20_body']

which is not unique for any of the elements that shares the office:document-content/office:body/office:text/text:p[@text:style-name='Text_20_body'] XPath.

Please support a way to generate unique XPaths so that wone can traverse the entire input XML document using them, thanks in advance!

Discussion

  • 林博仁(Buo-ren Lin)

    I would like to note that I was previously using the xmlstarlet elements -v command to generate the XPaths.

    Version information:

    $ xmlstarlet --version
    1.6.1
    compiled against libxml2 2.9.14, linked with 20914
    compiled against libxslt 1.1.35, linked with 10139
    
     
  • 林博仁(Buo-ren Lin)

    Typo fix of the original post: s/wone/one/

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.