2012-05-14 42 views
1

生病非常感激,如果任何人能幫助我找到一種方法來讀取文本作爲XPath表達式我如何讀取文本XPath表達式

例如這是我的xml文檔

<abc> 
    <XYZ> 
     <include>/citizen[./marital_status[text() ='married']]</include> 
    </XYZ> 
</abc> 

,我在這裏寫一個樣式表

<xsl:template match="abc"> 
     <xsl:call-template name="evaluate"> 
      <xsl:with-param name="include"> 
       <xsl:apply-templates select="$include"/> 
      </xsl:with-param> 
     </xsl:call-template> 
    </xsl:template> 

的問題是,這裏<include>元素的文本是什麼我想在<xsl:apply-templates select="$include"/> XPath表達式。這會給我結婚的公民,但在這裏我只是得到了字符串"/citizen[./marital_status[text() ='married']]"。有沒有可能的做法?

在此先感謝

+0

的元素 – ashamim

+0

元素我不相信這是可能的xslt 1.0而不使用http://www.exslt.org/或其他擴展功能。 –

+0

http://stackoverflow.com/questions/1551526/is-it-possible-to-use-a-dynamic-xpath-expression-in-a-xslt-style-sheet –

回答

1

檢查什麼在你選擇的XSLT處理器可供選擇:看它是否具有某種XX的:評價()擴展功能。如果不是,或者如果你想要一個可移植的解決方案,另一種方法是生成一個包含相關表達式的樣式表(或樣式表模塊),然後編譯和執行樣式表。