[Home] [By Thread] [By Date] [Recent Entries]

Subject: Re: xsl:package use question
From: "Mukul Gandhi mukulg@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Feb 2026 11:25:23 -0000
Hi Mike,

On Tue, Feb 10, 2026 at 3:22b/PM Michael Kay michaelkay90@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> The specification for xsl:expose says
>
> The names attribute selects a subset of these components by name (and in
> the case of functions, arity); its value is a whitespace-separated sequence
> of tokens each of which is either a NameTest
> <https://www.w3.org/TR/xpath-30/#prod-xpath30-NameTest>XP30 or a
> NamedFunctionRef
> <https://www.w3.org/TR/xpath-30/#prod-xpath30-NamedFunctionRef>XP30.
> (Examples are *, p:*, *:local, p:local, and p:local#2.)
>
> I don't think it's 100% clear that when referring to a function, including
> the arity is mandatory, but that's Saxon's interpretation. Erratum XT30.E36
> clarifies this.
>
>  XT30.E36   It should be made more clear that in xsl:accept and
> xsl:expose, a NameTest with no arity cannot be used to identify functions.
>
> The XSL WG worked on errata for the XSLT 3.0 specification before it
> disbanded in 2019. Unfortunately the "errata" link in the published
> specification leads nowhere, but the draft errata are present in the GitHub
> repository, and I have extracted a copy for convenience at
>
> https://github.com/user-attachments/files/25205612/xslt-30-errata.html
>

Thanks for all these valuable information.

I've finally been able to have this working with Saxon 10 EE as follows,

test1.xml

<?xml version="1.0" encoding="UTF-8"?>
<info1/>

test1.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:package name="http://package1"
                      package-version="1.0.0"
                      version="3.0"
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:fn0="http://fn0"
                      exclude-result-prefixes="fn0">

      <xsl:output method="xml" indent="yes"/>

      <xsl:mode/>

      <xsl:use-package name="http://package2" package-version="1.0.0">
           <xsl:accept component="function" names="fn0:abc#0"
visibility="public"/>
      </xsl:use-package>

     <xsl:template match="/">
         <result>
             <xsl:value-of select="fn0:abc()"/>
         </result>
     </xsl:template>

</xsl:package>

test2.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:package name="http://package2"
                      package-version="1.0.0"
                      version="3.0"
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      xmlns:fn0="http://fn0"
                      exclude-result-prefixes="xs fn0">

         <xsl:expose component="function" names="fn0:abc#0"
visibility="public"/>

         <xsl:function name="fn0:abc" visibility="public" as="xs:string">
                <xsl:sequence select="'Hello, ' || fn0:abc1()"/>
         </xsl:function>

          <xsl:function name="fn0:abc1" visibility="private" as="xs:string">
               <xsl:sequence select="'..., ref local only function. This
cannot be accessed, from outside this package.'"/>
          </xsl:function>

</xsl:package>

When I do an XSL transform for test1.xml with test1.xsl, I get following
result (which is what I've been expecting),

<?xml version="1.0" encoding="UTF-8"?>
<result>Hello, ..., ref local only function. This cannot be accessed, from
outside this package.</result>

I actually also had to add an <xsl:mode/> instruction within test1.xsl,
without which I've been getting an error,

XTSE3085  The unnamed mode has not been declared in an xsl:mode declaration
Errors were reported during stylesheet compilation


--
Regards,
Mukul Gandhi

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member