Alexander,

whilst I don not have a ready solution for your problem, it might be worthwhile to note that I was suffering from a very
similar problem a while ago when trying to get the CastorTransformer working in Cocoon 2.1.x. The problem then
seemed to be that Castor in principle supports your needs, but would force integration of these components at the
SAX1 level.

As Cocoon internally uses SAX 2 event pipelines, I had a quick look at the implementation of this component
(CastorTransformer), and it kind of confirmed my statement above. You just cannot use the SAX2 ContentHandler
interface, as this interface didn't exist with SAX1. Just have a look at the SAX1 documentation, and you should be
able to figure out things quite easily.

Having said that, I might be completely wrong with my statement as Castor XML might have changed in the
meantime.

Werner


On Mon, 24 Nov 2003 11:53:15 +0100, Alexander Zug wrote:

>Hi
>
>has anyone experience with marshalling to a ContentHandler
>and further (SAX) processing?
>
>I would like to process a marshalled Castor object (via a
>DefaultHandler) into a DOM Level 2 object . Is this
>procedure generally possible?
>
>I tried s.th. like the following but I got an Error:
>javax.xml.transform.TransformerConfigurationException:
>javax.xml.transform.TransformerConfigurationException:
>javax.xml.transform.TransformerException: java.lang.NullPointerException
>at: row 10 Transformer transformer =
>TransformerFactory.newInstance().newTransformer((Source)saxSource);
>
>Can anyone give me just one tip?
>
>1 DefaultHandler dHandler = new DefaultHandler();
>2 po.marshal((ContentHandler)dHandler);
>3 ParserAdapter pAdapter = new ParserAdapter();
>4 pAdapter.setContentHandler((ContentHandler)dHandler);
>5 SAXSource saxSource = new SAXSource();
>6 saxSource.setXMLReader((XMLReader)pAdapter);
>7 Document document =
>DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
>8 DOMResult domResult = new DOMResult();
>9 // org.apache.xalan.transformer.TransformerImpl.
>10 Transformer transformer =
>TransformerFactory.newInstance().newTransformer((Source)saxSource);
>11 transformer.transform(saxSource, domResult);
>12 System.out.println("domResult.getNode()="+domResult.getNode());
>
>
> Thanks a lot!
>Alex.
>
>-----------------------------------------------------------
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>




Reply via email to