Comments get clobbered in transformation

Discussion in 'XML' started by Collin VanDyck, Oct 15, 2003.

  1. 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!
    Collin VanDyck, Oct 15, 2003
    #1
    1. Advertising

  2. In article <>,
    Collin VanDyck <> wrote:

    % 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.

    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, Oct 15, 2003
    #2
    1. Advertising

  3. I found that by creating a class that implements LexicalHandler, and setting
    the XML Reader as such:

    reader.setProperty("http://xml.org/sax/properties/lexical-handler",new
    LexicalHandlerImpl());

    I actually get the comments! However, I am still stuck on how to get them
    back into the result tree. Ideas?

    TIA
    Collin


    "Patrick TJ McPhee" <> wrote in message
    news:bmjo5a$l7e$...
    > In article <>,
    > Collin VanDyck <> wrote:
    >
    > % 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.
    >
    > --
    >
    > Patrick TJ McPhee
    > East York Canada
    >
    Collin VanDyck, Oct 15, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SteveLB
    Replies:
    0
    Views:
    321
    SteveLB
    Aug 8, 2003
  2. Collin VanDyck

    Comments get clobbered in transformation

    Collin VanDyck, Oct 15, 2003, in forum: Java
    Replies:
    1
    Views:
    331
    Patrick TJ McPhee
    Oct 15, 2003
  3. ChollaPete
    Replies:
    1
    Views:
    290
    ChollaPete
    Jun 28, 2009
  4. Trans
    Replies:
    11
    Views:
    178
    Mariusz Pękala
    Jun 20, 2007
  5. Richard Trahan

    node object gets clobbered after clone

    Richard Trahan, Sep 5, 2004, in forum: Javascript
    Replies:
    1
    Views:
    99
    Lasse Reichstein Nielsen
    Sep 5, 2004
Loading...

Share This Page