[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Hierarchy problem

Subject: Re: Hierarchy problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 22 Jul 2002 14:36:18 +0100
xsl count node hierarchy
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
  • RE: Hierarchy problem, (continued)
    • DPawson - Mon, 22 Jul 2002 07:31:07 -0400 (EDT)
    • DPawson - Mon, 22 Jul 2002 07:53:49 -0400 (EDT)
    • DPawson - Mon, 22 Jul 2002 08:26:51 -0400 (EDT)
      • Jeni Tennison - Mon, 22 Jul 2002 09:36:24 -0400 (EDT) <=
      • David Carlisle - Mon, 22 Jul 2002 09:57:51 -0400 (EDT)
    • DPawson - Mon, 22 Jul 2002 09:39:25 -0400 (EDT)
    • McNally, David - Mon, 22 Jul 2002 09:58:47 -0400 (EDT)
    • DPawson - Mon, 22 Jul 2002 09:59:22 -0400 (EDT)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.