Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - How to point to an element using context-dependent information? [Thread Next] Re: How to point to an element using context-dependent information?To: NULL Date: 7/14/2007 8:52:00 PM
Arndt Jonasson wrote:
> 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.
If you only want links within the document, just us ID and IDREF
attribute types.
<top>
<friends>
<friend ID="JA1">
<name1>Joe</name1>
<name2>Anderson</name2>
</friend>
<friend>
<name1>Paul</name1>
<name2>Bright</name2>
</friend>
</friends>
<addresses>
<address>
<name>Joe</name>
<moredata see="JA1"/>
<street>Wilson St.</street>
<number>15</number>
</address>
</addresses>
</top>
But there are other, probably much more efficient ways to do this.
///Peter
--
XML FAQ: http://xml.silmaril.ie/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
