我正在尝试创建一个 XSLT 来转换 XML 文档,但是我在分组时遇到了问题。我为单个对象提取信息没有问题,但我不知道如何使用 xslt 对某些元素进行分组。我尝试过 xsl:for-each-group 和 xsl:key 进行分组,但我没有成功转换。
输入:
<?xml version="1.0" standalone="yes"?>
<root>
<node1>
<ID>2</ID>
<Name>ABCDE</Name>
<Age>21</Age>
<Skills>C++ C#</Skills>
<worklocation>IN</worklocation>
<designaton>Engineer I</designaton>
</node1>
<node2>
<ID>3</ID>
<Name>EFGH</Name>
<Age>12</Age>
<Skills>java</Skills>
<worklocation>USA</worklocation>
<designaton>Engineer II</designaton>
</node2>
</root>
期望的输出:
<root>
<node1>
<ID>2</ID>
<Name>ABCDE</Name>
<Age>21</Age>
<workInfo>
<Skills>C++ C#</Skills>
<worklocation>IN</worklocation>
<designaton>Engineer I</designaton>
</workInfo>
</node1>
<node2>
<ID>3</ID>
<Name>EFGH</Name>
<Age>12</Age>
<workInfo>
<Skills>java</Skills>
<worklocation>USA</worklocation>
<designaton>Engineer II</designaton>
</workInfo>
</node2>
</root>