Comments get clobbered in transformation

Collin VanDyck

Usenet Archive
Joined
May 5, 2003
Messages
134
Reaction score
0
I'm a semi-newbie to XSL transformations, so hopefully you guys can tell me what I'm doing wrong here. I have a string that is an XML document that I am running through a Xalan transformer:

public String transform (String pageXML) throws SAXException , IOException { XMLReader reader = XMLReaderFactory.createXMLReader;

ByteArrayOutputStream outputStream = new ByteArrayOutputStream; Properties p = OutputProperties.getDefaultMethodProperties("xml"); Serializer serializer = SerializerFactory.getSerializer(p); serializer.setOutputStream(outputStream);

this.setParent(reader);
this.setContentHandler(serializer.asContentHandler);

InputSource input = new InputSource(new StringReader(new String(pageXML))); this.parse(input);

String toReturn = outputStream.toString;
return toReturn;

Note: 'this' is a subclass of XMLFilterImpl. In the source XML, I have a
SSI like this:

<!--#include /path/file.asp-->

This is getting erased somehow in the transformation. I suspect that it has something to do with the Properties object I am using to create my Serializer. Is there some property I need to set to allow comments? Also, I could not find a reference in my Googling for a list of the possible output properties. I think I'm missing something pretty simple here.

I tested this with an empty class of XMLFilterImpl, with the same results, so I know it is not my SAX event overrides causing this problem.

Thanks in advance!
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% I'm a semi-newbie to XSL transformations, so hopefully you guys can tell me % what I'm doing wrong here.

It's difficult to tell what you're doing wrong if you don't post the actual transformation. The most likely thing is that you aren't copying the comment (which you're using as if it were a processing instruction) (a pet peeve of mine) to the result tree.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top