我在 XSLT 2.0 上构建了这个函数和转换(请注意,下面元素的值实际上填充了正确的值,只是不想复制粘贴 3 个其他函数:-)):
<xsl:function name="foo:count_max_nodes_for_each_child_irrelevant_of_level">
<xsl:param name="root_element"/>
<xsl:element name="re">
<xsl:for-each select="$root_element/child::*" >
<xsl:element name="ch"> <!--{concat('level_1-',position())}-->
<xsl:attribute name="name">
<xsl:value-of select="concat('level_1-',position())" />
</xsl:attribute>
<xsl:value-of select="max(foo:create_nodes_count_in_levels(foo:count_level_nodes(.,max(./node()[not(node())]/count(ancestor-or-self::node())))))"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:function>
<xsl:variable name="this_root" select="." />
<xsl:variable name="max_vertical_nodes_for_each_child_from_root" as="element()" select="foo:count_max_nodes_for_each_child_irrelevant_of_level($this_root)" />
我认为这段代码会生成一个存储在变量中的 xml 树,我可以进一步向下钻取。但是当我尝试这个时:
<xsl:variable name="testin_purposes" select="$max_vertical_nodes_for_each_child_from_root/ch[1]" />
没有返回值,我几乎尝试了所有方法,甚至 exslt:node-set() 但没有任何帮助...我可以将此变量“max_vertical_nodes_for_each_child_from_root”作为参数发送,并且该参数再次(至少根据氧气)相同结构,但即使在另一个功能/转换中,我也无法深入研究......
任何猜测我错过了什么或做错了什么?
感谢您的任何回答!