是否可以用XPath表达式替换标记属性的值。即:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../Product/templates.xsl"/>
<xsl:output method="xml"/>
<xsl:template name="root" match="/">
<test-report start="substring(abcd, 1, 2)" stop="2015-10-07 16:54.103">
<xsl:call-template name="temp"/>
</test-report>
</xsl:template>
<xsl:template name="temp">
<xsl:value-of select="'TEXT_RIKO'"/>
</xsl:template>输出是
<?xml version="1.0" encoding="UTF-8"?>
<test-report start="substring(abcd, 1, 2)" stop="2015-10-07 16:54.103">
TEXT_RIKO
</test-report>我想要的是(在输出文件中)开始属性的值是函数子字符串的输出,即ab。
谢谢!
发布于 2015-10-08 08:00:55
答案是“是”,但您需要使用属性值模板来做到这一点。
只需写这个
<test-report start="{substring(abcd, 1, 2)}" stop="2015-10-07 16:54.103">大括号表示要计算的表达式,而不是字面意义上的输出。
https://stackoverflow.com/questions/33009742
复制相似问题