Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev - [xsl] looking for an attribute
[Thread Next]
Re: [xsl] looking for an attribute
To:
Date: 9/14/2006 11:37:00 AM
Hi Aaron,
You'll need to add (and know) what the context node is. Suppose the
following (expecting "navigation" to be your root node):
>>>> Example of root node, root node is "above" the root node of your
xml doc.
<xsl:template match="/">
<xsl:if test="navigation/focusedTab[@name = 'Login']" >
....
</xsl:if>
</xsl:template>
>>>> Example of named template. Here the context node is still the root
node:
<xsl:template match="/">
<xsl:call-template name="scripts" />
</xsl:template>
<xsl:template name="scripts">
<xsl:if test="navigation/focusedTab[@name = 'Login']" >
....
</xsl:if>
</xsl:template>
>>>> Example of normal template. Here the context node is "navigation":
<xsl:template match="/">
<xsl:apply-template select="navigation"/>
</xsl:template>
<xsl:template match="navigation">
<xsl:if test="focusedTab[@name = 'Login']" >
....
</xsl:if>
</xsl:template>
In short: once you know "where you are" in the document parse tree, or
in other words: are aware of the context node, you can find how your
XPath expression should be like.
Good luck!
Cheers,
Abel Braaksma
http://abelleba.metacarpus.com
Aaron Johnson wrote:
Appologies if this is a repeated request...
I have some xml...
<navigation>
<focusedTab unremovable="true" immutable="true" ID="50"
name="Login"/>
<inactiveTab unremovable="true" immutable="true" ID="38"
name="Home"/>
</navigation>
I would like to test if the focused tab has an attribute of "login" so
as to impliment a choose statement...
<xsl:template name="scripts">
<xsl:choose>
<xsl:when test="?????'"> etc etc....
I thought it would be <xsl:when test="focusedTab[@name='Login']"> but
it won't work.
Any help would be appreciated.
AaronDisclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

