I've the below XML.
Code:
<list>
<list.item>
<label>
<star.page>94</star.page> (a)</label>
</list.item>
<list.item>
<label>(b)</label> As the
</list.item>
</list>
and i was trying to get the maximum string length of label by ignoring child nodes of label, I'm trying to do this using the below.
Code:
<xsl:template name="orderedlist" match="list">
<xsl:variable name="strl">
<xsl:choose>
<xsl:when test="descendant::list.item/label/node()[self::star.page]">
<xsl:value-of select="max(descendant::list.item/label/string-length(node()[not(*)]))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="max(descendant::list.item/label/string-length(text()))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div>
<xsl:value-of select="$strl"/>
</div>
<xsl:choose>
<xsl:when test="$strl > '6'">
<ol class="eng-orderedlist orderedlist1">
<xsl:apply-templates/>
</ol>
</xsl:when>
<xsl:otherwise>
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates/>
</ol>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="orderitem" match="list.item">
<xsl:apply-templates select="./label/node()[1][self::star.page]" mode="first"/>
<li class="item">
<div class="para">
<xsl:if test="./label">
<span class="item-num">
<xsl:value-of select="./label/text()"/>
</span>
</xsl:if>
<xsl:choose>
<xsl:when test="./text()">
<xsl:apply-templates select="child::node()[fn:not(self::label)]"/>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</div>
</li>
</xsl:template>
but it is giving the below error.
Code:
XSLT 2.0 Debugging Error: Error: file:///C:/Users/u0138039/Desktop/Proview/Law%20Reports/HK/11NOV/P1/XML/XSLT/Reports(RXXX_sma-DXXXHX).xslt:1421: Wrong occurrence to match required sequence type - Details: - XPTY0004: The supplied sequence ('3' item(s)) has the wrong occurrence to match the sequence type xs:string ('zero or one')
please let eme know where am i going wrong.
Thanks