|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Node selection based on parent attribute
Subject: Re: Node selection based on parent attribute
From: "katharine wykes" <katharinewykes@xxxxxxxxxxx>
Date: Fri, 30 Aug 2002 17:18:40 +0000
|
Still trying to get a better understanding of xslt. Using the code you
specified below brings up a parser error:
Attribute 'select' is invalid on 'xsl:if'.
Any clues as to the cause of this?
Cheers,
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Node selection based on parent attribute
Date: Fri, 30 Aug 2002 12:24:31 -0400
Katharine,
Another approach (besides the ones using for-each) is just to use the
built-in descent of the tree, as in something like:
<xsl:template match="menu">
<xsl:if select="ancestor::menu[@id=$id']">
<xsl:value-of select="@id"/>
<!-- copies out this menu's @id if it has an ancestor
menu with @id = $id -->
</xsl:if>
<xsl:apply-templates/>
<!-- continues the tree traversal in case there are any below -->
</xsl:template>
Make sure the parameter is set to the *value* of the id ('1', '6',
whatever) whose descendants you want.
Cheers,
Wendell
At 10:51 AM 8/30/2002, you wrote:
Thanks for that.
Would there be an easy way of making that recursive. So if there were
sub/sub nodes under <menu id=6>, ie
<menu id=6>
<menu id=8>
<menu id=9/>
<menu id=10/>... and so on
</menu>
</menu>
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|