Yes, you can do an identity transform and have the transformer serialize
the result as XML.  You can also do it without doing a transformation.
There is some code in the testXSLT executable which does exactly this.
Take a look at process.cpp in TestXSLT.   Here's a code snippet to give you
an idea of what's involved:

   void
   serializeDocument(
            XalanDocument*    theDocument,
            std::ostream&     theStream)
   {
      XalanStdOutputStream          theStream(theStream);
      XalanOutputStreamPrintWriter  thePrintWriter(theStream);

      FormatterToXML          theFormatter(thePrintWriter);
      FormatterTreeWalker     theWalker(theFormatter);

      theWalker.traverse(theDocument);
   }

You should also ask on the Xerces list, since this is really a DOM
question.

Dave



                                                                                
                              
                      "Troels Rossing"                                          
                              
                      <[EMAIL PROTECTED]         To:      "Xalan user maillist" 
<[email protected]>  
                      e.com>                   cc:                              
                              
                                               Subject: How to create an 
xml-file                             
                      12/06/2001 03:31                                          
                              
                      AM                                                        
                              
                                                                                
                              
                                                                                
                              




Hi

I have been looking for an easy way to generate an xml file from a DOM tree
in memory. Can it be that there are no easy way to write a DOMDocument to a
file??
I have looked in the documentation for both Xerces and Xalan. The only way
to do it seems to be by doing a transformation with the XalanTransformer.
Has to be an easier way.....

Hope someone can help me :-)

regards

Troels Rossing
QualiWare
Phone +45 45 47 07 46




Reply via email to