我想将属于<line/>
的@page
属性的值(<section type="cover"/>
的后代)更改为<section type="contents"/>
的(max(@page) + 1)
。属性的最大值
基本上我需要封面部分的页码比内容部分的最后一个数字页码要高1。
注意:<line/>
节点并不总是兄弟,它们可以嵌套在任何级别。
例如改变这个:
<root>
<section type="contents">
<line page="i">text</line>
<line page="ii">text</line>
<line page="1">text</line>
<line page="1">text</line>
<line page="2">text</line>
<block>
<line page="3">text</line>
<line page="4">text</line>
</block>
</section>
<section type="cover">
<line page="i">text</line>
<line page="i">text</line>
</section>
</root>
这样:
<root>
<section type="contents">
<line page="i">text</line>
<line page="ii">text</line>
<line page="1">text</line>
<line page="1">text</line>
<line page="2">text</line>
<block>
<line page="3">text</line>
<line page="4">text</line>
</block>
</section>
<section type="cover">
<line page="5">text</line> <!-- @page changes to max()+1 -->
<line page="5">text</line> <!-- @page changes to max()+1 -->
</section>
</root>
有没有一种简单的方法与PHP5,XSLT1.0,XPATH实现这一目标?
好问题,+1。请参阅我的回答,以获取完整的解决方案,该解决方案使用XSLT 1.0中最快的已知方式查找最大值。 – 2010-10-21 13:35:06