Xslt 面临一些属性节点问题

Xslt 面临一些属性节点问题,xslt,Xslt,我的全长XSLT上有以下代码,它在转换过程中会产生一些错误。 错误为XPTY0004:不允许将多个项目的序列作为matches()的第一个参数。 标签 这里怎么了?请将变量n2更改为/genderant::text()[1] <xsl:template match="par[@class='tablecaption']" exclude-result-prefixes="html"> <p class="caption1"> <xsl:variable na

我的全长XSLT上有以下代码,它在转换过程中会产生一些错误。 错误为
XPTY0004:不允许将多个项目的序列作为matches()的第一个参数。


标签


这里怎么了?请将变量
n2
更改为
/genderant::text()[1]

<xsl:template match="par[@class='tablecaption']" exclude-result-prefixes="html">
<p class="caption1">
<xsl:variable name="n2" select="./descendant::text()[1]"/>
<xsl:attribute name="id">
<xsl:if test="matches($n2, '(Table)\s(\d+|[A-Z])(\.)(\d+)')">
<xsl:variable name="y2" select="replace($n2, '(Table)\s(\d+|[A-Z])(\.)(\d+)', '$4')"/>Tab<xsl:value-of select="normalize-space(substring($y2, 1, 2))"/></xsl:if>
</xsl:attribute>
<strong><xsl:apply-templates/></strong></p>
</xsl:template>

标签

有了这个输入

<root>
    <par class="tablecaption"> Table A.1 <bold>text2</bold></par>
</root>

表A.1文本2
它得到:

<root>
    <p class="caption1" id="Tab1"><strong> Table A.1 <bold>text2</bold></strong></p>
</root>

表A.1文本2


那么,这里的解决方案是什么?您能告诉我要做的更改吗?将
替换为
oops,应该是
<root>
    <p class="caption1" id="Tab1"><strong> Table A.1 <bold>text2</bold></strong></p>
</root>