Subject: Re: [xsl] in-document references From: S Woodside <sbwoodside@xxxxxxxxx> Date: Mon, 6 Jan 2003 19:41:07 -0500 |
[snip]From: S Woodside [mailto:sbwoodside@xxxxxxxxx] <xsl:template match="ref"> <li>Ref: <b><xsl:value-of select="@name"/></b> <ul> <xsl:apply-templates select="//define[@name=current()/@name]" mode="def"/> </ul> </li> </xsl:template>
Your current select expression tells the processor to select all 'define'
nodes that are descendants of the document element.
<!--This is a Relax NG schema--> <grammar> <element name="Id"> <ref name="string"/> </element> <define name="string"> <data type="string"/> </define> </grammar>
<xsl:template match="element"> <li>Element: <xsl:value-of select="@name"/> <ul> <xsl:apply-templates/> </ul> </li> </xsl:template>
<xsl:template match="ref"> <li>Ref: <b><xsl:value-of select="@name"/></b> <ul> <xsl:apply-templates select="//define[@name=current()/@name]" mode="def"/> </ul> </li> </xsl:template>
<xsl:template match="define" mode="def"> <xsl:apply-templates/> </xsl:template>
==================output should be=============== (ignoring whitespace issues)
<li>Element: Id <ul> <li>Ref: <b>string</b> <ul> <li> Id <!--This is the hard part--> </li> </ul> </ul> </li> <li> [Define: <b>string</b>] </li>
<li>Element: Id <ul> <li>Ref: <b>string</b> <ul> <li> <!--I get nothing here since there is no "element" parent of "define" in the data--> </li> </ul> </ul> </li> <li> [Define: <b>string</b>] </li>
To select just descendants of the context node, do:
<xsl:apply-templates select=".//define[@name=current()/@name]" mode="def"/>
(This doesn't address optimization of course--this search pattern can be
quite expensive.)
--- www.simonwoodside.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] in-document references, Martinez, Brian | Thread | RE: [xsl] in-document references, Robert Koberg |
RE: [xsl] in-document references, Robert Koberg | Date | RE: [xsl] in-document references, Robert Koberg |
Month |