Adding xsl:note to the schema for XSLT 4.0

A question for XSD experts and in particular for Michael Sperberg-McQueen!

I'm struggling to work out how to add xsl:note to the schema for XSLT 4.0.

The rule is simply: an xsl:note element can appear anywhere (as a descendant of xsl:stylesheet | transform | package).

It's easy enough to add it to the substitution group for instructions and declarations.

What's difficult is handling things like xsl:for-each, whose content model is currently (xsl:sort* instruction*). Handling each such case independently is really hard work.

One possibility is to use xs:defaultOpenContent mode="interleave", but that doesn't allow me to nominate a permitted list of names that may appear, only a list of names that must not appear.

The best I can come up with is

<xs:defaultOpenContent mode="interleave" appliesToEmpty="true">
  <xs:any processContents="strict" namespace="##targetNamespace" notQName="xsl:accept xsl:accumulator xsl:accumulator-rule ...."/>
</xsLdefaultOpenContent>

That is, in order to allow xsl:note to appear anywhere, I allow any of the 85 global elements in the XSLT namespace to appear anywhere, except for the 84 that are explicitly disallowed.

Another option would be to use

<xs:defaultOpenContent mode="interleave" appliesToEmpty="true">
  <xs:any processContents="lax" namespace="##targetNamespace"/>
</xsLdefaultOpenContent>

with an assertion at the xsl:stylesheet level that if any descendant in the XSLT namespace has a type of xs:anyType then its name must be xsl:note.

Any better suggestions?

Michael Kay
Saxonica

Received on Thursday, 22 June 2023 22:59:55 UTC