XSLT 转换样式从 3.0 降低到 2.0 - 变量引用错误 [英] XSLT converting style down from 3.0 to 2.0 - variable reference error
问题描述
我有一个很大的 XSL 3.0 样式表,我需要将其转换为 XSL 2.0.整个文档中似乎重复了一个错误,但我不知道如何解决.
I have a large XSL 3.0 stylesheet which I need to convert to XSL 2.0. It seems there is one error repeated throughout the document, but I'm not sure how to fix it.
例如,在 XSL 3.0 中,我声明了这些变量:
For example, in XSL 3.0 I declare these variables:
<xsl:variable name="glosspath"
select="/tei:TEI/tei:text//tei:add"/>
<xsl:variable name="apppath"
select="/tei:TEI/tei:text//tei:del | /tei:TEI/tei:text//tei:surplus | /tei:TEI/tei:text//tei:supplied[@reason='added']
| /tei:TEI/tei:text//tei:choice[@style='sic'] | /tei:TEI/tei:text//tei:sic[@style='sic'] | /tei:TEI/tei:text//tei:gap
| /tei:TEI/tei:text//tei:note[@type='reading']"/>
然后我在各种上下文中使用这些变量,例如
And then I use these variables in a variety of contexts such as
<xsl:template match="$glosspath">...
或:
<xsl:number count="$apppath" format="a" level="any"/>
变量都抛出相同的错误:XTSE0340 XSLT Pattern syntax error at line 635 in {$glosspath}: A variable reference is not allowed in a XSLT pattern (除了在谓词中)
The variables all throw the same error: XTSE0340 XSLT Pattern syntax error at char 0 on line 635 in {$glosspath}: A variable reference is not allowed in an XSLT pattern (except in a predicate)
我查看了网站上的各种答案,例如 this 和指南,但我不是确定如何重新编写它以符合要求...
I've looked at various answers on the site like this and at the guidelines, but I'm not sure how to re-write this to be compliant...
非常感谢.
推荐答案
我相信对于您的模板匹配,您可以做到这一点...
I believe for your template match you can do this...
<xsl:template match="*[. intersect $glosspath]">
对于数字,您可以这样做(尽管这不一定有效)
And for the number, you can do this (although this is not necessarily as efficient)
<xsl:number count="*[. intersect $apppath]" format="a" level="any"/>
更改为使用 intersect
.感谢 Martin Honnen
Changed to use intersect
. Thanks to Martin Honnen
这篇关于XSLT 转换样式从 3.0 降低到 2.0 - 变量引用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!