[jdom-interest] How to create JDOM from SAX events
Michael Lipp
michael.lipp at danet.de
Thu Feb 19 00:19:33 PST 2004
Jason Hunter wrote:
> Michael Lipp wrote:
>
>> Chris B. wrote:
>>
>>>
>>> You simply create a SAXHandler and use that as a content handler.
>>> Once it is all streamed through you can do a getDocument on the
>>> handler to retrieve the jdom tree.
>>
>>
>>
>> Thank you, I found that "shortcut" when I tried to derive my own
>> SAXBuilder and found that I was actually doing just this. Maybe the
>> documentation should be changed. Currently, SAXHandler is described as
>> "A support class for SAXBuilder". But obviously it has a life of its own.
>>
>> - Michael
>
>
> Michael, could you send in a patch with some text that would have helped
> you?
>
> -jh-
This is not patch format, but I doubt patch format would make
integrating easier. Here you are:
/**
* Builds a JDOM document from SAX events. Used by {@link SAXBuilder
* <code>SAXBuilder</code>} to process the SAX events from the parser.
*/
public class SAXHandler ...
I haven't read the source so I'm not sure if this is true BUT: If this
was my project, I would move the notes on the behaviour of SAXBuilder
("Details which SAX does not provide, such as whitespace outside the
root element, are not represented in the JDOM document." and "Known
issues: Relative paths for a DocType or EntityRef may be converted by
the SAX parser into absolute paths.") to SAXHandler, as I suppose that
they are really issues of SAXHandler. I'd then add a note to SAXBuilder:
*
* See {@link SAXHandler <code>SAXHandler</code>} for restrictions
* and known issues.
*
Regards,
Michael
>
>>
>>
>>>
>>> Michael Lipp wrote:
>>>
>>>> Hi,
>>>>
>>>> I have a SAX event stream and want to convert this to JDOM. The
>>>> SAXBuilder seems to accept anything except (interestingly) SAXEvents.
>>>>
>>>> How should I solve the problem? I see a way to derive a new class
>>>> from SAXBuilder that creates the ContentHandler and returns it so
>>>> that I can send my SAX events to it. But there must be a simpler way
>>>> than deriving a new class, mustn't it?
>>>>
>>>> Or I can create a TransformerHandler (JAXP) with SAX as source and a
>>>> JDOMResult. It is just that I am always a bit hesitant to use an
>>>> "identity transformer" as I am never sure about the performance...
>>>>
>>>> Regards,
>>>>
>>>> Michael
>>>>
>>
>> _______________________________________________
>> To control your jdom-interest membership:
>> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>>
>>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list