Superseded by XSLT 2.0 RELAX NG Grammar, 12 Jul 2006.  Supersedes XSLT 2.0 RELAX NG Grammar, 07 Apr 2005.

XSLT 2.0 RELAX NG Grammar

Volume 8, Issue 60; 19 Apr 2005; last modified 08 Oct 2010

A few more bug fixes for my XSLT 2.0 RELAX NG Grammar. This version validates stylesheets conforming to the 4 Apr 2005 draft of XSLT 2.0.

After fixing a few bugs, I found a few more. Last night, when I discovered that use-when wasn't supported, I decided that what was really needed was a thorough check against the most recent specification. That resulted in the following changes:

  • Allow xsl:version on literal result elements (LREs) to have any value (not just “2.0”).

  • Allow xsl:xpath-default-namespace, xsl:default-collation, xsl:type, xsl:validation, and xsl:use-when to appear on LREs.

  • Allow version, exclude-result-prefixes, extension-element-prefixes, xpath-default-namespace, default-collation, and use-when to appear on all XSL elements.

  • Allow xs:schema to appear inside xsl:schema-import.

  • Only allow mode on xsl:template elements with a match.

  • Allow content or select on xsl:processing-instruction, not both. Ditto for xsl:comment.

  • Improve co-constraints on attributes on xsl:number and xsl:for-each-group.

  • Allow xsl:sort to contain content.

  • On xsl:output, it's escape-uri-attributes (with an “s”) and normalize-unicode is not a simple boolean.

  • The name attribute is required on xsl:namespace.

  • All of the xsl:output attributes are allowed on xsl:result-document, where they are AVTs.

  • The xsl:sequence element only contains xsl:fallback.

  • Added xsl:document.

I also renamed and reordered some of the patterns and used the AVT pattern in a bunch of attributes where it had been overlooked.

The new xslt20.rnc is available. It still works with the (unmodified) xslt10.rnc and xslt.rnc grammars.

Please report any bugs that you find. Share and enjoy!

Comments

This cleans up the only issue I see on the stylesheets I've loaded thus far. Finding this page this morning really made my day. Thanks!
      
--- xslt20.rnc.orig     2005-05-20 08:14:57.000000000 -0400
+++ xslt20.rnc  2005-05-20 08:15:02.000000000 -0400
@@ -180,11 +180,11 @@
 apply-templates.element =
    element apply-templates {
       extension.atts,
       global.atts,
       attribute select { expression.datatype }?,
-      attribute mode { "#all" | "#default" | qname.datatype }?,
+      attribute mode { "#current" | "#default" | qname.datatype }?,
       (sort.element | with-param.element)*
    }
 
 attribute.element =
    element attribute {

    
—Posted by Ben Rogers on 20 May 2005 @ 12:23 UTC #

Thanks for this schema. It saves me a lot of typing when used in conjunction with nXML ;-)

--drkm

—Posted by Florent Georges on 16 Jan 2006 @ 11:31 UTC #

Norm,

xsl:namespace's name attribute is a possibly empty AVT but typed as attribute name { xsd:NCName }, I think it should be avt.datatype

the mode attribute can take a white space separated list of modes but is typed as attribute mode { "#all" | "#default" | qname.datatype }? I think the last clause should be qnames__s__.datatype

David

—Posted by David Carlisle on 26 Jun 2006 @ 10:57 UTC #
My suggested change was not enough, does not validate
<xsl:template mode="#default a" match="/">
I now suggest
mode.datatype = list { "#all" | (xsd:NCName | "#default")+ }
(which is same as exclude.prefixes.datatype except with a + not a *) together with
template.element =
   element template {
      extension.atts,
      global.atts,
      (attribute match { pattern.datatype }
       & attribute mode { mode.datatype}?)?,
      attribute name { qname.datatype }?,
      attribute priority { number.datatype }?,
      attribute as { sequence.datatype }?,
      (param.element*, sequence.constructor)
   }
—Posted by David Carlisle on 10 Jul 2006 @ 11:10 UTC #
I now suggest
mode.datatype = list { "#all" | (xsd:NCName | "#default")+ }
(which is same as exclude.prefixes.datatype except with a + not a *)

of course the trouble with cutting and pasting things is that you tend to cut the wrong thing. (It would be so much better if i could kill and yank instead:-)

unlike exclude.prefixes.datatype modes can be QNames not just NCNames so xsd:NCName above needs to be xsd:QName or equivalently qname.datatype

PS any chance that you could see comments when writing a comment: it would make it a bit easier when replying to comments

—Posted by David Carlisle on 11 Jul 2006 @ 09:31 UTC #

David: yes, essay comments are now displayed on the essay that you're commenting on.

—Posted by Norman Walsh on 12 Jul 2006 @ 01:08 UTC #