This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Hierarchy problem


David C wrote:
> > (My definitions)
> > level3 is a 'direct descendant' of level2
> 
> why not use the XPath terminology, "child" ? Then I'd  be sure I know
> what you mean.
> 
> Also your example was a bit confusing (and still is) as there are two 
> things you might have meant by "level 3": the element of that 
> name, and
> the h3 element with that content. I assume you meant the former.

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.

Hence I'm going to finish up with

<xsl:variable name='mapRef'/> containing the id of a node
<xsl:variable name='navTarget'/> containing the id of a node.

As Mike corrected me, this is the right approach.

the requirement then is to prove true|false that mapRef has a child
whose id is that in navTarget variable. The proviso is that
in the XML document hierarchy, there is no node, with
contains(name(),'level')
'between' the two nodes.

  <level1 id='l1'>
   <h1>Level1</h1>
   <level2 id='l2'>
    <h2>Level2</h2>  <!-- bad navPoint 1 -->
    <level3 id='l3'> <!-- good navPoint 2 -->
     <h3>level3</h3>
     <note id="noteId">  <!-- mapRef target -->
      <p>Note content</p>
     </note>
    </level3>
   </level2>
  </level1>

> 
> 
> > <xsl:variable name='x' select='/level1/level2'/>
> > <xsl:variable name='y' select='/level1'/>
> 
> well that sets x to be all the level 3 nodes and y to be all thelevel
> one ones.

Hence the corrected variable values would be 
<xsl:variable name='mapRef' select='id("l2")'/>   (was x)
<xsl:variable name='navTarget' select="id('nodeId')"/> (was y)

>From your later email
>> I'm looking for *immediate* descendent, i
>ie child,
yes, sorry.

Then you said:

No!  If you want child 
then you want to use the child axis not descendent-or-self, so that
would be
count($x/*|$y) = count($x/*)
        ^                ^
also y contains a node set of more than one node, in general so you
mean
 the node set y is a subset of ...

[Showing up my lack of set theory knowledge I can't see the difference in
this case]

Using the above: 

<xsl:variable name='x' select='id("l1")'/>
<xsl:variable name='y' select="id('noteId')"/>

shows true, which is clearly not the case.
Also, if $y is a node which doesn't exist (or is higher in the doc tree than
$x) surely the statement would come back true?

Still very confused,
Thanks for your tolerance David.

regards DaveP

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]