Page 1 of 1
Validating XML files during a transformation
Posted: Wed May 14, 2008 10:36 pm
by mlcook
Is it possible to validate XML files during an XSL transformation before actually performing the transformations?
That is, I'd like to make sure the input XML file is valid before trying to process it.
I would know which schema to use.
Although the XML files should have been validated before the transformation, I can't guarantee it, so I'd like to make a check to verify them.
Is this possible with XSL?
If so, how?
Thanks, Mike
Re: Validating XML files during a transformation
Posted: Thu May 15, 2008 11:15 am
by sorin_ristache
Hello,
For DTD based validation of the XML input of the transformation use Saxon 9 to apply the transformation and enable the option DTD based validation of the source file in Options -> Preferences -> XML -> XSLT/FO/XQuery -> XSLT -> Saxon -> Saxon 9. For XML Schema based validation you need the schema-aware version of Saxon 9, that is Saxon 9 SA and you need to enable the option Schema based validation of the source file available in the same Preferences panel.
Regards,
Sorin
Re: Validating XML files during a transformation
Posted: Thu May 15, 2008 4:25 pm
by mlcook
I was thinking of XML schema aware validation during XSLT transformations. Since we don't have Saxon 9SA, that option is out for the moment.
I had seen this web page:
http://www.ibm.com/developerworks/xml/l ... axslt.html
which uses
<xsl:import-schema schema-location="po1.xsd"/>
and then
<xsl:template match="document-node(schema-element(PurchaseOrder>
But their example set an option on the java command line in order to invoke the validation process.
After your comments, and more careful reading of the above web page, I notice that they're using Saxon 9SA also.
So, it appears that we can't do that now, but could do it if we were to obtain Saxon 9SA.
Thanks for your reply.
-- Mike
Re: Validating XML files during a transformation
Posted: Thu May 15, 2008 4:41 pm
by sorin_ristache
mlcook wrote:I had seen this web page:
http://www.ibm.com/developerworks/xml/l ... axslt.html
which uses
<xsl:import-schema schema-location="po1.xsd"/>
and then
<xsl:template match="document-node(schema-element(PurchaseOrder>
But their example set an option on the java command line in order to invoke the validation process.
After your comments, and more careful reading of the above web page, I notice that they're using Saxon 9SA also.
Yes, you need a schema aware XSLT 2.0 processor for using xsl:import-schema, document-node(), schema-element(), etc.
Regards,
Sorin