A
Arndt Jonasson
Say I have an XML document, where I want the contents of certain
elements
to be a textual pointer to another element, based on the contents
of yet another element. Somewhat silly example:
<top>
<friends>
<friend>
<name1>Joe</name1>
<name2>Anderson</name2>
</friend>
<friend>
<name1>Paul</name1>
<name2>Bright</name2>
</friend>
</friends>
<addresses>
<address>
<name>Joe</name>
<moredata>/top/friends/friend[name1=$./../name]</moredata>
<street>Wilson St.</street>
<number>15</number>
</address>
</addresses>
</top>
The string "/top/friends/friend[name1=$./../name]" could be what
I want, except that the "$." thing is an invention. The contents
of /top/friends/addresses/address[name="Joe"]/moredata is
meant to be an XPath expression pointing out the node
/top/friends/friend[name1="Joe"], based on the fact that when looking
at /top/friends/addresses/address[name="Joe"]/moredata, "../name" has
the contents "Joe".
I could invent a syntax (like $. above), but I'd like to use existing
syntax if there is any. I'm not familiar enough with XPointer or
XQuery
to know whether they can express this. Can they? I don't see that
XPath alone is enough. Thanks in advance for any suggestions.
elements
to be a textual pointer to another element, based on the contents
of yet another element. Somewhat silly example:
<top>
<friends>
<friend>
<name1>Joe</name1>
<name2>Anderson</name2>
</friend>
<friend>
<name1>Paul</name1>
<name2>Bright</name2>
</friend>
</friends>
<addresses>
<address>
<name>Joe</name>
<moredata>/top/friends/friend[name1=$./../name]</moredata>
<street>Wilson St.</street>
<number>15</number>
</address>
</addresses>
</top>
The string "/top/friends/friend[name1=$./../name]" could be what
I want, except that the "$." thing is an invention. The contents
of /top/friends/addresses/address[name="Joe"]/moredata is
meant to be an XPath expression pointing out the node
/top/friends/friend[name1="Joe"], based on the fact that when looking
at /top/friends/addresses/address[name="Joe"]/moredata, "../name" has
the contents "Joe".
I could invent a syntax (like $. above), but I'd like to use existing
syntax if there is any. I'm not familiar enough with XPointer or
XQuery
to know whether they can express this. Can they? I don't see that
XPath alone is enough. Thanks in advance for any suggestions.