如何在java中使用xslt从xml中使用group-by进行选择
我有这个xml文件,
<SearchEngine>
<XV2_2284_425_1_1>
<RowNumber>1</RowNumber>
<ID>104</ID>
<Reference_x0020_ID>X_0000000017</Reference_x0020_ID>
<Discipline>Arch</Discipline>
<DocType>Doc1</DocType>
</XV2_2284_425_1_1>
<XV2_2284_425_1_3>
<RowNumber>2</RowNumber>
<ID>106</ID>
<Reference_x0020_ID>X_0000000020</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc3</DocType>
</XV2_2284_425_1_3>
<XV2_1234_425_1_1>
<RowNumber>3</RowNumber>
<ID>105</ID>
<Reference_x0020_ID>X_0000000018</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc2</DocType>
</XV2_1234_425_1_1>
<XV2_1234_425_2_1>
<RowNumber>4</RowNumber>
<ID>107</ID>
<Reference_x0020_ID>X_0000000019</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc3</DocType>
</XV2_1234_425_2_1>
</SearchEngine>
我试图获取按Discipline和DocType分组的所有Reference_x0020_ID(对于Discipline和DocType的所有值) 我尝试使用 XSLT 但没有运气
任何帮助将不胜感激
谢谢
I have this xml file
<SearchEngine>
<XV2_2284_425_1_1>
<RowNumber>1</RowNumber>
<ID>104</ID>
<Reference_x0020_ID>X_0000000017</Reference_x0020_ID>
<Discipline>Arch</Discipline>
<DocType>Doc1</DocType>
</XV2_2284_425_1_1>
<XV2_2284_425_1_3>
<RowNumber>2</RowNumber>
<ID>106</ID>
<Reference_x0020_ID>X_0000000020</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc3</DocType>
</XV2_2284_425_1_3>
<XV2_1234_425_1_1>
<RowNumber>3</RowNumber>
<ID>105</ID>
<Reference_x0020_ID>X_0000000018</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc2</DocType>
</XV2_1234_425_1_1>
<XV2_1234_425_2_1>
<RowNumber>4</RowNumber>
<ID>107</ID>
<Reference_x0020_ID>X_0000000019</Reference_x0020_ID>
<Discipline>Structural</Discipline>
<DocType>Doc3</DocType>
</XV2_1234_425_2_1>
</SearchEngine>
I am trying to get all Reference_x0020_ID grouped by Discipline and DocType (for all values of both Discipline and DocType)
I tried using XSLT but no luck
Any help would be appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
I. XSLT 1.0
这是一个 XSLT 1.0 解决方案:
当此转换应用于提供的 XML 文档时:
产生所需的正确结果: >
说明:慕尼黑分组< /strong> 两个键。
二. XSLT 2.0
此转换:
应用于同一 XML 文档时会产生相同的所需正确结果。
说明:
XSLT 2.0 指令的使用I. XSLT 1.0
Here is an XSLT 1.0 solution:
when this transformation is applied on the provided XML document:
the wanted, correct result is produced:
Explanation: Muenchian grouping on two keys.
II. XSLT 2.0
This transformation:
when applied on the same XML document produces the same wanted, correct result.
Explanation: Use of the
<xsl:for-each-group>
XSLT 2.0 instruction