XSLT 属性分组
输入文件格式是
<Node1 Attribute11="colors" >
<Node2 Attribute21="Order1" Attribute22="123" Attribute23="red" />
<Node2 Attribute21="Order2" Attribute22="456" Attribute23="blue" />
<Node2 Attribute21="Order1" Attribute22="789" Attribute23="green" />
<Node2 Attribute21="Order2" Attribute22="012" Attribute23="yellow" />
<Node2 Attribute21="Order3" Attribute22="345" Attribute23="red" />
<Node2 Attribute21="Order1" Attribute22="678" Attribute23="blue" />
</Node1>
所需的输出是
<Node1 Attribute11="colors" >
<Node3 Attribute21="Order1" >
<Node2 Attribute21="Order1" Attribute22="123" Attribute23="red" />
<Node2 Attribute21="Order1" Attribute22="789" Attribute23="green" />
<Node2 Attribute21="Order1" Attribute22="678" Attribute23="blue" />
</Node3>
<Node3 Attribute21="Order2">
<Node2 Attribute21="Order2" Attribute22="456" Attribute23="blue" />
<Node2 Attribute21="Order2" Attribute22="012" Attribute23="yellow" />
</Node3>
<Node3 Attribute21="Order3">
<Node2 Attribute21="Order3" Attribute22="345" Attribute23="red" />
</Node3>
</Node1>
通过分组,我无法获得所需格式的输出。 非常感谢任何有关 XSLT 1.0 的帮助
The input file format is
<Node1 Attribute11="colors" >
<Node2 Attribute21="Order1" Attribute22="123" Attribute23="red" />
<Node2 Attribute21="Order2" Attribute22="456" Attribute23="blue" />
<Node2 Attribute21="Order1" Attribute22="789" Attribute23="green" />
<Node2 Attribute21="Order2" Attribute22="012" Attribute23="yellow" />
<Node2 Attribute21="Order3" Attribute22="345" Attribute23="red" />
<Node2 Attribute21="Order1" Attribute22="678" Attribute23="blue" />
</Node1>
The desired output is
<Node1 Attribute11="colors" >
<Node3 Attribute21="Order1" >
<Node2 Attribute21="Order1" Attribute22="123" Attribute23="red" />
<Node2 Attribute21="Order1" Attribute22="789" Attribute23="green" />
<Node2 Attribute21="Order1" Attribute22="678" Attribute23="blue" />
</Node3>
<Node3 Attribute21="Order2">
<Node2 Attribute21="Order2" Attribute22="456" Attribute23="blue" />
<Node2 Attribute21="Order2" Attribute22="012" Attribute23="yellow" />
</Node3>
<Node3 Attribute21="Order3">
<Node2 Attribute21="Order3" Attribute22="345" Attribute23="red" />
</Node3>
</Node1>
With the grouping I am not able to get the output in the desired format.
Any help with XSLT 1.0 is much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Saxon-HE 9.2.1.1 测试的 XSLT 1.0 解决方案
带循环的解决方案:
不带循环的解决方案:
XSLT 1.0 solutions tested with Saxon-HE 9.2.1.1
Solution with looping:
Solution without looping: