0

I got the following XML

<doc>
    <start/>
    <mandatory id='x1'/>
    <optional id='foo'/>
    <end/>
    <start/>
    <mandatory id='x2'/>
    <end/>
    <start/>
    <mandatory id='x3'/>
    <optional id='boo'/>
    <end/>
</doc>

whose structure is flat. A coherent set of information begins with tag but ends with tag. Certain information within a set a mandatory, here but others are not, here

My process uses XPATH 1.0 to first extract the starting node, and after that for each starting node, I want to have the mandatory info as well as the optional one.

My problem is to find the proper XPATH expression to derive the optional node that fits to the current node of the iteration provided by

/doc/start

I already gave the Kayessian XPath 1.0 Formula

How to perform set operations in XPath 1.0 XPath select all elements between two specific elements

to derive a intersection of two sets a try

following-sibling::optional[count(. | following-sibling::end[1]/preceding-sibling::optional)=(count(following-sibling::end[1]/preceding-sibling::optional))]

Thanks a lot

cheers Christian

Community
  • 1
  • 1
  • Can you provide desired output? Why not use XSLT? XSLT can contain multiple XPaths and return multiple nodes. – Parfait Sep 28 '15 at 20:25
  • Thanks for getting back on me. The framework is set, the application is up'n running - so I unfortunately rely on XPATH. Desired output to optain the id for the optional tag is in iteration 1 *foo*, in iteration 2 *empty (node set)* and in iteration 3 *boo*. Hope that helps. Thanks in advance – Christian Meichsner Sep 29 '15 at 09:55

0 Answers0