xsl-list
[Top] [All Lists]

Re: [xsl] Using a TransformerHandler strips comments but a Transformer keeps them

2008-02-13 04:23:31
On 13/02/2008, David McKain <dmckain(_at_)ph(_dot_)ed(_dot_)ac(_dot_)uk> wrote:
Andrew Welch wrote:

Does anyone know why a transform using a TransformerHandler strips
comments but the "stardard" Tranformer keeps them.

[snipped]
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.parse(sourceXML.toURI().toString());

Hi Andrew,

You need to tell your XMLReader to forward lexical events (e.g.
comments) to the TransformerHandler as well. In what you have above, you
have only asked it to forward basic ContentHandler-type SAX events onwards.

Add the following after your setContentHandler() line:

xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler";,
                         hander);

and you should find your comments reappearing.

Ahh great thanks - I did scan the features and properties lists but
lexical-handler didn't jump out at me...

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--