我有一个 XSL 程序,它反过来生成一个 XSL 程序,根据输入可能如下所示:
<xsl:variable name="patterns"/> <!--empty in this particular case-->
<xsl:template name="token">
<xsl:for-each select="$patterns/pattern">
...
然后当我运行生成的样式表时,撒克逊人,保佑它的心,显然是在做某种静态分析并抱怨:
XPTY0019: Required item type of first operand of '/' is node(); supplied value has item type xs:string
甚至不会编译样式表。
我的解决方法是在 $patterns 节点集中生成一个虚拟元素,但是这里有没有更简洁的方法,或者抑制编译错误的方法?