替换 saxon:if 和 saxon:before xslt 2.0 中的函数 [英] Replacement for saxon:if and saxon:before functions in xslt 2.0

查看:27
本文介绍了替换 saxon:if 和 saxon:before xslt 2.0 中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何替代saxon:ifsaxon:before 在 XSLT 2.0/XPath 2.0 中的函数?>

我有这样的代码:

<xsl:变量名=之间"选择=撒克逊:如果($停止,撒克逊人:之前(以下兄弟姐妹::*,$停止),以下兄弟姐妹::*)"/>

想法是 between 变量应该包含当前节点和下一个 h1h2 元素之间的所有元素(存储在 stop 变量),或所有剩余元素,如果没有下一个 h1h2.

我想在新的 XSLT 2.0 模板中使用此代码,我正在寻找 saxon:ifsaxon:before 的替代品.

解决方案

这是我的解决方案:

<xsl:变量名=之间"><xsl:when test="$stop"><xsl:sequence select="following-sibling::*[. &lt;< $stop]"/></xsl:when><xsl:否则><xsl:sequence select="following-sibling::*"/></xsl:否则></xsl:选择></xsl:变量>

它使用 <<运算符(编码为 &lt;&lt;),来自 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::*[. &lt;&lt; $stop]" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:sequence select="following-sibling::*" />
         </xsl:otherwise>
    </xsl:choose>
</xsl:variable>

It uses <xsl:sequence> and << operator (encoded as &lt;&lt;), 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆