OK (you asked for it), basically I have some xml that needs to be massaged
first by a simple xslt before being fed into my transformer, and then once my
transformer is done, I need to result to be massaged again with another xslt.
My transformer relies on some predefined and specific transformer libraries
that I have no control over, so the xml has to be massaged to fit into the
format required by these libraries. If I can just build a string with the
incoming xml (from the first xslt), I can then feed this string of xml into the
custom transform libraries (as long as the xml contained in the string is
structured correctly). So basically, here is what I need my custom tranformer
to do:
1. Accept SAX events and build a string of the incoming xml
2. Perform transform on the received xml string
3. Output the resulting xml in the form of more Sax events for the next
tranformer/serializer in line. i.e. something like this:
String message = doMyCustomTransform(incomingXMLString);
//Create a reader for turning a string into an InputSource
XMLReader xmlreader = XMLReaderFactory.createXMLReader();
//Set the content handler into the XMLReader class.
xmlreader.setContentHandler(contentHandler);
//Now feed the source into the xml reader, which will turn around and
//invoke the proper handlers in the contentHandler based on the
//string.
InputSource source = new InputSource(new StringReader(message));
xmlreader.parse(source);
I've pretty much got steps 2 and 3 worked out. I just need the step 1 part.
Need anymore details?
Thanks,
Jeff
-----Original Message-----
From: Grzegorz Kossakowski [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 01, 2007 8:29 AM
To: [email protected]
Subject: Re: Custom Transformer
Schmitz, Jeffrey A napisaĆ(a):
> Is there a simple implementation of a Custom Transformer using
> AbstractSAXTransformer anywhere? Would love to see just a Hello World
> program, but can't seem to find one.
>
The most simple transformer I can think of is StripNamespacesTransformer[1].
It would be much better if you could come up with some details of your own
transformer you want to write so we could give you some clues.
[1]
https://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/StripNameSpacesTransformer.java?view=markup
--
Grzegorz Kossakowski
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]