XSLT当需要的输入和输出xslt相同时
问题描述:
从link开始,我需要创建一个XSLT,其中输入和输出XML应该与下面相同。请建议如何为以下输入XML创建XSLT以实现与输出相同的效果。XSLT当需要的输入和输出xslt相同时
<abc:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/">
<abc:Body>
<def:CheckOutput xmlns:def="http://www.test.com/service">
<def:Error>
<def:Code>0</def:Code>
</def:Error>
</def:CheckOutput>
</abc:Body>
</abc:Envelope>
答
你的XML是无效,导致命名空间前缀没有定义abc
。名称空间前缀NS1
已定义,但从未使用过。也许你的input-xml混淆了。
随着有效输入,您的XSLT会是这样:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:def="http://www.test.com/service">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
有一个读了关于XSLT恒等变换(https://en.wikipedia.org/wiki/Identity_transform)。 –
如果没有任何变化,转化的目的是什么? –