xslt - Facing some attribute node issue -
i having following code on full length xslt, and, creates errors during transformation. error xpty0004: sequence of more 1 item not allowed first argument of matches()
<xsl:template match="par[@class='tablecaption']" exclude-result-prefixes="html"> <p class="caption1"> <xsl:variable name="n2" select="./text()|./*/text()"/> <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>
what wrong here? pls
change variable n2
./descendant::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>
with input
<root> <par class="tablecaption"> table a.1 <bold>text2</bold></par> </root>
it gets:
<root> <p class="caption1" id="tab1"><strong> table a.1 <bold>text2</bold></strong></p> </root>
Comments
Post a Comment