Improved compatibility with old libraries (Reported by Kevin Moore)
This commit is contained in:
parent
0cf27535a7
commit
80999d32f9
|
@ -184,8 +184,12 @@ const wxMBConv &WrapXerces::getMBConv()
|
||||||
return conv;
|
return conv;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#ifdef BOOST_STATIC_ASSERT_MSG
|
||||||
BOOST_STATIC_ASSERT_MSG ( sizeof ( XMLCh ) == 2
|
BOOST_STATIC_ASSERT_MSG ( sizeof ( XMLCh ) == 2
|
||||||
, "Xerces-C doesn't use UTF-16 strings any more");
|
, "Xerces-C doesn't use UTF-16 strings any more");
|
||||||
|
#else
|
||||||
|
BOOST_STATIC_ASSERT ( sizeof ( XMLCh ) == 2 );
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return wxConvUTF8;
|
return wxConvUTF8;
|
||||||
|
@ -282,3 +286,115 @@ InputSource *WrapXerces::resolveEntity (
|
||||||
, ( const XMLCh * ) WrapXerces::toString ( publicId ).GetData()
|
, ( const XMLCh * ) WrapXerces::toString ( publicId ).GetData()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DOMElement *WrapXerces::getFirstElementChild ( const DOMElement &element )
|
||||||
|
{
|
||||||
|
#if _XERCES_VERSION >= 30100
|
||||||
|
return element.getFirstElementChild();
|
||||||
|
#else
|
||||||
|
// Copied from Xerces-C
|
||||||
|
DOMNode* n = element.getFirstChild();
|
||||||
|
while ( n )
|
||||||
|
{
|
||||||
|
switch ( n->getNodeType() )
|
||||||
|
{
|
||||||
|
case DOMNode::ELEMENT_NODE:
|
||||||
|
return ( DOMElement * ) n;
|
||||||
|
|
||||||
|
case DOMNode::ENTITY_REFERENCE_NODE:
|
||||||
|
{
|
||||||
|
DOMElement* e = getFirstElementChild ( n );
|
||||||
|
if ( e )
|
||||||
|
return e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n = n->getNextSibling();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMElement *WrapXerces::getFirstElementChild ( const DOMNode *n )
|
||||||
|
{
|
||||||
|
// Copied from Xerces-C
|
||||||
|
const DOMNode *top = n;
|
||||||
|
while ( n )
|
||||||
|
{
|
||||||
|
if ( n->getNodeType() == DOMNode::ELEMENT_NODE )
|
||||||
|
return ( DOMElement * ) n;
|
||||||
|
|
||||||
|
DOMNode *next = n->getFirstChild();
|
||||||
|
while ( !next )
|
||||||
|
{
|
||||||
|
if (top == n)
|
||||||
|
break;
|
||||||
|
|
||||||
|
next = n->getNextSibling();
|
||||||
|
if ( !next )
|
||||||
|
{
|
||||||
|
n = n->getParentNode();
|
||||||
|
if ( top == n || !n )
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n = next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMElement *WrapXerces::getNextElementSibling (
|
||||||
|
const DOMElement &element )
|
||||||
|
{
|
||||||
|
#if _XERCES_VERSION >= 30100
|
||||||
|
return element.getNextElementSibling();
|
||||||
|
#else
|
||||||
|
// Copied from Xerces-C
|
||||||
|
DOMNode *n = getNextLogicalSibling ( &element );
|
||||||
|
while ( n ) {
|
||||||
|
switch ( n->getNodeType() )
|
||||||
|
{
|
||||||
|
case DOMNode::ELEMENT_NODE:
|
||||||
|
return ( DOMElement * ) n;
|
||||||
|
|
||||||
|
case DOMNode::ENTITY_REFERENCE_NODE:
|
||||||
|
{
|
||||||
|
DOMElement* e = getFirstElementChild ( n );
|
||||||
|
if ( e )
|
||||||
|
return e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n = getNextLogicalSibling ( n );
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
DOMNode *WrapXerces::getNextLogicalSibling (
|
||||||
|
const DOMNode* n )
|
||||||
|
{
|
||||||
|
// Copied from Xerces-C
|
||||||
|
DOMNode* next = n->getNextSibling();
|
||||||
|
// If "n" has no following sibling and its parent is an entity reference node we
|
||||||
|
// need to continue the search through the following siblings of the entity
|
||||||
|
// reference as these are logically siblings of the given node.
|
||||||
|
if ( !next ) {
|
||||||
|
DOMNode* parent = n->getParentNode();
|
||||||
|
while ( parent
|
||||||
|
&& parent->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE )
|
||||||
|
{
|
||||||
|
next = parent->getNextSibling();
|
||||||
|
if ( next )
|
||||||
|
break;
|
||||||
|
|
||||||
|
parent = parent->getParentNode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <xercesc/sax2/SAX2XMLReader.hpp>
|
#include <xercesc/sax2/SAX2XMLReader.hpp>
|
||||||
#include <xercesc/sax2/DefaultHandler.hpp>
|
#include <xercesc/sax2/DefaultHandler.hpp>
|
||||||
|
#include <xercesc/dom/DOMElement.hpp>
|
||||||
#include "xercescatalogresolver.h"
|
#include "xercescatalogresolver.h"
|
||||||
|
|
||||||
using namespace xercesc;
|
using namespace xercesc;
|
||||||
|
@ -129,6 +130,12 @@ class WrapXerces : private boost::noncopyable
|
||||||
const wxString &publicId,
|
const wxString &publicId,
|
||||||
const wxString &systemId,
|
const wxString &systemId,
|
||||||
const wxString &fileName );
|
const wxString &fileName );
|
||||||
|
|
||||||
|
static DOMElement *getFirstElementChild ( const DOMElement &element );
|
||||||
|
static DOMElement *getFirstElementChild ( const DOMNode *n );
|
||||||
|
static DOMElement *getNextElementSibling ( const DOMElement &element );
|
||||||
|
static DOMNode *getNextLogicalSibling ( const DOMNode* n );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const wxMBConv &getMBConv();
|
static const wxMBConv &getMBConv();
|
||||||
static XMLNetAccessor *mOriginalNetAccessor;
|
static XMLNetAccessor *mOriginalNetAccessor;
|
||||||
|
|
|
@ -878,7 +878,7 @@ MyFrame::MyFrame (
|
||||||
// Initialize Xerces-C++
|
// Initialize Xerces-C++
|
||||||
WrapXerces::Init ( libxmlNetAccess );
|
WrapXerces::Init ( libxmlNetAccess );
|
||||||
|
|
||||||
#if _XERCES_VERSION >= 30101
|
#if _XERCES_VERSION >= 30100
|
||||||
if ( XMLPlatformUtils::fgSSE2ok
|
if ( XMLPlatformUtils::fgSSE2ok
|
||||||
&& xercescSSE2Warning
|
&& xercescSSE2Warning
|
||||||
&& wxTheApp->argc == 1 )
|
&& wxTheApp->argc == 1 )
|
||||||
|
|
|
@ -115,10 +115,11 @@ void XmlSchemaGenerator::findAllElements ( const DOMElement &element,
|
||||||
wxString tagName = WrapXerces::toString ( element.getTagName() );
|
wxString tagName = WrapXerces::toString ( element.getTagName() );
|
||||||
mElements[tagName].nodes.insert ( &element );
|
mElements[tagName].nodes.insert ( &element );
|
||||||
|
|
||||||
DOMElement *child = element.getFirstElementChild();
|
DOMElement *child = WrapXerces::getFirstElementChild ( element );
|
||||||
for ( ; child != NULL; child = child->getNextElementSibling() )
|
while ( child )
|
||||||
{
|
{
|
||||||
findAllElements ( *child, nIndent );
|
findAllElements ( *child, nIndent );
|
||||||
|
child = WrapXerces::getNextElementSibling ( *child );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,10 +132,11 @@ void XmlSchemaGenerator::generateData ( const DOMElement &element,
|
||||||
generateData ( name, nIndent );
|
generateData ( name, nIndent );
|
||||||
}
|
}
|
||||||
|
|
||||||
DOMElement *child = element.getFirstElementChild();
|
DOMElement *child = WrapXerces::getFirstElementChild ( element );
|
||||||
for ( ; child != NULL; child = child->getNextElementSibling() )
|
while ( child )
|
||||||
{
|
{
|
||||||
generateData ( *child, nIndent );
|
generateData ( *child, nIndent );
|
||||||
|
child = WrapXerces::getNextElementSibling ( *child );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,10 +270,11 @@ void XmlSchemaGenerator::outputSchema ( const DOMElement &element )
|
||||||
mSchema << data.schema;
|
mSchema << data.schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
DOMElement *child = element.getFirstElementChild();
|
DOMElement *child = WrapXerces::getFirstElementChild ( element );
|
||||||
for ( ; child != NULL; child = child->getNextElementSibling() )
|
while ( child )
|
||||||
{
|
{
|
||||||
outputSchema ( *child );
|
outputSchema ( *child );
|
||||||
|
child = WrapXerces::getNextElementSibling ( *child );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue