开发者

XSLT How to access the value of a matched node in a template

开发者 https://www.devze.com 2023-03-30 17:12 出处:网络
I want to be able to access the \'value\' of the node I am matching on in my template. <factfind>

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="."/>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号