This relates to schema-aware validation of inputs into an XSLT transformation using latest Saxon EE 9.8.
My XSLT file contains the following.
A namespace and associated schema defined as such:
<xsl:import-schema namespace="http://www.fpml.org/2005/FpML-4-2" schema-location="/path/to/some_swbml.xsd"/>
A result document conforming to the above schema:
<xsl:result-document method="xml" href="{$file}" format="swbml-format" validation="strict">
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" xsl:use-attribute-sets="ir">
GENERATE SOME MORE XML TO BE VALIDATED BY THE XSD
</SWBML>
</xsl:result-document>
You will note that the parent tag in the result document <SWBML>
uses an attrribute set xsl:use-attribute-sets="ir"
.
The attribute set is defined as per below:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:attribute-set name="ir">
<xsl:attribute name="version">4-2</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
This is a toy-example, the boilerplate isn't justified above!
This works fine when I use it with:
java net.sf.saxon.Transform -sa -ext:on -it -o:output.xml -xsl:example.xslt
This is expected because "-sa" will only check the outputed XML document, as I understand it.
This doesn't work:
java net.sf.saxon.Transform -val:lax -ext:on -it -o:output.xml -xsl:example.xslt
Giving:
FORG0001: Attribute @xsl:use-attribute-sets is not allowed on element <SWBML>
My question is - shouldn't the validator process the attribute sets before trying validate the <SWBML>
? It looks to me like it's complaining that an XSLT instruction is not permitted in the output XML document, which is of course true, but it seems to be checking prematurely.
The resulting XML is valid:
<SWBML xmlns="http://www.fpml.org/2005/FpML-4-2" version="4_2">
As demonstrated by transforming with the "-sa" option.
I'm not sure if this is a limitation of XSLT, or a bug in Saxon processing? It feels like I should be able to do this to me!
Any ideas?