2011-08-26 46 views
0

我希望能夠訪問我在模板中匹配的節點的'值'。XSLT如何訪問模板中匹配節點的值

<factfind> 
    <myelement>This is a value I want to retreive</myelement> 
    .... 
    .... 
</factfind> 

基本上,我想用下面的模板(類似的東西)

<xsl:template name="get-my-element" match="myelement"> 
    <!-- somehow retreive the value 'This is a value I want to retrieve' --> 
    <xsl:value-of select="$this"/> 
</xsl:template> 

我知道我可以在<factfind>匹配模板,但問題是我已經是匹配的模板元素並以自己的方式處理它。如果我製作兩個模板來處理一個節點,則只會調用第一個模板。

所以你可能知道上下文好一點,下面是我如何設置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> 

的菜單項模板想撥打電話,模板一開始我的元素模板來訪問它內部的信息,而不會影響我的factfind模板的行爲。

回答

2

簡單,點表達給你的背景資料:

<xsl:value-of select="."/> 
+0

完美..!太明顯了。搜尋我的所有結果是'如何匹配節點的價值'等等,這是一件很難的事情。 – jenovachild