xsl-list
[Top] [All Lists]

Re: [xsl] looking for an attribute

2006-09-14 04:36:35
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[(_at_)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[(_at_)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[(_at_)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[(_at_)name='Login']"> but
it won't work.

Any help would be appreciated.

Aaron

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--