[英]How to remove type attribute from XML using XSLT1.0
Assume that I have an XML as below.假设我有一个如下所示的 XML。
<CustomerOrder>
<CustomerId type="string">1000</CustomerId>
<CustomerName type="string">Johnny</CustomerName>
<Age type="Number">20</Age>
</CustomerOrder>
I need to write and XSL transformer so that I can remove the type attribute and the final output should be something like below.我需要编写 XSL 转换器,以便我可以删除类型属性,最终的 output 应该如下所示。
<CustomerOrder>
<CustomerId>1000</CustomerId>
<CustomerName>Johnny</CustomerName>
<Age>20</Age>
</CustomerOrder>
Any ideas??有任何想法吗??
Just use this stylesheet realizing what was suggested in the first comment:只需使用此样式表即可实现第一条评论中的建议:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<!-- identity template - copies everything as it is except for other rules matching -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<!-- Match all type attributes and ignore them -->
<xsl:template match="@type" />
</xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.