开发者

Dynamic path in document function()

The XML file name is specific but I need to build a dynamic path. I have tried using a variable to build the path but it didn't work:

<xsl:variable name="path">
   ...conditional c开发者_开发知识库ode
</xsl:variable>     <xsl:value-of select="document('myXML.xml')/worksheets/$path"/> 

2.0 solutions ok.


Evaluation of any dynamically-generated XPath expression is not supported by the XSLT 1.0 or XSLT 2.0 standards. It will be supported in XSLT 2.1.

If the dynamically-generated XPath expression is not too complex, the technique in this answer can be used successfully:

Retrieving XML node from a path specified in an attribute value of another node


You need an extension function, XPath 2.0 does not support dynamic compilation/evaluation. Saxon has saxon:evaluate. Even if your processor does not support such function you might be able to implement it yourself as an extension function.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜