[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xalan-j-users
Subject:    RE: Serialize xml
From:       "Flurchick, Kenneth M" <FLURCHICKK () MAIL ! ECU ! EDU>
Date:       2002-11-24 20:55:26
[Download RAW message or body]

  GentleBeings
As Simon pointed out, I should have included the code I use here it is
This code will write the document to a file but there are no indentations
(despite asking for them)
I have tried several different approaches and do not think I should have 
to use a translator I just want to serialize the file correctly
kf



      // A serialize approach
      // Instantiate a Xalan XML serializer and use it to serialize
      // the output DOM to System.out using a default output format.
      Serializer serializer = SerializerFactory.getSerializer
               (OutputProperties.getDefaultMethodProperties("xml"));
      org.apache.xalan.serialize.SerializerToXML serial = new
        org.apache.xalan.serialize.SerializerToXML();
      Properties props = new Properties();
      props.setProperty(javax.xml.transform.OutputKeys.METHOD, "xml");
      props.setProperty(javax.xml.transform.OutputKeys.ENCODING,
"ISO-8859-1");
      props.setProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
      props.setProperty(javax.xml.transform.OutputKeys.STANDALONE, "no");
      props.list(System.out);
      // java.io.Writer xout = new
      //    org.apache.xalan.serialize.SerializerToXML().getWriter();
      // serial.init(xout, props);
      serial.setOutputStream(new FileOutputStream(ruFile));
      serial.startPreserving();
      serial.setOutputFormat(props);
      //  serial.indent(4);
      serial.asDOMSerializer();
      serial.serialize(doc);


-----Original Message-----
From: Simon Kitching
To: Flurchick, Kenneth M
Cc: 'xalan-j-users@xml.apache.org'
Sent: 11/23/02 9:33 PM
Subject: Re: Serialize xml

Hi Kenneth,

If you are using org.apache.xml.serialize.XMLSerializer, then try
setting the OutputFormat object's "preserve-space" attribute to false.

If you are using XSLT serialization, try adding the tag
<xsl:strip-space elements="*"> as a direct child of the <xsl:stylesheet>
tag.

If this doesn't solve the problem, I suggest you include a little more
information about your configuration and the results you are getting.
Your rather minimal original email makes it a bit difficult to offer
good suggestions :-)

Hope this helps,

Simon

On Sun, 2002-11-24 at 02:32, Flurchick, Kenneth M wrote:
> GentleBeings
> I have a simple (I think) issue
> I am trying to write out an xml file I created
> made the nodes and set up a writer
> the xml file has no indentations though I specifically turned it on
> Got a snippet to do this correctly
> DO I need a transfomer to do this?
> kf

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic