Xml XSLT使用属性值重命名元素
我是xslt新手。我试图用属性名重命名my.xml的元素名,并删除attAttribute 这是我要转换的XML示例:Xml XSLT使用属性值重命名元素,xml,xslt,Xml,Xslt,我是xslt新手。我试图用属性名重命名my.xml的元素名,并删除attAttribute 这是我要转换的XML示例: <configdata> <element xsi:type="AAA"> <attributes> <att1>0</att1> <att2>1</att2> <att3>25</att3> </attributes&g
<configdata>
<element xsi:type="AAA">
<attributes>
<att1>0</att1>
<att2>1</att2>
<att3>25</att3>
</attributes>
</element>
<element xsi:type="BBB">
<attributes>
<att4>23</att4>
<att5>44</att5>
<att6>12</att6>
</attributes>
</element>
</configdata>
0
1.
25
23
44
12
期望输出:
<configdata>
<AAA>
<attributes>
<att1>0</att1>
<att2>1</att2>
<att3>25</att3>
</attributes>
</AAA>
<BBB>
<attributes>
<att4>23</att4>
<att5>44</att5>
<att6>12</att6>
</attributes>
</BBB>
</configdata>
0
1.
25
23
44
12
xml有数百个元素(AAA、BBB、CCC、DDD…),因此,任何通用的解决方案都是很好的
我尝试了以下xslt代码,但在输出中,我保持输入xml不变
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="element">
<xsl:element name="{@xsi:type}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
我将感谢任何帮助。谢谢
<xsl:template match="element">
<xsl:element name="{@xsi:type}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
您想处理
的所有子级。但是,
不能做到这一点。它所做的只是输出元素的文本内容。嗨,托马拉克,谢谢你的回答。我试过:但在输出中我只得到心房肌的de值。。0125 234412我没有说你应该删除身份模板。;)