|
Subject: Re: [xsl] Getting variable yet most immediate parentNode From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Fri, 28 Sep 2007 02:00:16 +0200 |
<xsl:apply-templates select=".//answers" />
Actually this should be "ancestor::*/answers", or "ancestor::*[answers][1]/answers", shouldn't it?
".//answers" will search the subtree below the current node, rather than look up the tree.
"ancestor::*/answers" will select answers elements from all ancestors; "ancestor::*[answers][1]/answers" will select only the closest one. If you think the latter expression is too opaque, you could also write
(ancestor::*/answers)[last()]
... and then try to explain that. :-)
<questions>
<answers />
<question>
<answer>
<option>True</option>
<option>False</option>
</answer>
</question>
</questions> <xsl:template match="questions">
<xsl:apply-templates mode="q" select="option" />
<SNIP />
</xsl:template> <xsl:template match="answers">
<xsl:param name="qKey" />
<xsl:if test="option">
......... <xsl:template match="answers[option]">
....<xsl:template match="answers[option]" >
<select>
<xsl:apply-templates select="option" />
</select>
</xsl:template><xsl:template match="option"> <option><xsl:value-of select="(@name | .)[1]" /> </xsl:template>
Cheers, -- Abel Braaksma
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Getting variable yet most, Wendell Piez | Thread | Re: [xsl] Getting variable yet most, Wendell Piez |
| Re: [xsl] Getting variable yet most, Wendell Piez | Date | [xsl] Posting to XSL-List from gmai, B Tommie Usdin |
| Month |