这是我想使用 xsl 转换为以下结果的 xml。请提供任何帮助。这类似于 Windows 目录结构。这里的目录深度是动态的。
<?xml version="1.0" encoding="UTF-8"?>
<root>
<qc name="accounting" level="1">
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
<qc name="asset_allocation" level="1">
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
<qc name="asset_allocation" level="1">
<qc name="fund" level="2">
<qc name="v1_1" level="3"/>
</qc>
</qc>
<qc name="credit_quality" level="1">
<qc name="account" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
<qc name="credit_quality" level="1">
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
<qc name="credit_quality" level="1">
<qc name="v1_0" level="2"/>
</qc>
<qc name="credit_quality" level="1">
<qc name="v2_0" level="2"/>
</qc>
<qc name="portfolio" level="1">
<qc name="credit_quality" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
</root>
在上面的 xml 中,我有每个级别的名称。我想在同一级别对相同的名称进行分组。
结果:
<root>
<qc name="accounting" level="1">
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
<qc name="asset_allocation" level="1">
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
<qc name="v1_1" level="3"/>
</qc>
</qc>
<qc name="credit_quality" level="1">
<qc name="account" level="2">
<qc name="v1_0" level="3"/>
</qc>
<qc name="fund" level="2">
<qc name="v1_0" level="3"/>
</qc>
<qc name="v1_0" level="2"/>
<qc name="v2_0" level="2"/>
</qc>
<qc name="portfolio" level="1">
<qc name="credit_quality" level="2">
<qc name="v1_0" level="3"/>
</qc>
</qc>
</root>