You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jon Smirl <jo...@mediaone.net> on 2000/06/12 07:27:26 UTC

Xalan-c: createXmlDocument

The Sun parser DOM supports a createXmlDocument function like this:

    XSLTInputSource* pSource = new
XSLTInputSource(m_pRequest->getInputStream());
    XalanDocument pDocInput = XalanDocument::createXmlDocument(pSource,
false);

Where source is the input document and true/false is validate.

Should xalan-c have this function? I've been trying to stick with all of the
Xalan DOM wrapper class so that I don't become dependent on the Xerces API.

Jon Smirl
jonsmirl@mediaone.net



Re: Xalan-c: createXmlDocument

Posted by Jon Smirl <jo...@mediaone.net>.
>objects which are not designed to be thread safe. However, you don't need
>one for every document, just one for every thread. Note that most of these
>objects are very inexpensive to create, so there shouldn't be much
>overhead.

I've just spent the last year working with Java. Objects can be very
expensive in Java so you tend to want to create them once and reuse them. I
just need to readjust my thinking to the C world. Also, I haven't learned
yet which objects are cheap vs expensive in Xalan-c. I'll start reading the
source code more.

It's not simple doing per thread objects in an Apache module. I'm not aware
of thread create/destroy events. A better scheme is having a pool of objects
and checking them out them as needed.

PS - I'm only partially receiving mail from the list. I noticed your reply
in the archives but it hasn't made it to my in box yet.

Jon Smirl
jonsmirl@mediaone.net




Re: Xalan-c: createXmlDocument

Posted by Jon Smirl <jo...@mediaone.net>.
I can replace this:

   m_pDocInput = XalanDocument::createXmlDocument(pSource, false);

with this:

   DOMSupportDefault theDOMSupport;
   XercesParserLiaison theParserLiaison(theDOMSupport);
   m_pDocInput = theParserLiaison.createDocument();
   FormatterToDOM* fToDOM = new FormatterToDOM(m_pDocInput,
(XalanElement*)NULL);
   theParserLiaison.parseXMLStream(*pSource, *fToDOM);

These don't appear to be threadsafe so I need to create them for each
document.
Is there a better way to do this?

Jon Smirl
jonsmirl@mediaone.net