tags:

views:

51

answers:

1

I know how to call a java Transform and have it validate the output against a schema. What I want to do is:

Validate the input and Transform it via xsl.

I could:

  1. Create a Validator
  2. Validate and have it output a DOMResponse
  3. Pass the DOM to a Transformer.

What I really want to do is have this done in one step and not have to create a DOM model; have it all work via SAX.

-Dave

A: 

I assume you mean DOMResult instead of DOMResponse.

Validator.validate() returns void, so your approach is not feasible. If you want to hold the entire DOM in memory you could parse the XML, then create a DOMSource to pass to the validator and Transformer. If you can't hold the entire DOM in memory you will have to stream the document twice, once to the validator and once to the Transformer. If the ouput is from a non-rewindable source (i.e. a document streamed in from a web client) you will have to store a local copy on disk so you can process it twice.

Jim Garrison
Thanks, and yes, I did mean DOMResult. For now, I am using the first method of holding the DOM in memory. I'm going to keep looking, though, because it seems like Java should be able to do this.
Dave