xml-xalan-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David N Bertoni/Cambridge/IBM <david_n_bert...@us.ibm.com>
Subject RE: How to use DocumentBuilder?
Date Tue, 30 Jul 2002 21:50:12 GMT




Hi Kevin,

Please make sure your replies go the list, instead of to my individual
address.

If you want to use the new Xerces DOM then you are out of luck when it
comes to transforming with Xalan.  Xalan supports the old DOM, but not the
new one.  When and if such support will ever be available is up-in-the-air.
It's a lot of work, and I'm too busy to do it right now, and I'm not sure I
even want to do it at all.

If you really must create the source with the new Xerces DOM, then you have
two choices:

   1. Create a DOM instance using the new Xerces DOM, then serialize that
   tree and have Xalan parse it.

   2. Create a DOM instance using the new Xerces DOM, then walk it and send
   SAX2 events to an instance of XalanDocumentBuilder.  You can take a look
   at the following classes for some ideas on how to walk a DOM instance in
   document order and send SAX :

      DOMSupport/TreeWalker.cpp
      XMLSupport/FormatterTreeWalker.cpp

If you decide to go with #2, we could certainly collaborate on writing the
code, and work it back into Xalan.

You could also consider building the tree through SAX2 events.  You would
know better based on your current code how feasible that it.   Of course,
this is only possible if you can build the DOM instance in document order.

Dave



                                                                                         
                                  
                      "Xiao, Ke"                                                         
                                  
                      <kxiao@microstra         To:      "'David N Bertoni/Cambridge/IBM'"
<david_n_bertoni@us.ibm.com>      
                      tegy.com>                cc:                                    
                                     
                                               Subject: RE: How to use DocumentBuilder?  
                                  
                      07/30/2002 02:30                                                   
                                  
                      PM                                                                 
                                  
                                                                                         
                                  
                                                                                         
                                  



Hi Dave,


Thanks a lot for your reply.
I use XercesDOMWrapperParsedSource before, and the transformation time is
too long.
This is the one reason I try to create the Xalan internal source tree from
Xerces DOM tree instead of using that wrapper.


Another reason is now I am using Xerces V2.0, Xalan1.3 does not support the
new DOM , so I have to create the source tree by myself.


Any suggestions for this?


Do we have any plans to integrate with the latest xerces?
Do we have any tips to use Xalan more efficiently?


Thanks again.


Kevin


-----Original Message-----
From: David N Bertoni/Cambridge/IBM [mailto:david_n_bertoni@us.ibm.com]
Sent: Tuesday, July 30, 2002 5:25 PM
To: 'xalan-c-users@xml.apache.org'
Subject: Re: How to use DocumentBuilder?









Yes, XalanDocumentBuilder _only_ supports building a document through SAX2
calls.  That's the only way you can use Xalan's internal source tree
implementation, which is what XalanDocumentBuilder uses for its
implementation.


If you really must use DOM calls, you can use the Xerces DOM interfaces,
then follow this usage pattern to do a transformation:


   http://xml.apache.org/xalan-c/usagepatterns.
   html#xercesdomwrapperparsedsource


However, be prepared for longer transformation times and greater memory
usage.


Dave








                      "Xiao, Ke"


                      <kxiao@microstra         To:      "'xalan-c-
users@xml.apache.org'" <xalan-c-users@xml.apache.org>


                      tegy.com>                cc:      (bcc: David N
Bertoni/Cambridge/IBM)


                                               Subject: How to use
DocumentBuilder?


                      07/30/2002 02:07


                      PM










Hi,all


I want to use DocumentBuilder to create a Xalan Document for transform, but

it always fails.
My code is like:
   XalanTransformer theXalanTransformer;


   // Get a document builder from the transformer...
   XalanDocumentBuilder* const  theBuilder = theXalanTransformer.
createDocumentBuilder();
   XalanDocument *lpDoc = theBuilder->getDocument();


When I try to use lpDoc to create any XalanElement or other nodes, it
always fails.
I debug the code and find that the lpDoc is a XalanSourceTreeDocument
class, all creatXXX methods in that class are not supported and throw an
exception.


There is a DocumentBuilder sample in Xalan, but it use SAX2 ContentHandler
from the DocumentBuilder to create the document.
Does this mean that DocumentBuilder only support SAX2 content handler , but

do not support any DOM here?


Do I have any other ways to solve this?


Thanks a lot,













Mime
View raw message