替换 saxon:if 和 saxon:before xslt 2.0 中的函数 [英] Replacement for saxon:if and saxon:before functions in xslt 2.0
问题描述
是否有任何替代saxon:if和 saxon:before 在 XSLT 2.0/XPath 2.0 中的函数?>
我有这样的代码:
<xsl:变量名=之间"选择=撒克逊:如果($停止,撒克逊人:之前(以下兄弟姐妹::*,$停止),以下兄弟姐妹::*)"/>
想法是 between
变量应该包含当前节点和下一个 h1
或 h2
元素之间的所有元素(存储在 stop
变量),或所有剩余元素,如果没有下一个 h1
或 h2
.
我想在新的 XSLT 2.0 模板中使用此代码,我正在寻找 saxon:if
和 saxon:before
的替代品.
这是我的解决方案:
<xsl:变量名=之间"><xsl:when test="$stop"><xsl:sequence select="following-sibling::*[. << $stop]"/></xsl:when><xsl:否则><xsl:sequence select="following-sibling::*"/></xsl:否则></xsl:选择></xsl:变量>
它使用
和 <<
运算符(编码为 <<
),来自 XSLT 2.0/XPath 2.0.
它不像原始版本那么短,但它不再使用撒克逊扩展名.
Is there any replacement for saxon:if and saxon:before functions in XSLT 2.0 / XPath 2.0?
I have code like this:
<xsl:variable name="stop"
select="(following-sibling::h:h1|following-sibling::h:h2)[1]" />
<xsl:variable name="between"
select="saxon:if($stop,
saxon:before(following-sibling::*, $stop),
following-sibling::*)" />
Idea is that between
variable should contain all elements between current node and next h1
or h2
element (stored in stop
variable), or all remaining elements, if there is no next h1
or h2
.
I'd like to use this code in new XSLT 2.0 template, and I am looking for replacement for saxon:if
and saxon:before
.
Here is my solution:
<xsl:variable
name="stop"
select="(following-sibling::h:h1|following-sibling::h:h2)[1]" />
<xsl:variable name="between">
<xsl:choose>
<xsl:when test="$stop">
<xsl:sequence select="following-sibling::*[. << $stop]" />
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="following-sibling::*" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
It uses <xsl:sequence>
and <<
operator (encoded as <<
), from XSLT 2.0 / XPath 2.0.
It's not as short as original version, but it doesn't use saxon extensions anymore.
这篇关于替换 saxon:if 和 saxon:before xslt 2.0 中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!