Project

Profile

Help

Should I be able to make a mode declared in a used package the default-mode in a using package without using xsl:accept?

Added by Martin Honnen over 7 years ago

When I have one package declaring a mode @m1@ as @public@




    

    
        
            
            
        
    


and I now want to use it as a default-mode in a different stylesheet, should it suffice to simply use the package and set the default-mode, as in





    


or do I need to accept the mode in the using package as in




    
        
    


?

Altova XML Spy 2017 now has packages support and does not accept the @default-mode="m1"@ in the first stylesheet while Saxon does accept it.

The Altova support team told me that the current spec https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/#accepting-components defines that the mode in the using package is private unless an @xsl:accept@ make it public, which the table in the spec seems to express with


Visibility in used package CQ	Visibility in using package CP
public                                               private

and that therefore the mode @m1@ can't be used as the @default-mode@, unless an @xsl:accept@ makes it public in the using package.

Based on that, it seem Saxon (tested with 9.7.0.8 EE J) has a bug running





    


without indicating the error about the default mode.

A sample input is



    
        
            foo 1
            
                
                    foo 2
                
            
        
    


Replies (3)

Please register to reply

RE: Should I be able to make a mode declared in a used package the default-mode in a using package without using xsl:accept? - Added by Michael Kay over 7 years ago

Firstly, it's great to know that Altova are studying and implementing the spec. I just wish they would participate in its development, if only by providing feedback when they find issues. Contributing test cases would be public-spirited too...

Secondly, I may be missing it, but I don't see a rule saying that the default mode must be have public visibility. On the contrary, we explicitly say that the default mode can be the unnamed mode, and the unnamed mode always has private visibility.

So I would say that your code is valid.

RE: Should I be able to make a mode declared in a used package the default-mode in a using package without using xsl:accept? - Added by Martin Honnen over 7 years ago

Thanks for your response, I have now searched the spec and https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/#dt-unnamed-mode has a table that says about the visibility of modes

visibility One of public, private, or final. The default is private. See 3.5.3.1 Visibility of Components. If the mode is unnamed, that is, if the name attribute is absent, then the visibility attribute if present must have the value private. A named mode is not eligible to be used as the initial mode if its visibility is private.

so it seems that Altova is right that the initial mode can't be a private mode and as the visibility of @m1@ in the using package is private without an @xsl:accept@ or @xsl:override@ it appears to be that Saxon should raise an error on the stylesheet trying to use the mode @m1@ as the @default-mode@ without doing an @xsl:accept@.

RE: Should I be able to make a mode declared in a used package the default-mode in a using package without using xsl:accept? - Added by Michael Kay over 7 years ago

There's actually still some debate about some of the rules in this area, so I won't be making any changes until that is bedded down.

But the statement

A named mode is not eligible to be used as the initial mode if its visibility is private.

doesn't imply

A named mode is not eligible to be used as the default mode if its visibility is private.

The default mode in xsl:stylesheet is primarily a default value for the mode attribute of xsl:template and xsl:apply-templates. If you have a stylesheet module that's concerned with generating a table-of-contents, and most of the template rules are in mode TOC, then it makes sense to set default-mode="TOC" and leave the mode attribute absent. It might also make perfect sense to make this mode private, so that the only way of invoking the TOC functionality is through some public interface like a make-table-of-contents() function.

We do say: If no initial mode is supplied, then the mode used is that named in the default-mode attribute of the (explicit or implicit) xsl:package element of the top-level package or in the absence of such an attribute, the unnamed mode.] which implies that using a private mode as the default mode in the top-level package is probably a bad idea. This is actually the topic currently open in the WG: see bug 29827

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29827

    (1-3/3)

    Please register to reply