DOM Document to SAX Filter Chain

DOM Document to SAX Filter Chain

Post by Barney Barum » Fri, 25 Apr 2003 13:20:25



Hi. I am trying process a DOM document with a chain of XSLT filters,
as per the Sun tutorial at:

http://java.sun.com/webservices/docs/ea2/tutorial/doc/JAXPXSLT6.html

All very well, but I can't see how to create an
org.xml.sax.InputSource from an org.w3c.dom.Document. Well, I can see
quite a few ways of doing it, but they are all ugly as hell and I'm
sure there must be a simple elegant solution out there that I'm just
missing.

Any ideas? TIA.

 
 
 

1. problems chaining sun multi schema validator filter to transform filter

Hello

I have been playing with the Sun MultiSchema Validator a bit, and I
must say, I like it. I had been thinking about cobbling together
something similar for a project I am working on, but this thing is
better.

Anyway - I am having what I am sure is a simple problem, but I have
not been able to figure it out.

Basically, I have an xml document that I am transforming to a new
document that validates against an XML Schema. This document and its
corresponding xsl is part of a production system that works fine (and
uses Xerces and Xalan). I can transform using something like

              TransformerFactory tFactory = TransformerFactory.newInstance();
                    SAXTransformerFactory saxTFactory = ((SAXTransformerFactory)
tFactory);

            javax.xml.transform.TransformerFactory tfactory =
javax.xml.transform.TransformerFactory.newInstance ();
            xmlFilter = saxTFactory.newXMLFilter(source);

        i create a verifier filter as in

        VerifierFactory factory = new
com.sun.msv.verifier.jarv.TheFactoryImpl ();
        final org.iso_relax.verifier.Verifier verifier = factory.newVerifier
(schemaFile);
        filter = verifier.getVerifierFilter ();

just basic stuff here.

If i do my transform, and serialize it, the transform works perfectly.

If i load the transformed document using an xmlreader, and validate
that using the verifier filter, that works perfectly too. I can
introduce errors and they are reported perfectly. If i chain the
verifier to the transformer, however, I get this error:

com.sun.msv.verifier.ValidityViolation: unexpected attribute
"xmlns:xsi"

if the output from the transformer gets serialized and re-read, then
the error goes away. I even wrote a dumb little filter that serializes
to a string and back, and stuck that inline, and the problem goes
away.

Im thinking that there is some issue with encoding, or output format,
or somethng somewhere.

The stylesheet's encoding is set to UTF-8 and its output type is XML.
namespaces are all correctly defined.

any help would be appreciated.

Thanks.

Chris

2. Very faint screen - original PalmPilot

3. JAXP and filter chains.

4. BA: Newsday writer seeks information

5. XSL SAX chaining and Validation (JAVA)

6. What's your smb name?!

7. SAX vs DOM for small documents

8. Hard drive Alimentation wanted

9. SAX XPath Filter

10. SAX Filter in C++

11. SAX Filtering with IVBSAXFilter interace

12. VB, SAX and Filtering

13. Get XPath given DOM element, get DOM element given document & XPath