You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Boris Garbuzov <bo...@borealissoft.com> on 2001/05/10 18:12:45 UTC

Re: XML Output Format (Instead of using XMLSerializer, use identitytransformer)

Thanks. I alsy like to use the most universal code. But transformer fails for
streaming out in my case. It hangs like in an infinite loop and goes out of
memory. I reported this error previously.

-------------

Shane_Curcuru@lotus.com wrote:

> Note: XMLSerializer is usually not what you want to use, unless you really
> know you want to use it.  We need better doc on identity transformers,
> which let you transform any type of source into any type of result -
> basically changing the data format (DOM tree, SAX events, Stream) into
> another type, but without changing the content.
>
> See http://xml.apache.org/xalan-j/usagepatterns.html#serialize  Or, Edwin
> Goei wrote nicely:
> "Until DOM Level 3 comes out, the most portable
> way to do this is to use the javax.xml.transform package.  You create an
> identity transformer and then transform a DOMSource into a StreamResult
> object.  This should probably be added to a FAQ, probably at least the
> Xalan FAQ.  The best pointer I could find was
> http://xml.apache.org/xalan-j/usagepatterns.html#dom.  It needs to be
> modified to use a StreamResult object.
>
> -Edwin"
>
> - Shane
> ---- you "Daniel Pfuhl" <da...@web.de> wrote ----
> For a while I'm trying to read an xml-file
> into dom - transforming it using xalan and
> modifying it also. after that i want to
> write the "new" dom to a file. All works
> fine but of formatting the output. There
> are no linebreaks after each tag and some-
> times tags are "broken". What am I done
> wrong??
>
> ****************************************
>
> try {
>      FileWriter out = new FileWriter("c:/test.xml");
>
>           OutputFormat formatt = new OutputFormat(doc);
>           formatt.setIndenting(true);
>           formatt.setIndent(6);
>           XMLSerializer serializer = new XMLSerializer(out, formatt);
>
>      try {
>           serializer.serialize(doc.getDocumentElement());
>           }
>           catch (IOException ex) {
>                               ex.printStackTrace();
>                          }
>      out.toString();
>      out.close();
> etc.