需要通过 XSLT 获取不同的元素
我在名为 Query 的元素下有一个可能重复的表元素列表,我需要获取不同的表元素(不是它的值,而是标签/元素名称本身。
/ShopArea/Connection/Query/*
列表表名称包括重复项。
下面是 XML
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="ShopArea.xslt"?>
<ShopArea>
<Connection name="Connection1">
<Report date="25-09-2011">
<Query id="1">
<TABLE1>1.1</TABLE1>
<TABLE2>1.2</TABLE2>
<TABLE3>1.3</TABLE3>
</Query>
<Query id="2">
<TABLE21>2.1</TABLE21>
<TABLE22>2.2</TABLE22>
<TABLE23>2.3</TABLE23>
</Query>
</Report>
<Report date="26-09-2011">
<Query id="1">
<TABLE1>26 1.1</TABLE1>
<TABLE2>26 1.2</TABLE2>
<TABLE3>26 1.3</TABLE3>
</Query>
<Query id="2">
<TABLE21>26 2.1</TABLE21>
<TABLE22>26 2.2</TABLE22>
<TABLE23>26 2.3</TABLE23>
</Query>
</Report>
</Connection>
</ShopArea>
我引用了 如何在 XSLT 中选择唯一节点但我不是能够做对。
I have a list of table elements under element named Query that may duplicate, I need to fetch distinct table elements (not its value but the tag/element name itself.
/ShopArea/Connection/Query/*
lists the table names including duplicates.
Below is the XML
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="ShopArea.xslt"?>
<ShopArea>
<Connection name="Connection1">
<Report date="25-09-2011">
<Query id="1">
<TABLE1>1.1</TABLE1>
<TABLE2>1.2</TABLE2>
<TABLE3>1.3</TABLE3>
</Query>
<Query id="2">
<TABLE21>2.1</TABLE21>
<TABLE22>2.2</TABLE22>
<TABLE23>2.3</TABLE23>
</Query>
</Report>
<Report date="26-09-2011">
<Query id="1">
<TABLE1>26 1.1</TABLE1>
<TABLE2>26 1.2</TABLE2>
<TABLE3>26 1.3</TABLE3>
</Query>
<Query id="2">
<TABLE21>26 2.1</TABLE21>
<TABLE22>26 2.2</TABLE22>
<TABLE23>26 2.3</TABLE23>
</Query>
</Report>
</Connection>
</ShopArea>
I refered How to select unique nodes in XSLT but I'm not able to get it right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我。 XSLT 1.0。此转换使用简单的 Muenchian 分组:
当应用于提供的 XML 文档:
生成所需的正确结果(
查询
子元素的所有不同名称的元素):II。 XSLT 2.0:此转换使用
:I. XSLT 1.0. This transformation uses simple Muenchian grouping:
When applied on the provided XML document:
the wanted, correct result (all different names of elements that are children of a
Query
) is produced:II. XSLT 2.0: This transformation uses
<xsl:for-each-group>
: