Subject: Re: [xsl] Hierarchy problem From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 22 Jul 2002 14:36:18 +0100 |
Dave, > The requirement I'm working to states > > The mapRef attribute on each navTarget must reference the innermost > navPoint that contains the element referenced by the navTarget. > > Roughly this means that I have two pointers into the same xml file. > Both are indirected by smil files. > > navTarget points to some element which must be a child of a levelN > element (N is 1...6) by id value. > > mapRef points to one of those levelN elements, by id value. So if you have: <navTarget mapRef="id3">id5</navTarget> then the element whose id attribute is 'id3' must be the parent of the element whose id attribute is 'id5': <level4 id="id3"> <level5 id="id5"> ... </level5> </level4> is OK, but: <level4 id="id3"> <level5> <level6 id="id5"> ... </level6> </level5> </level4> isn't. In that case, I don't think you need to test node identity at all. Say you're on a navTarget element. You can locate from that navTarget element the element the navTarget is pointing to with: id(.) then you can look at the parent of that element and check out its id attribute's value: id(.)/../@id and then you can see if it's the same as the value of the mapTarget attribute on the current navTarget element: id(.)/../@id = @mapTarget if it is, then your condition is satisfied, if it isn't then the mapTarget attribute is pointing to the wrong place. It's easier to get the node from the navTarget than from the mapTarget because that means you only have to check one node (the parent of the element the navTarget points to) rather than several (all the children of the element the mapTarget points to). On the set logic stuff. The general pattern is: count($node-set | $node) = count($node-set) is true only if $node is in the node set $node-set. You can make the $node-set be the children of $x: count($x/* | $node) = count($x/*) in which case you're testing whether $node is a child of $x, or you can make the $node-set be the descendants of $x: count($x//* | $node) = count($x//*) in which case you're testing whether $node is one of the descendants of $x. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Hierarchy problem, DPawson | Thread | Re: [xsl] Hierarchy problem, David Carlisle |
RE: [xsl] Hierarchy problem, DPawson | Date | RE: [xsl] Hierarchy problem, DPawson |
Month |