【发布时间】:2017-01-26 14:21:53
【问题描述】:
我正在尝试使用 XSLT 转换 XML 文档。原始 XML 文档中的一些元素在我的 XSL 文档中未使用,但这些元素的值被添加到结果中。我怎样才能省略这些元素?示例:
XML
<?xml version="1.0"?>
<data>
<id>1</id>
<name>Test</name>
<description>Test description</description>
</data>
XSL
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="id">
<id>
<xsl:apply-templates/>
</id>
</xsl:template>
</xsl:stylesheet>
结果
<id>1</id>TestTest description
预期结果
<id>1</id>
【问题讨论】: