1 回答
TA贡献1752条经验 获得超4个赞
这是一个简化的示例:
XML
<input>
<item/>
<item/>
<item/>
</input>
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" cdata-section-elements="Value"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/input">
<output>
<xsl:for-each select="item">
<DataPoint>
<Name>
<xsl:value-of select="concat('Carrier.Requirements', position())"/>
</Name>
<Value>Here is the response text</Value>
</DataPoint>
</xsl:for-each>
</output>
</xsl:template>
</xsl:stylesheet>
结果
<?xml version="1.0" encoding="utf-16"?>
<output>
<DataPoint>
<Name>Carrier.Requirements1</Name>
<Value><![CDATA[Here is the response text]]></Value>
</DataPoint>
<DataPoint>
<Name>Carrier.Requirements2</Name>
<Value><![CDATA[Here is the response text]]></Value>
</DataPoint>
<DataPoint>
<Name>Carrier.Requirements3</Name>
<Value><![CDATA[Here is the response text]]></Value>
</DataPoint>
</output>
演示:https ://xsltfiddle.liberty-development.net/94hvTAn
- 1 回答
- 0 关注
- 151 浏览
添加回答
举报