Opened 14 years ago

Closed 14 years ago

#1399 closed task (fixed)

Upgrade to Xerces 3.1.0

Reported by: rohitr Owned by: brucedechant
Priority: low Milestone: 2.3
Component: General Version: 2.2.0
Severity: trivial Keywords: xerces, upgrade, oem
Cc: External ID:

Description (last modified by brucedechant)

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:-

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

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

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:-

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'

Change History (2)

comment:1 by brucedechant, 14 years ago

Description: modified (diff)
Owner: set to brucedechant

comment:2 by brucedechant, 14 years ago

Resolution: fixed
Status: newclosed

Fixed in trunk. r5335, r5336 and r5338

Note: See TracTickets for help on using tickets.