所以我有这个 XML
<?xml version="1.0" encoding="UTF-8"?>
<school name="AMU" location="CA">
<student name="Jonny">
<info age="20" class="A" />
</student>
</school>
我想做的是只创建和之间的school
表student
,
<?xml version="1.0" encoding="UTF-8"?>
<school name="AMU" location="CA">
<table>
.....
<table />
<student name="Jonny">
<info age="20" class="A" />
</student>
</school>
我知道如何使用 foreach-group
和concat
它创建一个表。
XSL 我正在研究,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes" />
<xsl:template match="school">
<xsl:element name="school">
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="location">
<xsl:value-of select="@location" />
</xsl:attribute>
<table>
created table
</table>
<xsl:copy>
<xsl:apply-templates select="student" />
</xsl:copy>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
我的问题是我想复制我的表下的所有节点,所以我的输出 XML 将在和之间有表,school
并且student
没有其他任何改变。(表工作正常)
我应该怎么办?
谢谢。