XSLT - 获取节点组的最大子节点数
XSLT - Get maximum child nodes for group of nodes
是否可以在不循环遍历的情况下获取所有子节点中的最大孙节点?在下面的示例中,有四个文档节点,分别具有 4、5、1 和 2 个值节点。所以理想情况下,我想 return 5 作为表达式/函数的答案。
如果不在 xslt 2.0 中循环或使用 xpath,这是否可能?
XML:
<File>
<Document>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
<Value>..</Value>
</Document>
</File>
假设 File
元素是当前上下文项,您可以使用
max(Document/count(Value))
Document/count(Value)
给你一个整数序列(每个 Document
的 Value
children 的数量),max
从中选择最大值顺序。
您可以使用 max(/File/Document/count(*))
.
是否可以在不循环遍历的情况下获取所有子节点中的最大孙节点?在下面的示例中,有四个文档节点,分别具有 4、5、1 和 2 个值节点。所以理想情况下,我想 return 5 作为表达式/函数的答案。
如果不在 xslt 2.0 中循环或使用 xpath,这是否可能?
XML:
<File>
<Document>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
</Document>
<Document>
<Value>..</Value>
<Value>..</Value>
</Document>
</File>
假设 File
元素是当前上下文项,您可以使用
max(Document/count(Value))
Document/count(Value)
给你一个整数序列(每个 Document
的 Value
children 的数量),max
从中选择最大值顺序。
您可以使用 max(/File/Document/count(*))
.