XSLT How to access the value of a matched node in a template
I want to be able to access the 'value' of the node I am matching on in my template.
<factfind>
<myelement>This is a value I want to retreive</myelement>
....
....
</factfind>
Basically, I want to use the following template (something like it)
<xsl:template name="get-my-element" match="myelement">
<!-- somehow retreive the value 'This is a value I want to retrieve' -->
<xsl:value-of se开发者_Go百科lect="$this"/>
</xsl:template>
I know I could match a template on <factfind>
but the problem is I already have a template that is matching that element and handling it in its own way. If I make two templates that handle the one node, only the first one is called.
So you might know the context a bit better, here is how I have it setup atm.
<xsl:template match="loggedin">
<div id="entities">
<xsl:apply-templates select="entities"/>
</div>
<div id="nav">
<xsl:apply-templates select="menuitem"/>
</div>
<div id="content">
<xsl:apply-templates select="factfind" />
</div>
</xsl:template>
The menuitem template would like to make a call-template to the get-my-element template to access the information inside of it, without effecting the behaviour of my factfind template.
Simple, the dot expression gives you the context item:
<xsl:value-of select="."/>
精彩评论