cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: IncludeXMLConsumer with RedundantNamespacesFilter does not output comments
Date Thu, 05 Mar 2009 14:01:55 GMT
On Wed, 2009-03-04 at 17:52 +0100, Andreas Hartmann wrote:
> 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?

Personally I like the automatic one, since if I pass an instanceof
LexicalHandler then I expect that the events are invoked. 

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





Mime
View raw message