Hi Martin,
     This XSL stylesheet transformation implementation issue, has been
fixed on Xalan-J's XSLT 3.0 development branch.

On Fri, Feb 20, 2026 at 9:08 PM Martin Honnen <[email protected]> wrote:
>
>
> I am using the latest Apache Xalan XSLT 3.0 development branch and find
> some odd behaviour when using
>
>    <xsl:variable name="n" as="xs:integer">
>
>      <xsl:number/>
>
>    </xsl:variable>
>
> that yields an error "(javax.xml.transform.TransformerException):
> XTTE0570 : XSL variable n's value doesn't conform to variable's type
> declaration xs:integer"
>
> I would expect the 'as="xs:integer"' attribute to cast the value of the
> variable to an xs:integer (see
> https://www.w3.org/TR/xslt-30/#variable-values explaining "Value is
> obtained by evaluating the sequence constructor, adjusted to the type
> required by the as attribute")
>
> Any thoughts as to why this is not working? I think that worked previously.
>
>
> Full code examples:
>
> XSLT:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                  xmlns:xs="http://www.w3.org/2001/XMLSchema";
>                  exclude-result-prefixes="#all"
>                  expand-text="yes"
>                  version="3.0">
>
> <xsl:mode on-no-match="shallow-copy"/>
>
> <xsl:template match="chapter">
>     <xsl:variable name="n" as="xs:integer">
>       <xsl:number/>
>     </xsl:variable>
>     <xsl:comment>Processing {node-name()} number {$n}</xsl:comment>
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates/>
>     </xsl:copy>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> XML
>
>
> <book title="Example book">
>    <chapter id="ch1">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
>    <chapter id="ch2">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
>    <chapter id="ch3">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
>    <chapter id="ch4">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
>    <chapter id="ch5">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
>    <chapter id="ch6">
>      <section>..</section>
>      <section>
>        <para>..</para>
>        <para><!-- paragraph in section --></para>
>      </section>
>    </chapter>
> </book>
>


-- 
Regards,
Mukul Gandhi

Reply via email to