cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <andr...@apache.org>
Subject Re: IncludeXMLConsumer with RedundantNamespacesFilter does not output comments
Date Wed, 04 Mar 2009 16:52:22 GMT
Thorsten Scherler schrieb:
> On Fri, 2009-02-27 at 14:26 +0100, Andreas Hartmann wrote:
>> StringXMLizable.toSAX() sets only the content handler of the SAX
>> parser. 
>>
>> Maybe it makes sense to set the lexical handler, if possible?
>>
>>      public void toSAX(ContentHandler contentHandler) throws
>> SAXException {
>>          final SAXParser parser = getContext().parser;
>>          parser.getXMLReader().setContentHandler(contentHandler);
>>
>> +       if (contentHandler instanceof LexicalHandler) {
>> +           parser.getXMLReader().setProperty(
>> +             "http://xml.org/sax/properties/lexical-handler",
>> +             (LexicalHandler) contentHandler);
>> +       }
>>
>>          InputSource is = new InputSource(new StringReader(data));
>>          try {
>>              parser.getXMLReader().parse(is);
>>          } catch (IOException e) {
>>              throw new SAXException(e);
>>          }
>>      }
> 
> I agree that this change is the elegant solution for the problem. Can
> you apply it, if nobody objects. 

Up to now, nobody has objected – but I have to admit I don't like the 
automagic approach that much. Maybe we'd rather add a method like

   StringXMLizable.toSAX(XMLConsumer consumer)

to make it more obvious that the LexicalHandler events are emitted?

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Mime
View raw message