[mapguide-trac] #1399: Upgrade to Xerces 3.1.0

MapGuide Open Source trac_mapguide at osgeo.org
Fri Jul 9 09:33:13 EDT 2010


#1399: Upgrade to Xerces 3.1.0
-----------------------+----------------------------------------------------
   Reporter:  rohitr   |       Owner:                      
       Type:  task     |      Status:  new                 
   Priority:  low      |   Milestone:  2.3                 
  Component:  General  |     Version:  2.2.0               
   Severity:  trivial  |    Keywords:  xerces, upgrade, oem
External_id:           |  
-----------------------+----------------------------------------------------
 Xerces Upgrade

 This ticket is referenced with the Xerces upgrade outlined in
 [http://trac.osgeo.org/mapguide/wiki/MapGuideRfc101]

 changelogs for Xerces
 [http://xerces.apache.org/xerces-c/migrate-archive-3.html]

 Changes that concern us:-[[BR]]

 1.> <xercesc/parsers/SAX2XMLReaderImpl.hpp> is no longer included by
 default.[[BR]]

 2.> DOMWriter has been replaced as part of the the final DOM Level 3
 specification conformance work.[[BR]]

 3.> <xercesc/dom/DOMLSSerializer.hpp>, <xercesc/dom/DOMConfiguration.hpp>
 and  <xercesc/dom/DOMLSOutput.hpp> were added as part of the DOM Level 3
 specification conformance.

 Changes I have made:-[[BR]]

 1.> included the relevant header files, as necessary.

 2.> Since we don't have access to DOMWriter and the serialization works in
 a different way now I rewrote most of MgXmlUtil:ToBytes().
 {{{
     DOMLSSerializer* theSerializer = NULL;
     DOMLSOutput* theOutputDesc = NULL;
     DOMConfiguration* theDC = NULL;
     XMLFormatTarget* memTarget = NULL;

 }}}

 The new serializing class is now DOMLSSerializer. It outputs to streams
 defined by DOMLSOutput which now controls output parameters like encoding.
 Other configuration details are specified by the DOMConfiguration class.
 The Output stream is defined by an XMLFormatTarget which we will cast as
 in MemBufFormatTarget.
 {{{
     // get a serializer, an instance of DOMWriter
     XMLCh tempStr[100];
     XMLString::transcode("LS", tempStr, 99);

     DOMImplementation *impl  =
 DOMImplementationRegistry::getDOMImplementation(tempStr);
     CHECKNULL(impl, L"MgXmlUtil.ToBytes");

     theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
     theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
     CHECKNULL(theSerializer, L"MgXmlUtil.ToBytes");
     CHECKNULL(theOutputDesc, L"MgXmlUtil.ToBytes");
     theDC = theSerializer->getDomConfig();
 }}}
 DOMLSSerializer and DOMLSOutput are assigned using the DOMImplementation
 object impl, while DOMConfiguration initializes using the DOMLSSerializer
 object.
 {{{
     // set user specified output encoding
     XMLCh encodeStr[100];
     XMLString::transcode("UTF-8", encodeStr, 99);
     theOutputDesc->setEncoding(encodeStr);
 }}}
 Encoding is specified in DOMLSOutput now.
 {{{
     memTarget = new MemBufFormatTarget();
     theOutputDesc->setByteStream(memTarget);

     theSerializer->write(m_doc, theOutputDesc);
 }}}

 memTarget is initialized with a MemBufFormatTarget object and this is
 attached to the output stream of DOMLSOutput. Note that writenode has been
 replaced with just write.
 {{{
     INT32 bytesLen = (INT32)((MemBufFormatTarget*)memTarget)->getLen();
     BYTE_ARRAY_IN rawBytes =
 (BYTE_ARRAY_IN)((MemBufFormatTarget*)memTarget)->getRawBuffer();
 }}}
 We have to cast it as MemBufFormatTarget.

 3.> In FilterUtil.h the namespace was declared by 'namespace xercesc_2_7'.
 I changed it to xerces_3_0 for it to work with the new xerces. Note that
 this is bad programming practice. I would change it as soon as I get a
 working compile. It should be declared as 'namespace
 XERCES_CPP_NAMESPACE_QUALIFIER'

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/1399>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list