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


Does this do what you want - it checks if the node in $point2 is the parent
of the node in $point1 (I think):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text"/>
	
<xsl:template match="/">
<xsl:variable name="point1" select="//*[@id='noteId']"/>
<xsl:variable name="point2" select="//level2[@id='l2']"/>
<xsl:choose>
	<xsl:when test="$point1/.. = $point2">
		<xsl:text>Yes</xsl:text>
	</xsl:when>
	<xsl:otherwise>
		<xsl:text>No</xsl:text>
	</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

I don't think this would be complicated by using document() in the variable
definitions (but could be wrong).

David.
--
David McNally            Moody's Investors Service
Software Engineer        99 Church St, NY NY 10007 
David.McNally@Moodys.com            (212) 553-7475 

> -----Original Message-----
> From: DPawson@rnib.org.uk [mailto:DPawson@rnib.org.uk]
> Sent: Friday, July 19, 2002 10:43 AM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Hierarchy problem
> 
> 
> With a structure such as
> 
> 
> <bodymatter>
>   <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>
> 
> ....
> 
> I need to check that the node with id=noteId
> is (or is not) a direct descendant of another node (e.g. 
> level2[id='l2'])
> or if there are intervening levelX elements.
> 
[snip]


---------------------------------------

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission.  If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited.  If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments.  Thank you.

Every effort is made to keep our network free from viruses.  You should, however, review this e-mail message, as well as any attachment thereto, for viruses.  We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.


 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]