【发布时间】:2017-03-10 19:45:24
【问题描述】:
考虑一下,<xsl:value-of select="@select"/> 输出 /root/name。我要传递给value-of 的求值表达式,因此它会选择 XML 中的特定值。
我想让整个代码工作:
XML:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<xsl:value-of select="/root/name"/>
<name>Foo</name>
</root>
XSL:
<xsl:template match="xsl:value-of">
<xsl:element name="{name()}">
<xsl:attribute name="select">
<xsl:value-of select="@select"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
期望的输出:
Foo
但它什么也不输出,或者使用其他解决方案它只输出/root/name。
是否有可能使这段代码工作?我使用 XSLT 1.0。
谢谢
【问题讨论】:
-
请发布一个可重现的示例,包括 XML 输入和预期输出 - 请参阅:minimal reproducible example。
-
@michael.hor257k 已编辑 :)