Subject: Re: [xsl] Doing math in XSLT? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 1 Apr 2024 18:43:33 -0000 |
I have the following XML
<row> B B B B <entry nameend="col2" namest="col1"> B B B B B B B <p>OpenID Connect client settings</p> B B B B B B B <note B B B B B B B B B B B id="note_N1055C" B B B B B B B B B B B >The following parameters are only applicable B B B B B B B B B B B when this client supports the OpenID Connect use B B B B B B B B B B B cases.</note> B B B B </entry> </row>
The attributes nameend="col2" namest="col1" indicate that this row spans 2 columns (end - start + 1).
I've tried this to try and get the numbers 1 and 2 from these strings, but I get NaN errors
<xsl:variable name="start" B B B B select="number(substring-after(@namest, 'col'))" as="xs:double"/> <xsl:variable name="end" B B B B select="number(substring-after(@nameend, 'col'))" as="xs:double"/>
I've tried this in different combinations with/without the as="xs:double" and number() and those variations throw the same error.
B <xsl:template match="entry"> <xsl:variable name="start" B B B select="number(substring-after(@namest, 'col'))" as="xs:double"/> <xsl:variable name="end" B B B select="number(substring-after(@nameend, 'col'))" as="xs:double"/> B B B <xsl:comment>{$end - $start + 1}</xsl:comment> B </xsl:template>
doesn't give any error with Saxon HE 12 and outputs e.g. <!--2--> for your sample XML.
Please show us minimal but complete code that gives that error and tell us which XSLT processor and version you use.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Doing math in XSLT?, dvint@xxxxxxxxx | Thread | Re: [xsl] Doing math in XSLT?, dvint dvint@xxxxxxxx |
[xsl] Doing math in XSLT?, dvint@xxxxxxxxx | Date | Re: [xsl] Doing math in XSLT?, Dimitre Novatchev dn |
Month |