I have a "milestone"-markup intertwingled with normal XML:
<root>
<milestone type="opener" xml:id="m1" />
text
<milestone type="opener" xml:id="m2"/>
text
<milestone type="closer" ref="#m2"/>
text
<node>
text
</node>
...
<milestone type="closer" ref="#m1"/>
</root>
and want to address the "parent"-milestone structure (i.e. milestone@xml:id='m1'
) to <node>
using nothing than XPath.
Every milestone@xml:id
corresponds with a milestone@ref
as opener and closer of the milestone structure.
The "parent"-milestone-structure to the node would be identified by something similar to
node/preceding::milestone/concat('#',@xml:id) = node/following:milestone/@ref
This test relies on the context of the <node>
. It could be implemented in XSLT with something like
<xsl:template match="node">
<xsl:variable name="me" select="."/>
<xsl:value-of select="./preceding::milestone[
./concat('#',@xml:id) =
$me/following::milestone/@ref
][1]/@xml:id" />
</xsl:template>
But I cannot figure out how to do that with pure XPath.
Any suggestions?