Schema Aware processing using an empty TransformerHandler

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Schema Aware processing using an empty TransformerHandler

Andrew Welch
Mike,

In the past I've used an empty TransformerHandler to write out java
objects to an XML file by supplying it with SAX events and a Result.
This works nicely with Saxon because I believe it's optimised to not
build a source tree.

Is it possible with SaxonSA to supply the empty TransformerHandler
with a result Schema to validate what's being written out at that
point?

Currently we are using STAX to write out the XML, and then reparsing
it for validation.  It would be good to be able to do it all in a
single step.

thanks
andrew


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
<a href="http://ads.osdn.com/?ad_idv28&alloc_id845&op=click">http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Schema Aware processing using an empty TransformerHandler

Michael Kay
I think this should work.

1. Make sure that you instantiate a SchemaAwareTransformerFactory

2. Call factory.addSchema() method to supply the schema

3. Call factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION,
Validation.STRICT) to switch validation on

4. Get the TransformerHandler and use it as before.

(This is actually validating data on the way in to the identity transformer,
not on the way out, but the effect is the same, of course).

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> andrew welch
> Sent: 15 November 2005 14:03
> To: [hidden email]
> Subject: [saxon] Schema Aware processing using an empty
> TransformerHandler
>
> Mike,
>
> In the past I've used an empty TransformerHandler to write out java
> objects to an XML file by supplying it with SAX events and a Result.
> This works nicely with Saxon because I believe it's optimised to not
> build a source tree.
>
> Is it possible with SaxonSA to supply the empty TransformerHandler
> with a result Schema to validate what's being written out at that
> point?
>
> Currently we are using STAX to write out the XML, and then reparsing
> it for validation.  It would be good to be able to do it all in a
> single step.
>
> thanks
> andrew
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
> Register for a JBoss Training Course.  Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> <a href="http://ads.osdn.com/?ad_idv28&alloc_id845&op=ick">http://ads.osdn.com/?ad_idv28&alloc_id845&op=ick
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
<a href="http://ads.osdn.com/?ad_idv28&alloc_id845&op=click">http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Schema Aware processing using an empty TransformerHandler

Andrew Welch
> I think this should work.
>
> 1. Make sure that you instantiate a SchemaAwareTransformerFactory
>
> 2. Call factory.addSchema() method to supply the schema
>
> 3. Call factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION,
> Validation.STRICT) to switch validation on
>
> 4. Get the TransformerHandler and use it as before.
>
> (This is actually validating data on the way in to the identity transformer,
> not on the way out, but the effect is the same, of course).

Excellent - just in the process of getting a license (sadly not as
simple as using the bosses credit card any more)


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
<a href="http://ads.osdn.com/?ad_idv28&alloc_id845&op=click">http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help