【发布时间】:2021-12-24 06:14:28
【问题描述】:
需要创建<entry><morerows/></entry>
- 如果
<entry>/@morerows有以下兄弟<row>元素 - 在需要检查
<entry>/@morerows的位置之前,然后在下面的兄弟<row>中创建<entry><morerows/></entry>。 - 如果您在输入中看到第二个元素中的
<entry>元素较少,因为在第一个元素中使用了@morerows 属性(@morerows属性表示<rowspan>元素概念)
示例:假设<entry>/@morerows的位置是第6位,那么需要在following-sibling 6th place entry中的第6位位置创建下一个兄弟<entry><morerows/></entry>
请帮助我完成上述具有挑战性的任务并提前感谢
输入xml:
<table>
<tgroup>
<thead>
<row>
<entry><p></p></entry>
<entry namest="col2" nameend="col3"><p>Class A Common</p></entry>
<entry namest="col4" nameend="col5"><p>Class B Common</p></entry>
<entry morerows="1"><p>Additional</p></entry>
<entry morerows="1"><p>Retained</p></entry>
<entry morerows="1"><p>Accumulated</p></entry>
<entry namest="col9" nameend="col10"><p>Class A 1</p></entry>
<entry morerows="1"><p>Noncontrolling</p></entry>
<entry morerows="1"><p>Total</p></entry>
</row>
<row>
<entry><p>content here</p></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
</row>
</thead>
</tgroup>
</table>
预期输出:
<table>
<tgroup>
<thead>
<row>
<entry><p></p></entry>
<entry namest="col2" nameend="col3"><p>Class A Common</p></entry>
<entry namest="col4" nameend="col5"><p>Class B Common</p></entry>
<entry morerows="1"><p>Additional</p></entry>
<entry morerows="1"><p>Retained</p></entry>
<entry morerows="1"><p>Accumulated</p></entry>
<entry namest="col9" nameend="col10"><p>Class A 1</p></entry>
<entry morerows="1"><p>Noncontrolling</p></entry>
<entry morerows="1"><p>Total</p></entry>
</row>
<row>
<entry><p>content here</p></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
<entry><morerows/></entry>
<entry><morerows/></entry>
<entry><morerows/></entry>
<entry><p>content 1</p></entry>
<entry><p>content 2</p></entry>
<entry><morerows/></entry>
<entry><morerows/></entry>
</row>
</thead>
</tgroup>
</table>
【问题讨论】:
-
请您编辑您的示例并删除所有
<colspec.../>元素吗?他们分散了 entry 和 morerows 元素的注意力……滚动太多了 :) 谢谢。 -
单个示例并不能很好地说明需求,但请查看现有的表规范化示例。
-
嗨 @ZachYoung 我删除了
元素,你能解决这个问题吗,这个非常具有挑战性的任务。 -
谢谢。我同意马丁的观点……我很难理解应该发生什么。在您的示例中,
<entry><morerows/></entry>的最终位置似乎与<entry morerows... />的位置无关...您的示例直观地显示了它们应该结束的位置,但这只是因为空格。