XSLT-2 xsl:if 带有处理指令

问题描述 投票:0回答:1

嘿!

我想查询处理指令中是否出现':',然后才执行某些操作。 在我只匹配 oxy_comment_start 之前,我想对其进行改进。 在这种情况下,使用 AND 还是 if 函数对我来说并不重要,最主要的是我得到了所有 oxy_comment_start 并在注释中包含 ':' 的处理指令。

有人知道如何获得它吗?

这应该被忽略:

<?oxy_comment_start author="cln98vq" timestamp="2024" comment="Paratext has G"?>

这应该被处理:

<?oxy_comment_start author="cln98vq" timestamp="2024" comment="stultifere: steltifere G"?>                

我有

    <xsl:template match="processing-instruction('oxy_comment_start')">
        <div>
            <xsl:value-of select="replace(., '.*?comment=&quot;(.*?): \w+ [A-H]&quot;.*', '$1')"/>
        </div>
    </xsl:template>

获取所有 oxy_comment_starts。如果我尝试添加

match="processing-instruction('oxy_comment_start' and ':')"
,则会收到错误,并且
<xsl:if processing-instruction('oxy_comment_start')="contains(':')">
给出错误,处理指令不能放入 xsl:if 中。

xml xslt xslt-2.0 processing-instruction
1个回答
0
投票

使用

<xsl:template match="processing-instruction('oxy_comment_start')[contains(., ':')]">
当然是可能的。

© www.soinside.com 2019 - 2024. All rights reserved.