Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Help with SAXSource and javax.xml.transform.Transformer

Reply
Thread Tools

Help with SAXSource and javax.xml.transform.Transformer

 
 
Andreas
Guest
Posts: n/a
 
      09-02-2005
Hi!

I fail to catch events when transforming xml.
I have some code that successfully transforms an xml

... code ...
// Setup XSL transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslStreamSource);

// Setup XML result
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
StreamResult transformResult = new StreamResult(bos);

// Do the transform
StreamSource ss = new StreamSource(source);
transformer.transform(ss, transformResult);
... end code ...

Now I need this code to perform some "side effects" when parsing the
original xml. I know it is possible to catch events in a ContentHandler
when parsing xml with XMLReader. I tried this with the following code.

... code ...
// Perform Sideeffects
InputSource is = new InputSource(source);
MyContentHandler mch = new MyContentHandler();
XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(sch);
reader.parse(is);
... end code ...

Ok, so know I know that XMLReader.parse will fire events. Why can't I
use this reader with a SAXSource to catch these events when doing the
transform?

Something like:

... code ...
SAXSource ss = new SAXSource(reader, is);
transformer.transform(ss, transformResult);
... end code ...

Unfortunately this code doesn't produce any events

Any solution for this problem?

/Andreas

 
Reply With Quote
 
 
 
 
Raymond DeCampo
Guest
Posts: n/a
 
      09-04-2005
Andreas wrote:
>
> Something like:
>
> ... code ...
> SAXSource ss = new SAXSource(reader, is);
> transformer.transform(ss, transformResult);
> ... end code ...
>
> Unfortunately this code doesn't produce any events
>
> Any solution for this problem?
>


Perhaps if you posted a short, self-contained code example (SSCCE) it
would be easier to help you.

Ray

--
XML is the programmer's duct tape.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments