【发布时间】:2014-02-12 18:26:42
【问题描述】:
请原谅我对 XSLT 的无知,我对它还很陌生。
使用 saxon xslt 2.0:我试图从 xsl:variable 中获取单个元素,在应用 <xsl:copy-of select="$type"> 时看起来像这样:
<type>
<label>Book</label>
<id>book</id>
</type>
尝试仅访问 id 元素 - 我尝试过:
<xsl:copy-of select="$type/id">
<xsl:copy-of select="$type[2]">
<xsl:value-of select="$type/id">
<xsl:value-of select="$type[2]">
也试过这个和一些变种
<xsl:value-of select="$type[name()='id']"/>
并尝试更改数据类型
<xsl:variable name="type" as="element">
XSLT 2.0 node-set() 操作似乎不适用。
我寻求有关如何正确访问 xsl:variable 元素的详细说明,并且很高兴发现我使用这一切都错了,有更好的方法。感谢您的见解和努力。
@martin-honnen 添加时:
<xsl:variable name="test1">
<type>
<label>Book</label>
<id>book</id>
</type>
</xsl:variable>
<TEST1><xsl:copy-of select="$test1/type/id"/></TEST1>
<xsl:variable name="test2" as="element()">
<type>
<label>Book</label>
<id>book</id>
</type>
</xsl:variable>
<TEST2><xsl:copy-of select="$test2/id"/></TEST2>
我得到了结果:
<TEST1/>
<TEST2/>
【问题讨论】:
标签: xslt xslt-2.0 saxon xsl-variable