xspec抛出的预期结果:
<nl/>
<test:ws xmlns:test="http://www.jenitennison.com/xslt/unit-test">
</test:ws>
我想要的预期结果是我们想要的输出元素:
<nl/>
答案 0 :(得分:0)
您需要在XSLT中做三件事:
xmlns:test="http://www.jenitennison.com/xslt/unit-test"
exclude-result-prefixes="xs test"
<xsl:template match="test:ws"/>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nl/>
<test:ws xmlns:test="http://www.jenitennison.com/xslt/unit-test"></test:ws>
</root>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://www.jenitennison.com/xslt/unit-test"
exclude-result-prefixes="xs test" version="2.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="test:ws"/>
</xsl:stylesheet>
输出:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nl/>
</root>
请参阅下面提到的链接以供参考: