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



> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@jenitennison.com]
> Sent: 22 July 2002 10:54
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] Hierarchy problem
> 
> 
> Dave,
> 
> David C made a typo when he wrote:
> >> just if $y is a child of $x which is what I think you mean 
> by direct
> >> descendant.
> >> 
> >> count($x//*|$y) = count($x/*)
> >> 
> >> if $y is a descendent of $x
> 
> He meant:
> 
>   count($x//*|$y) = count($x//*)
>                              ^ additional /

That's it.


 <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">  <!-- navLabel target -->
      <p>Note content</p>
     </note>
    </level3>
   </level2>
  </level1>

<xsl:variable name='x' select='/level1/level2/level3/note'/>
<xsl:variable name='y' select='/level1'/>


<xsl:template match="/">
  <xsl:message>Y is a desc of X:<xsl:value-of 
  select="count($x//*|$y) = count($x/*)"/></xsl:message>

  <xsl:message>X is a desc of Y:<xsl:value-of 
  select="count($y//*|$x) = count($y//*)"/></xsl:message>
 

</xsl:template>

Gives:
Y is a desc of X:false
X is a desc of Y:true



In this case note is a descendent of level1, so $x should be a descendent of
$Y.

This goes back to the idea of the union ignoring duplicates (count only
once)?
hence 

count($x//*|$y) = count($x//*)

implies that node $y is a member of the set which is all the children of $x?

Is that right?


Still doesn't resolve my original problem though.
the hierarchy above is
 level1
   level2
    level3
I'm looking for *immediate* descendent, i.e. level3 (and hence note)
are not *immediate* descendents of level1, level2 intervenes.

I'm playing with Dimitres suggestion, along the lines of

var myNearestParentLevel = substring-after(ancestor-or-self(contains
(name('level')) ...
  i.e. get '3' for note as being the nearest wrapper.

then use Dimitres ideas to check if (for level1) l+1 = $myNearestParentLevel

 which is false.

Regards DaveP



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]