【发布时间】:2022-01-04 14:51:57
【问题描述】:
我熟悉 XSL 中的简单 muenchian 分组,但我遇到了一个问题,老实说,我什至不知道如何处理它。
所以我有一个 XML:
<whiskies>
<whisky name="ABC" percent="" region="" type="">
<tastingNotesCollection/>
<bottles>
<bottle price="" size="" level="0" date=""/>
<bottle price="" size="" level="70" date=""/>
<bottle price="" size="" level="100" date=""/>
</bottles>
<comments/>
</whisky>
<whisky name="DEF" percent="" region="" type="">
<tastingNotesCollection/>
<bottles>
<bottle price="" size="" level="0" date=""/>
<bottle price="" size="" level="100" date=""/>
</bottles>
<comments/>
</whisky>
<whisky name="GHI" percent="" region="" type="">
<tastingNotesCollection/>
<bottles>
<bottle price="" size="" level="30" date=""/>
</bottles>
<comments/>
</whisky>
<whiskies>
我们的目标是按瓶子的高度对威士忌进行分组:
所以level="0" 被认为是空的。
从level="1" 到level="99" 的任何内容都被认为是开放的。
并且level="100" 被认为是未打开的。
所以转换后的结果(将在 HTML 中完成)应该如下所示:
<h1>Empty</h1>
<ul>
<li>ABC</li>
<li>DEF</li>
</ul>
<h1>Open</h1>
<ul>
<li>ABC</li>
<li>GHI</li>
</ul>
<h1>Unopened</h1>
<ul>
<li>ABC</li>
<li>DEF</li>
</ul>
如您所见,同一种威士忌可以出现在多个组中,具体取决于瓶子的数量和瓶子的装满程度。 第二个问题是,“Open”组没有确切的值,可以是 1 到 99 之间的任何值。
所以是的,我真的不知道这是否可以解决,或者如何开始。任何提示表示赞赏。
【问题讨论】:
-
请将预期结果作为代码发布。
标签: xslt-1.0 muenchian-grouping