dbertoni    2002/10/02 22:59:21

  Modified:    c/src/XercesParserLiaison XercesParserLiaison.cpp
                        XercesParserLiaison.hpp
  Log:
  Updates for new DOM and new DOM parser.
  
  Revision  Changes    Path
  1.51      +35 -4     
xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp
  
  Index: XercesParserLiaison.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- XercesParserLiaison.cpp   3 Oct 2002 01:33:09 -0000       1.50
  +++ XercesParserLiaison.cpp   3 Oct 2002 05:59:20 -0000       1.51
  @@ -73,7 +73,7 @@
   
   #include <xercesc/framework/URLInputSource.hpp>
   #if XERCES_VERSION_MAJOR >= 2
  -#include <xercesc/dom/deprecated/DOMParser.hpp>
  +#include <xercesc/parsers/XercesDOMParser.hpp>
   #else
   #include <xercesc/parsers/DOMParser.hpp>
   #endif
  @@ -132,6 +132,7 @@
        m_externalSchemaLocation(),
        m_externalNoNamespaceSchemaLocation(),
        m_documentMap(),
  +     m_buildWrapper(true),
        m_buildBridge(true),
        m_threadSafe(false),
        m_executionContext(0)
  @@ -159,6 +160,11 @@
                i != m_documentMap.end();
                ++i)
        {
  +             if ((*i).second.m_isDeprecated == false)
  +             {
  +                     delete (*i).second.m_wrapper->getXercesDocument();
  +             }
  +
                delete (*i).first;
        }
   
  @@ -214,7 +220,11 @@
                        const InputSource&              reader,
                        const XalanDOMString&   /* identifier */)
   {
  +#if XERCES_VERSION_MAJOR >= 2
  +     XalanAutoPtr<XercesDOMParser>   theParser(CreateDOMParser());
  +#else
        XalanAutoPtr<DOMParser>         theParser(CreateDOMParser());
  +#endif
   
        if (m_errorHandler == 0)
        {
  @@ -227,16 +237,33 @@
   
        theParser->parse(reader);
   
  +#if XERCES_VERSION_MAJOR >= 2
  +     DOMDocument* const      theXercesDocument =
  +             theParser->getDocument();
  +
  +     theXercesDocument->normalize();
  +#else
        DOM_Document    theXercesDocument =
                theParser->getDocument();
   
        theXercesDocument.normalize();
  +#endif
   
  +#if XERCES_VERSION_MAJOR >= 2
  +     XercesDocumentWrapper*  theNewDocument = 0;
  +
  +     if (theXercesDocument != 0)
  +     {
  +             theNewDocument = doCreateDocument(theXercesDocument, 
m_threadSafe, m_buildWrapper);
  +
  +             theParser->adoptDocument();
  +#else
        XercesDocumentBridge*   theNewDocument = 0;
   
        if (theXercesDocument.isNull() == false)
        {
                theNewDocument = doCreateDocument(theXercesDocument, 
m_threadSafe, m_buildBridge);
  +#endif
   
                m_documentMap[theNewDocument] = theNewDocument;
        }
  @@ -618,12 +645,14 @@
   
   
   
  -DOMParser*
  +XercesParserLiaison::DOMParserType*
   XercesParserLiaison::CreateDOMParser()
   {
  -     DOMParser* const        theParser = new DOMParser;
  +     DOMParserType* const    theParser = new DOMParserType;
  +
  +     theParser->setExpandEntityReferences(true);
   
  -     theParser->setValidationScheme(m_useValidation == true ? 
DOMParser::Val_Auto : DOMParser::Val_Never);
  +     theParser->setValidationScheme(m_useValidation == true ? 
DOMParserType::Val_Auto : DOMParserType::Val_Never);
   
        theParser->setIncludeIgnorableWhitespace(m_includeIgnorableWhitespace);
   
  @@ -648,9 +677,11 @@
                
theParser->setExternalNoNamespaceSchemaLocation(c_wstr(m_externalNoNamespaceSchemaLocation));
        }
   
  +#if XERCES_VERSION_MAJOR < 2
        // Xerces has a non-standard node type to represent the XML decl.
        // Why did they ever do this?
        theParser->setToCreateXMLDeclTypeNode(false);
  +#endif
   
        return theParser;
   }
  
  
  
  1.37      +85 -1     
xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp
  
  Index: XercesParserLiaison.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- XercesParserLiaison.hpp   3 Oct 2002 01:33:09 -0000       1.36
  +++ XercesParserLiaison.hpp   3 Oct 2002 05:59:20 -0000       1.37
  @@ -80,7 +80,11 @@
   
   class DOM_Document;
   class DOMDocument;
  +#if XERCES_VERSION_MAJOR >= 2
  +class XercesDOMParser;
  +#else
   class DOMParser;
  +#endif
   class DOMSupport;
   class EntityResolver;
   class InputSource;
  @@ -331,6 +335,24 @@
         *
         * @deprecated This API is deprecated.
         * @param theXercesDocument The Xerces document.
  +      * @return a pointer to a new XalanDocument-derived instance.
  +      */
  +     XalanDocument*
  +     createDocument(const DOM_Document&      theXercesDocument)
  +     {
  +             return createDocument(theXercesDocument, m_threadSafe, 
m_buildBridge);
  +     }
  +
  +     /**
  +      * This API is deprecated.
  +      *
  +      * Create a XalanDocument proxy for an existing Xerces document.
  +      * The parser liaison owns the instance, and you must not delete
  +      * it.  The liaison will delete it when reset() is called, or the
  +      * liaison is destroyed.
  +      *
  +      * @deprecated This API is deprecated.
  +      * @param theXercesDocument The Xerces document.
         * @param threadSafe If true, read access to the tree will be 
thread-safe (implies buildBridge == true).
         * @param buildBridge If true, the entire bridge structure is built.
         * @return a pointer to a new XalanDocument-derived instance.
  @@ -348,6 +370,21 @@
         * liaison is destroyed.
         *
         * @param theXercesDocument The Xerces document.
  +      * @return a pointer to a new XalanDocument-derived instance.
  +      */
  +     XalanDocument*
  +     createDocument(const DOMDocument*       theXercesDocument)
  +     {
  +             return createDocument(theXercesDocument, m_threadSafe, 
m_buildWrapper);
  +     }
  +
  +     /**
  +      * Create a XalanDocument proxy for an existing Xerces document.
  +      * The parser liaison owns the instance, and you must not delete
  +      * it.  The liaison will delete it when reset() is called, or the
  +      * liaison is destroyed.
  +      *
  +      * @param theXercesDocument The Xerces document.
         * @param threadSafe If true, read access to the tree will be 
thread-safe (implies buildBridge == true).
         * @param buildWrapper If true, the entire wrapper structure is built.
         * @return a pointer to a new XalanDocument-derived instance.
  @@ -469,6 +506,7 @@
        /**
         * This functions returns the state of the liaison's build-bridge-nodes 
flag.
         *
  +      * @deprecated This API is deprecated.
         * @return true, if the bridge nodes are automatically built, false 
otherwise.
         */
        bool
  @@ -479,11 +517,14 @@
        }
   
        /**
  +      * This API is deprecated.
  +      *
         * This functions sets the state of the liaison's build-bridge-nodes 
flag.
         * This flag must be set for the document to be thread safe.  It can 
also be
         * set to true to increase performance.  If this flag is set to false, 
then
         * the thread-safe flag will also be set to false.
         *
  +      * @deprecated This API is deprecated.
         * @param newState The new state for the flag.
         *
         */
  @@ -499,6 +540,40 @@
        }
   
        /**
  +      * This API is deprecated.
  +      *
  +      * This functions returns the state of the liaison's 
build-wrapper-nodes flag.
  +      *
  +      * @return true, if the wrapper nodes are automatically built, false 
otherwise.
  +      */
  +     bool
  +     getBuildWrapperNodes() const
  +     
  +     {
  +             return m_buildWrapper;
  +     }
  +
  +     /**
  +      * This functions sets the state of the liaison's build-wrapper-nodes 
flag.
  +      * This flag must be set for the document to be thread safe.  It can 
also be
  +      * set to true to increase performance.  If this flag is set to false, 
then
  +      * the thread-safe flag will also be set to false.
  +      *
  +      * @param newState The new state for the flag.
  +      *
  +      */
  +     void
  +     setBuildWrapperNodes(bool       newState)
  +     {
  +             m_buildWrapper = newState;
  +
  +             if (newState == false)
  +             {
  +                     m_threadSafe = false;
  +             }
  +     }
  +
  +     /**
         * This functions returns the state of the liaison's thread-safe flag.
         * If true, documents created will be safe when data is read.  By 
default,
         * documents are _not_ thread-safe.
  @@ -530,10 +605,17 @@
   
                if (m_threadSafe == true)
                {
  +                     m_buildWrapper = true;
                        m_buildBridge = true;
                }
        }
   
  +#if XERCES_VERSION_MAJOR >= 2
  +     typedef XercesDOMParser         DOMParserType;
  +#else
  +     typedef DOMParser       DOMParserType;
  +#endif
  +
   protected:
   
        static void
  @@ -541,7 +623,7 @@
                        const SAXParseException&        e,
                        XalanDOMString&                         theMessage);
   
  -     virtual DOMParser*
  +     DOMParserType*
        CreateDOMParser();
   
        virtual SAXParser*
  @@ -597,6 +679,8 @@
        XalanDOMString          m_externalNoNamespaceSchemaLocation;
   
        DocumentMapType         m_documentMap;
  +
  +     bool                            m_buildWrapper;
   
        bool                            m_buildBridge;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to