XML Declaration not serialized

Discussion in 'XML' started by Guillaume Jeudy, Dec 8, 2003.

  1. Hi,

    I'm trying to serialize a DOM using the xalan package. I have a
    problem with the XML declaration not getting printed. Here's a snippet
    of code showing the initialization of the
    org.apache.xalan.serialize.SerializerToXML:

    Properties outputFormat =
    OutputProperties.getDefaultMethodProperties(Method.XML);
    outputFormat.put(OutputProperties.S_KEY_INDENT_AMOUNT, "3");
    outputFormat.put(OutputKeys.INDENT, "yes");
    outputFormat.put(OutputKeys.OMIT_XML_DECLARATION, "no");
    serializer = new SerializerToXML();
    serializer.setOutputFormat(outputFormat);

    The indent & indent amount properties do work as I see proper
    indentation in the serialization output. However the XML declaration
    does not appear in the serialized output.

    Can someone please help? I can't figure where to output that damn XML
    header.
    Guillaume Jeudy, Dec 8, 2003
    #1
    1. Advertising

  2. Guillaume Jeudy

    True Gamer Guest

    It is not necessary to use the XML declaration in version 1. You
    probably should not use it if it is giving you that kind of problem.
    --------------------------------------------------------------------------
    Guillaume Jeudy wrote:

    > Hi,
    >
    > I'm trying to serialize a DOM using the xalan package. I have a
    > problem with the XML declaration not getting printed. Here's a snippet
    > of code showing the initialization of the
    > org.apache.xalan.serialize.SerializerToXML:
    >
    > Properties outputFormat =
    > OutputProperties.getDefaultMethodProperties(Method.XML);
    > outputFormat.put(OutputProperties.S_KEY_INDENT_AMOUNT, "3");
    > outputFormat.put(OutputKeys.INDENT, "yes");
    > outputFormat.put(OutputKeys.OMIT_XML_DECLARATION, "no");
    > serializer = new SerializerToXML();
    > serializer.setOutputFormat(outputFormat);
    >
    > The indent & indent amount properties do work as I see proper
    > indentation in the serialization output. However the XML declaration
    > does not appear in the serialized output.
    >
    > Can someone please help? I can't figure where to output that damn XML
    > header.
    True Gamer, Dec 8, 2003
    #2
    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.

Share This Page