Reputation: 1474
what am I missing ? I can't get why my transformation is not schema-aware. Ref:
I know the documents are fine, xsd/xslt/xml files are processed by other systems and it works fine. I was trying to create a desktop command line tool for myself.
source code
def main(args: Array[String])
{
System.setProperty( "javax.xml.transform.TransformerFactory", "com.saxonica.config.EnterpriseTransformerFactory")
val factory = new EnterpriseTransformerFactory()
factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION, new Integer(Validation.STRICT))
val schemaXXX = new StreamSource( new File("PATH/to/xxx.xsd") )
val schemaYYY = new StreamSource( new File("PATH/to/yyy.xsd") )
factory.addSchema(schemaXXX)
factory.addSchema(schemaYYY)
val XSLT = new StreamSource(new File("PATH/to/zzz.xslt"))
val transformer = factory.newTransformer(XSLT)
val input = new StreamSource(new File("PATH/to/file.xml"))
val result = new StringWriter();
transformer.transform(input, new StreamResult(result))
println(result.toString())
}
Result:
The transformation is not schema-aware, so the source document must be untyped
Upvotes: 2
Views: 543
Reputation: 163458
A stylesheet in Saxon-EE is considered schema-aware if it explicitly uses xsl:import-schema, or if the XSLT compiler used to compile it is explicitly set to be schema aware. This is easier done using the s9api interface (XsltCompiler.setSchemaAware(true)), but it can also be done using JAXP by setting the property FeatureKeys.XSLT_SCHEMA_AWARE
("http://saxon.sf.net/feature/xsltSchemaAware") on the TransformerFactory. The reason you have to set this explicitly is that processing untyped documents is faster if the stylesheet knows at compile time that everything will be untyped, so we don't want people to incur extra costs when they move to Saxon-EE if they aren't using this feature.
In future please feel free to raise support questions at saxonica.plan.io where we aim to give a response within 24 hours.
Upvotes: 1