K. Ari Krupnikov wrote:Is there a Batik equivalent of javax.xml.transform.sax.TransformerHandler, a class that can accept SAX events and transcode them into an image?
Thomas DeWeese wrote:No, but there isn't much point. Just build a Batik DOM[...].
K. Ari Krupnikov wrote:
Oh I understand that. I'm not trying to avoid building a Batik DOM, I'm trying to avoid writing code to do it :=) Let me restate my question. Is there a class that can accept SAX events and create a Batik DOM based on them?
You will need to do some work but batik.dom.svg.SAXSVGDocumentFactory acts as a content handler and builds an SVGDocument. It's constructors don't let you do quite what you want but if you subclass I think you could make it work.
I can write my own ContentHandler that will instantiate an SVGDOMImplementation, buffer all events until the root element, then call createDocument and then create appropriate nodes on it based on the SAX events and then in the endDocument() I know that I have a complete DOM.
It's just that the code that does all this already exists somewhere in Batik, and I thought it was rather a waste to reproduce it.
TranscoderInput(XMLReader) doesn't do what I'm looking for -- it takes a reader and calls parse() on it. What I have is a class (not an XMLReader) that reports SAX events that correspond to an SVG document, but there is no way to control when it starts reporting them; there is no parse() method to call. The class I have is similar to javax.xml.transform.sax.SAXResult: you can set a content handler, but you don't control the parsing.
In JAXP, the solution to this is TransformerHandler which implements ContentHandler, instead of taking an XMLReader in the constructor. I can't find a similar mechanism in the Batik JavaDocs. Have I overlooked something? Is there another way to do what I need?
Ari.
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- 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]