From a5e86d37cf40004e6a43a21ab67d26695fa8619c Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 15 Dec 2008 03:56:35 +0000 Subject: [PATCH] Xerces 3 revisions. --- config_win32.h | 20 +++++++ configure.ac | 42 +++++++++++++- .../AbstractAttributeExtensibleXMLObject.cpp | 15 ++++- xmltooling/AbstractComplexElement.cpp | 2 + xmltooling/AbstractDOMCachingXMLObject.cpp | 1 + xmltooling/AbstractXMLObject.cpp | 2 + xmltooling/Namespace.cpp | 2 + xmltooling/QName.cpp | 2 + xmltooling/XMLObjectBuilder.cpp | 2 + xmltooling/XMLToolingConfig.cpp | 2 + xmltooling/base.h | 50 +++++++++++++++-- xmltooling/config_pub.h.in | 9 +++ xmltooling/config_pub_win32.h | 8 +++ xmltooling/encryption/impl/Decrypter.cpp | 3 +- xmltooling/encryption/impl/Encrypter.cpp | 1 + xmltooling/encryption/impl/EncryptionImpl.cpp | 29 +++++----- xmltooling/exceptions.cpp | 7 ++- xmltooling/impl/AnyElement.cpp | 3 +- xmltooling/impl/MemoryStorageService.cpp | 2 + xmltooling/impl/UnknownElement.cpp | 3 +- xmltooling/internal.h | 2 - xmltooling/io/AbstractXMLObjectMarshaller.cpp | 1 + xmltooling/io/AbstractXMLObjectUnmarshaller.cpp | 1 + .../security/impl/AbstractPKIXTrustEngine.cpp | 4 +- .../security/impl/ChainingCredentialResolver.cpp | 2 + xmltooling/security/impl/ChainingTrustEngine.cpp | 2 + xmltooling/security/impl/CredentialResolver.cpp | 4 +- .../security/impl/ExplicitKeyTrustEngine.cpp | 2 + .../security/impl/FilesystemCredentialResolver.cpp | 4 ++ xmltooling/security/impl/InlineKeyResolver.cpp | 1 + xmltooling/security/impl/KeyInfoResolver.cpp | 2 +- xmltooling/security/impl/TrustEngine.cpp | 2 + xmltooling/signature/impl/KeyInfoImpl.cpp | 23 ++++---- xmltooling/signature/impl/XMLSecSignatureImpl.cpp | 3 +- xmltooling/soap/impl/SOAPClient.cpp | 3 +- xmltooling/soap/impl/SOAPImpl.cpp | 27 ++++----- xmltooling/unicode.cpp | 10 ++-- xmltooling/util/CurlNetAccessor.cpp | 1 + xmltooling/util/CurlNetAccessor.hpp | 4 +- xmltooling/util/CurlURLInputStream.cpp | 4 +- xmltooling/util/CurlURLInputStream.hpp | 35 +++++++++--- xmltooling/util/DateTime.cpp | 5 +- xmltooling/util/DateTime.h | 2 +- xmltooling/util/ParserPool.cpp | 40 +++++++++++-- xmltooling/util/ParserPool.h | 65 ++++++++++++++++++---- xmltooling/util/ReloadableXMLFile.cpp | 1 + xmltooling/util/StorageService.cpp | 2 +- xmltooling/util/XMLConstants.cpp | 2 + xmltooling/util/XMLHelper.cpp | 59 +++++++++++++++----- xmltooling/xmltooling-lite.vcproj | 8 +-- xmltooling/xmltooling.vcproj | 8 +-- xmltoolingtest/xmltoolingtest.vcproj | 16 +++--- 52 files changed, 424 insertions(+), 126 deletions(-) diff --git a/config_win32.h b/config_win32.h index e21a066..c5e4385 100644 --- a/config_win32.h +++ b/config_win32.h @@ -65,6 +65,26 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_UNISTD_H */ +/* Define to 1 if you have the header file. */ +#undef HAVE_XERCESC_DOM_DOMLSPARSER_HPP + +/* Define to 1 if you have the header + file. */ +#undef HAVE_XERCESC_DOM_DOMLSRESOURCERESOLVER_HPP + +/* Define to 1 if you have the header file. + */ +#undef HAVE_XERCESC_DOM_DOMLSSERIALIZER_HPP + +#include + +#if (XERCES_VERSION_MAJOR >= 3) +# define XMLTOOLING_XERCESC_COMPLIANT_DOMLS 1 +# define XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE 1 +# define XMLTOOLING_XERCESC_64BITSAFE 1 +# define XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE 1 +#endif + /* Name of package */ #define PACKAGE "xmltooling" diff --git a/configure.ac b/configure.ac index e6a8654..c64aaf2 100644 --- a/configure.ac +++ b/configure.ac @@ -169,9 +169,45 @@ AC_TRY_LINK( [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])], [AC_MSG_ERROR([unable to link with Xerces])]) -# DOM3 API checks. -AC_CHECK_HEADERS([xercesc/dom/DOMLSParser.hpp xercesc/dom/DOMLSSerializer.hpp xercesc/dom/DOMLSResourceResolver.hpp]) - +AC_MSG_CHECKING([whether Xerces is 64-bit clean]) +AC_TRY_COMPILE([#include ], + [using namespace XERCES_CPP_NAMESPACE; + XMLFilePos testvar; + ], + [AC_MSG_RESULT([yes])] + [AC_DEFINE(XMLTOOLING_XERCESC_64BITSAFE)], + [AC_MSG_RESULT([no])]) + +AC_MSG_CHECKING([whether Xerces BinInputStream requires getContentType]) +AC_TRY_COMPILE([#include ], + [using namespace XERCES_CPP_NAMESPACE; + char buf[1024]; + BinMemInputStream in(buf,1024); + in.getContentType(); + ], + [AC_MSG_RESULT([yes])] + [AC_DEFINE(XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE)], + [AC_MSG_RESULT([no])]) + +AC_MSG_CHECKING([whether Xerces DOMLS API is compliant]) +AC_TRY_COMPILE([#include ], + [using namespace XERCES_CPP_NAMESPACE; + DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(NULL); + DOMLSSerializer *ls = ((DOMImplementationLS*)impl)->createLSSerializer(); + ], + [AC_MSG_RESULT([yes])] + [AC_DEFINE(XMLTOOLING_XERCESC_COMPLIANT_DOMLS)], + [AC_MSG_RESULT([no])]) + +AC_MSG_CHECKING([whether Xerces has setIdAttribute(XMLCh*, bool)]) +AC_TRY_COMPILE([#include ], + [using namespace XERCES_CPP_NAMESPACE; + DOMElement * elt; + elt->setIdAttribute(NULL, false); + ], + [AC_MSG_RESULT([yes])] + [AC_DEFINE(XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE)], + [AC_MSG_RESULT([no])]) # XML-Security settings AC_ARG_WITH(xmlsec, diff --git a/xmltooling/AbstractAttributeExtensibleXMLObject.cpp b/xmltooling/AbstractAttributeExtensibleXMLObject.cpp index 2efde22..b24ee87 100644 --- a/xmltooling/AbstractAttributeExtensibleXMLObject.cpp +++ b/xmltooling/AbstractAttributeExtensibleXMLObject.cpp @@ -29,6 +29,10 @@ using namespace xmltooling; using namespace std; +using xercesc::DOMAttr; +using xercesc::DOMElement; +using xercesc::XMLString; + set AttributeExtensibleXMLObject::m_idAttributeSet; AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject() @@ -80,7 +84,11 @@ void AbstractAttributeExtensibleXMLObject::unmarshallExtensionAttribute(const DO bool ID = attribute->isId() || isRegisteredIDAttribute(q); setAttribute(q,attribute->getNodeValue(),ID); if (ID) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + attribute->getOwnerElement()->setIdAttributeNode(attribute, true); +#else attribute->getOwnerElement()->setIdAttributeNode(attribute); +#endif } } @@ -92,7 +100,12 @@ void AbstractAttributeExtensibleXMLObject::marshallExtensionAttributes(DOMElemen attr->setPrefix(i->first.getPrefix()); attr->setNodeValue(i->second); domElement->setAttributeNodeNS(attr); - if (m_idAttribute==i) + if (m_idAttribute==i) { +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + domElement->setIdAttributeNode(attr, true); +#else domElement->setIdAttributeNode(attr); +#endif + } } } diff --git a/xmltooling/AbstractComplexElement.cpp b/xmltooling/AbstractComplexElement.cpp index d9ab944..335520f 100644 --- a/xmltooling/AbstractComplexElement.cpp +++ b/xmltooling/AbstractComplexElement.cpp @@ -28,6 +28,8 @@ using namespace xmltooling; using namespace std; +using xercesc::XMLString; + AbstractComplexElement::~AbstractComplexElement() { for_each(m_children.begin(), m_children.end(), cleanup()); for (vector::iterator i=m_text.begin(); i!=m_text.end(); ++i) diff --git a/xmltooling/AbstractDOMCachingXMLObject.cpp b/xmltooling/AbstractDOMCachingXMLObject.cpp index 9417e31..b8d3b42 100644 --- a/xmltooling/AbstractDOMCachingXMLObject.cpp +++ b/xmltooling/AbstractDOMCachingXMLObject.cpp @@ -30,6 +30,7 @@ #include using namespace xmltooling; +using namespace xercesc; using namespace std; AbstractDOMCachingXMLObject::~AbstractDOMCachingXMLObject() diff --git a/xmltooling/AbstractXMLObject.cpp b/xmltooling/AbstractXMLObject.cpp index 0f49b55..aeb0817 100644 --- a/xmltooling/AbstractXMLObject.cpp +++ b/xmltooling/AbstractXMLObject.cpp @@ -28,6 +28,8 @@ using namespace xmltooling; +using xercesc::XMLString; + AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) : m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject")), m_schemaLocation(NULL), m_noNamespaceSchemaLocation(NULL), m_nil(xmlconstants::XML_BOOL_NULL), diff --git a/xmltooling/Namespace.cpp b/xmltooling/Namespace.cpp index ec272c0..57ca9d6 100644 --- a/xmltooling/Namespace.cpp +++ b/xmltooling/Namespace.cpp @@ -25,6 +25,8 @@ using namespace xmltooling; +using xercesc::XMLString; + Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix, bool alwaysDeclare) : m_pinned(alwaysDeclare) { #ifndef HAVE_GOOD_STL diff --git a/xmltooling/QName.cpp b/xmltooling/QName.cpp index b161da6..868725c 100644 --- a/xmltooling/QName.cpp +++ b/xmltooling/QName.cpp @@ -26,6 +26,8 @@ using namespace xmltooling; using namespace std; +using xercesc::XMLString; + QName::QName(const XMLCh* uri, const XMLCh* localPart, const XMLCh* prefix) { #ifndef HAVE_GOOD_STL diff --git a/xmltooling/XMLObjectBuilder.cpp b/xmltooling/XMLObjectBuilder.cpp index 982f6a2..972e212 100644 --- a/xmltooling/XMLObjectBuilder.cpp +++ b/xmltooling/XMLObjectBuilder.cpp @@ -30,6 +30,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + map XMLObjectBuilder::m_map; XMLObjectBuilder* XMLObjectBuilder::m_default=NULL; diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index d36d746..f4109fa 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -69,6 +69,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::XMLPlatformUtils; + DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLParserException,xmltooling); DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLObjectException,xmltooling); DECL_XMLTOOLING_EXCEPTION_FACTORY(MarshallingException,xmltooling); diff --git a/xmltooling/base.h b/xmltooling/base.h index e1c7199..30db50d 100644 --- a/xmltooling/base.h +++ b/xmltooling/base.h @@ -39,6 +39,15 @@ # define XMLTOOLING_NO_XMLSEC 1 #endif +#ifdef XMLTOOLING_NO_XMLSEC +# ifdef XMLTOOLING_XERCESC_64BITSAFE +# include + typedef XMLSize_t xsecsize_t; +# else + typedef unsigned int xsecsize_t; +# endif +#endif + // Windows and GCC4 Symbol Visibility Macros #ifdef WIN32 #define XMLTOOL_IMPORT __declspec(dllimport) @@ -987,6 +996,20 @@ domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \ } +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE +/** + * Implements marshalling for an ID attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +# define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \ + if (m_##proper && *m_##proper) { \ + domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ + domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, true); \ + } +#else /** * Implements marshalling for an ID attribute * @@ -994,11 +1017,12 @@ * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute */ -#define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \ +# define MARSHALL_ID_ATTRIB(proper,ucase,namespaceURI) \ if (m_##proper && *m_##proper) { \ domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, m_##proper); \ domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \ } +#endif /** * Implements unmarshalling process branch for a string attribute @@ -1013,6 +1037,7 @@ return; \ } +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE /** * Implements unmarshalling process branch for an ID attribute * @@ -1020,12 +1045,27 @@ * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute */ -#define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \ +# define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \ + if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ + set##proper(attribute->getValue()); \ + attribute->getOwnerElement()->setIdAttributeNode(attribute, true); \ + return; \ + } +#else +/** + * Implements unmarshalling process branch for an ID attribute + * + * @param proper the proper name of the attribute + * @param ucase the upcased name of the attribute + * @param namespaceURI the XML namespace of the attribute + */ +# define PROC_ID_ATTRIB(proper,ucase,namespaceURI) \ if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ set##proper(attribute->getValue()); \ attribute->getOwnerElement()->setIdAttributeNode(attribute); \ return; \ } +#endif /** * Implements unmarshalling process branch for a DateTime attribute @@ -1242,7 +1282,7 @@ { \ public: \ virtual ~cname##Impl() {} \ - cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \ + cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) \ : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType) { \ } \ cname##Impl(const cname##Impl& src) \ @@ -1311,7 +1351,7 @@ */ #define IMPL_XMLOBJECTBUILDER(cname) \ cname* cname##Builder::buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType \ ) const \ { \ return new cname##Impl(nsURI,localName,prefix,schemaType); \ @@ -1376,7 +1416,7 @@ */ #define IMPL_XMLOBJECTBUILDER(cname) \ xmltooling::XMLObject* cname##Builder::buildObject( \ - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \ + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::Name* schemaType \ ) const \ { \ return new cname##Impl(nsURI,localName,prefix,schemaType); \ diff --git a/xmltooling/config_pub.h.in b/xmltooling/config_pub.h.in index 1ae9290..b14839a 100644 --- a/xmltooling/config_pub.h.in +++ b/xmltooling/config_pub.h.in @@ -17,3 +17,12 @@ /* Define to 1 to disable XML-Security-dependent features. */ #undef XMLTOOLING_NO_XMLSEC + +/* Define to 1 if Xerces supports a compliant DOMLS API. */ +#undef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + +/* Define to 1 if Xerces DOM ID methods take extra parameter. */ +#undef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + +/* Define to 1 if Xerces has a 64-bit-safe API. */ +#undef XMLTOOLING_XERCESC_64BITSAFE diff --git a/xmltooling/config_pub_win32.h b/xmltooling/config_pub_win32.h index bf1053b..6c00991 100644 --- a/xmltooling/config_pub_win32.h +++ b/xmltooling/config_pub_win32.h @@ -20,3 +20,11 @@ /* Define if you wish to disable Xalan-dependent features. */ #define XSEC_NO_XALAN + +#include + +#if (XERCES_VERSION_MAJOR >= 3) +# define XMLTOOLING_XERCESC_COMPLIANT_DOMLS 1 +# define XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE 1 +# define XMLTOOLING_XERCESC_64BITSAFE 1 +#endif diff --git a/xmltooling/encryption/impl/Decrypter.cpp b/xmltooling/encryption/impl/Decrypter.cpp index a87fa89..b29ca13 100644 --- a/xmltooling/encryption/impl/Decrypter.cpp +++ b/xmltooling/encryption/impl/Decrypter.cpp @@ -39,6 +39,7 @@ using namespace xmlencryption; using namespace xmlsignature; using namespace xmltooling; +using namespace xercesc; using namespace std; Decrypter::~Decrypter() @@ -164,7 +165,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, XS auto_ptr in(m_cipher->decryptToBinInputStream(encryptedData.getDOM())); XMLByte buf[8192]; - unsigned int count = in->readBytes(buf, sizeof(buf)); + xsecsize_t count = in->readBytes(buf, sizeof(buf)); while (count > 0) out.write(reinterpret_cast(buf),count); } diff --git a/xmltooling/encryption/impl/Encrypter.cpp b/xmltooling/encryption/impl/Encrypter.cpp index ae184e9..21601b8 100644 --- a/xmltooling/encryption/impl/Encrypter.cpp +++ b/xmltooling/encryption/impl/Encrypter.cpp @@ -34,6 +34,7 @@ using namespace xmlencryption; using namespace xmlsignature; using namespace xmltooling; +using namespace xercesc; using namespace std; Encrypter::~Encrypter() diff --git a/xmltooling/encryption/impl/EncryptionImpl.cpp b/xmltooling/encryption/impl/EncryptionImpl.cpp index ffabf41..a6d0af7 100644 --- a/xmltooling/encryption/impl/EncryptionImpl.cpp +++ b/xmltooling/encryption/impl/EncryptionImpl.cpp @@ -34,6 +34,7 @@ using namespace xmlencryption; using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::XMLENC_NS; using xmlconstants::XMLSIG_NS; @@ -71,7 +72,7 @@ namespace xmlencryption { XMLString::release(&m_Algorithm); } - EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -129,7 +130,7 @@ namespace xmlencryption { public: virtual ~TransformsImpl() {} - TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -170,7 +171,7 @@ namespace xmlencryption { XMLString::release(&m_URI); } - CipherReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + CipherReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -221,7 +222,7 @@ namespace xmlencryption { public: virtual ~CipherDataImpl() {} - CipherDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + CipherDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -263,7 +264,7 @@ namespace xmlencryption { XMLString::release(&m_Target); } - EncryptionPropertyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionPropertyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -286,7 +287,7 @@ namespace xmlencryption { IMPL_STRING_ATTRIB(Target); IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end()); - void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) { + void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) { if (!qualifiedName.hasNamespaceURI()) { if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) { setId(value); @@ -331,7 +332,7 @@ namespace xmlencryption { XMLString::release(&m_Id); } - EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptionPropertiesImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -388,7 +389,7 @@ namespace xmlencryption { XMLString::release(&m_URI); } - ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + ReferenceTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -426,7 +427,7 @@ namespace xmlencryption { public: virtual ~DataReferenceImpl() {} - DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + DataReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} DataReferenceImpl(const DataReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {} @@ -442,7 +443,7 @@ namespace xmlencryption { public: virtual ~KeyReferenceImpl() {} - KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + KeyReferenceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} KeyReferenceImpl(const KeyReferenceImpl& src) : AbstractXMLObject(src), ReferenceTypeImpl(src) {} @@ -462,7 +463,7 @@ namespace xmlencryption { public: virtual ~ReferenceListImpl() {} - ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + ReferenceListImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -534,7 +535,7 @@ namespace xmlencryption { XMLString::release(&m_Encoding); } - EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -596,7 +597,7 @@ namespace xmlencryption { public: virtual ~EncryptedDataImpl() {} - EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) {} EncryptedDataImpl(const EncryptedDataImpl& src) : AbstractXMLObject(src), EncryptedTypeImpl(src) {} @@ -626,7 +627,7 @@ namespace xmlencryption { XMLString::release(&m_Recipient); } - EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EncryptedKeyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } diff --git a/xmltooling/exceptions.cpp b/xmltooling/exceptions.cpp index 1d0e883..ea8aa40 100644 --- a/xmltooling/exceptions.cpp +++ b/xmltooling/exceptions.cpp @@ -33,6 +33,7 @@ #include using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::XMLTOOLING_NS; @@ -129,13 +130,13 @@ inline const char* get_digit_character() return s_mid; } -inline const char* unsigned_integer_to_string(char* buf, size_t cchBuf, int i) +inline const char* unsigned_integer_to_string(char* buf, size_t cchBuf, size_t i) { char* psz=buf + cchBuf - 1; // Set psz to last char *psz = 0; // Set terminating null do { - unsigned int lsd = i % 10; // Get least significant + size_t lsd = i % 10; // Get least significant // digit i /= 10; // Prepare for next most @@ -153,7 +154,7 @@ inline const char* unsigned_integer_to_string(char* buf, size_t cchBuf, int i) void XMLToolingException::addProperties(const params& p) { m_processedmsg.erase(); - int i=m_params.size()+1; + map::size_type i=m_params.size()+1; char buf[20]; const vector& v=p.get(); for (vector::const_iterator ci=v.begin(); ci!=v.end(); ci++) { diff --git a/xmltooling/impl/AnyElement.cpp b/xmltooling/impl/AnyElement.cpp index 1e4e2f0..8fb4cfc 100644 --- a/xmltooling/impl/AnyElement.cpp +++ b/xmltooling/impl/AnyElement.cpp @@ -29,6 +29,7 @@ #include using namespace xmltooling; +using namespace xercesc; using namespace std; XMLObject* AnyElementImpl::clone() const { @@ -62,7 +63,7 @@ void AnyElementImpl::processAttribute(const DOMAttr* attribute) { } XMLObject* AnyElementBuilder::buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType ) const { return new AnyElementImpl(nsURI, localName, prefix, schemaType); } diff --git a/xmltooling/impl/MemoryStorageService.cpp b/xmltooling/impl/MemoryStorageService.cpp index fdef458..7e9b845 100644 --- a/xmltooling/impl/MemoryStorageService.cpp +++ b/xmltooling/impl/MemoryStorageService.cpp @@ -34,6 +34,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + namespace xmltooling { class XMLTOOL_DLLLOCAL MemoryStorageService : public StorageService { diff --git a/xmltooling/impl/UnknownElement.cpp b/xmltooling/impl/UnknownElement.cpp index af4d12e..b1bc80f 100644 --- a/xmltooling/impl/UnknownElement.cpp +++ b/xmltooling/impl/UnknownElement.cpp @@ -33,6 +33,7 @@ using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; #ifndef XMLTOOLING_NO_XMLSEC using xmlsignature::Signature; @@ -204,7 +205,7 @@ XMLObject* UnknownElementImpl::unmarshall(DOMElement* element, bool bindDocument } XMLObject* UnknownElementBuilder::buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType ) const { return new UnknownElementImpl(nsURI,localName,prefix); } diff --git a/xmltooling/internal.h b/xmltooling/internal.h index 3a86e3b..6760ace 100644 --- a/xmltooling/internal.h +++ b/xmltooling/internal.h @@ -40,8 +40,6 @@ #include "XMLToolingConfig.h" #include "util/ParserPool.h" -using namespace xercesc; - #include #ifndef XMLTOOLING_NO_XMLSEC #include diff --git a/xmltooling/io/AbstractXMLObjectMarshaller.cpp b/xmltooling/io/AbstractXMLObjectMarshaller.cpp index 622240d..7e2cf3c 100644 --- a/xmltooling/io/AbstractXMLObjectMarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectMarshaller.cpp @@ -40,6 +40,7 @@ #endif using namespace xmlconstants; using namespace xmltooling; +using namespace xercesc; using namespace std; DOMElement* AbstractXMLObjectMarshaller::marshall( diff --git a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp index 5a07591..66ae055 100644 --- a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp @@ -32,6 +32,7 @@ using namespace xmlconstants; using namespace xmltooling; +using namespace xercesc; using namespace std; diff --git a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp index 2d5dcb0..791290b 100644 --- a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp +++ b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp @@ -162,11 +162,11 @@ namespace { } }; -AbstractPKIXTrustEngine::AbstractPKIXTrustEngine(const DOMElement* e) : TrustEngine(e), m_fullCRLChain(false) +AbstractPKIXTrustEngine::AbstractPKIXTrustEngine(const xercesc::DOMElement* e) : TrustEngine(e), m_fullCRLChain(false) { static XMLCh fullCRLChain[] = UNICODE_LITERAL_12(f,u,l,l,C,R,L,C,h,a,i,n); const XMLCh* flag = e ? e->getAttributeNS(NULL, fullCRLChain) : NULL; - m_fullCRLChain = (flag && (*flag == chLatin_t || *flag == chDigit_1)); + m_fullCRLChain = (flag && (*flag == xercesc::chLatin_t || *flag == xercesc::chDigit_1)); } bool AbstractPKIXTrustEngine::checkEntityNames( diff --git a/xmltooling/security/impl/ChainingCredentialResolver.cpp b/xmltooling/security/impl/ChainingCredentialResolver.cpp index f98ec7c..abbe6b2 100644 --- a/xmltooling/security/impl/ChainingCredentialResolver.cpp +++ b/xmltooling/security/impl/ChainingCredentialResolver.cpp @@ -33,6 +33,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + namespace xmltooling { class XMLTOOL_DLLLOCAL ChainingCredentialResolver : public CredentialResolver { diff --git a/xmltooling/security/impl/ChainingTrustEngine.cpp b/xmltooling/security/impl/ChainingTrustEngine.cpp index 4b5aa2c..358d3b9 100644 --- a/xmltooling/security/impl/ChainingTrustEngine.cpp +++ b/xmltooling/security/impl/ChainingTrustEngine.cpp @@ -33,6 +33,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + namespace xmltooling { TrustEngine* XMLTOOL_DLLLOCAL ChainingTrustEngineFactory(const DOMElement* const & e) { diff --git a/xmltooling/security/impl/CredentialResolver.cpp b/xmltooling/security/impl/CredentialResolver.cpp index 82bb279..75585d5 100644 --- a/xmltooling/security/impl/CredentialResolver.cpp +++ b/xmltooling/security/impl/CredentialResolver.cpp @@ -26,8 +26,8 @@ using namespace xmltooling; namespace xmltooling { - XMLTOOL_DLLLOCAL PluginManager::Factory FilesystemCredentialResolverFactory; - XMLTOOL_DLLLOCAL PluginManager::Factory ChainingCredentialResolverFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory FilesystemCredentialResolverFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory ChainingCredentialResolverFactory; }; void XMLTOOL_API xmltooling::registerCredentialResolvers() diff --git a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp index 346c35f..0cdb78a 100644 --- a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp +++ b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp @@ -40,6 +40,8 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + namespace xmltooling { class XMLTOOL_DLLLOCAL ExplicitKeyTrustEngine : public SignatureTrustEngine, public OpenSSLTrustEngine { diff --git a/xmltooling/security/impl/FilesystemCredentialResolver.cpp b/xmltooling/security/impl/FilesystemCredentialResolver.cpp index 0bd090a..d995180 100644 --- a/xmltooling/security/impl/FilesystemCredentialResolver.cpp +++ b/xmltooling/security/impl/FilesystemCredentialResolver.cpp @@ -43,6 +43,10 @@ using namespace xmltooling::logging; using namespace xmltooling; using namespace std; +using xercesc::DOMElement; +using xercesc::chLatin_f; +using xercesc::chDigit_0; + namespace xmltooling { // The ManagedResource classes handle memory management, loading of the files diff --git a/xmltooling/security/impl/InlineKeyResolver.cpp b/xmltooling/security/impl/InlineKeyResolver.cpp index 130c754..4dba33f 100644 --- a/xmltooling/security/impl/InlineKeyResolver.cpp +++ b/xmltooling/security/impl/InlineKeyResolver.cpp @@ -44,6 +44,7 @@ using namespace xmlsignature; using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; namespace xmltooling { diff --git a/xmltooling/security/impl/KeyInfoResolver.cpp b/xmltooling/security/impl/KeyInfoResolver.cpp index 6b182f8..8e28538 100644 --- a/xmltooling/security/impl/KeyInfoResolver.cpp +++ b/xmltooling/security/impl/KeyInfoResolver.cpp @@ -30,7 +30,7 @@ using namespace xmltooling; using namespace std; namespace xmltooling { - XMLTOOL_DLLLOCAL PluginManager::Factory InlineKeyInfoResolverFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory InlineKeyInfoResolverFactory; }; void XMLTOOL_API xmltooling::registerKeyInfoResolvers() diff --git a/xmltooling/security/impl/TrustEngine.cpp b/xmltooling/security/impl/TrustEngine.cpp index 0052b13..1c67741 100644 --- a/xmltooling/security/impl/TrustEngine.cpp +++ b/xmltooling/security/impl/TrustEngine.cpp @@ -30,6 +30,8 @@ using namespace xmltooling; using namespace std; +using xercesc::DOMElement; + namespace xmltooling { XMLTOOL_DLLLOCAL PluginManager::Factory ExplicitKeyTrustEngineFactory; XMLTOOL_DLLLOCAL PluginManager::Factory StaticPKIXTrustEngineFactory; diff --git a/xmltooling/signature/impl/KeyInfoImpl.cpp b/xmltooling/signature/impl/KeyInfoImpl.cpp index 1f59137..9505365 100644 --- a/xmltooling/signature/impl/KeyInfoImpl.cpp +++ b/xmltooling/signature/impl/KeyInfoImpl.cpp @@ -33,6 +33,7 @@ using namespace xmlsignature; using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::XMLSIG_NS; @@ -52,7 +53,7 @@ namespace xmlsignature { public: virtual ~DSAKeyValueImpl() {} - DSAKeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + DSAKeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -137,7 +138,7 @@ namespace xmlsignature { public: virtual ~RSAKeyValueImpl() {} - RSAKeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + RSAKeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -182,7 +183,7 @@ namespace xmlsignature { public: virtual ~KeyValueImpl() {} - KeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + KeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -244,7 +245,7 @@ namespace xmlsignature { XMLString::release(&m_Algorithm); } - TransformImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + TransformImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Algorithm(NULL) { } @@ -301,7 +302,7 @@ namespace xmlsignature { public: virtual ~TransformsImpl() {} - TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -337,7 +338,7 @@ namespace xmlsignature { XMLString::release(&m_Type); } - RetrievalMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + RetrievalMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -390,7 +391,7 @@ namespace xmlsignature { public: virtual ~X509IssuerSerialImpl() {} - X509IssuerSerialImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + X509IssuerSerialImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -435,7 +436,7 @@ namespace xmlsignature { public: virtual ~X509DataImpl() {} - X509DataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + X509DataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -514,7 +515,7 @@ namespace xmlsignature { public: virtual ~SPKIDataImpl() {} - SPKIDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + SPKIDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -578,7 +579,7 @@ namespace xmlsignature { public: virtual ~PGPDataImpl() {} - PGPDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + PGPDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -637,7 +638,7 @@ namespace xmlsignature { XMLString::release(&m_Id); } - KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Id(NULL) { } diff --git a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp index da8eb1a..f3072c6 100644 --- a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp +++ b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp @@ -47,6 +47,7 @@ using namespace xmlsignature; using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::XMLSIG_NS; using xmlconstants::XMLSIG_PREFIX; @@ -432,7 +433,7 @@ Signature* XMLObject* #endif SignatureBuilder::buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType ) const { if (!XMLString::equals(nsURI,XMLSIG_NS) || !XMLString::equals(localName,Signature::LOCAL_NAME)) diff --git a/xmltooling/soap/impl/SOAPClient.cpp b/xmltooling/soap/impl/SOAPClient.cpp index 7cf17f6..fb0ff52 100644 --- a/xmltooling/soap/impl/SOAPClient.cpp +++ b/xmltooling/soap/impl/SOAPClient.cpp @@ -33,6 +33,7 @@ using namespace soap11; using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; void SOAPTransport::send(istream* in) @@ -129,7 +130,7 @@ Envelope* SOAPClient::receive() bool SOAPClient::handleFault(const Fault& fault) { - const QName* code = (fault.getFaultcode() ? fault.getFaultcode()->getCode() : NULL); + const xmltooling::QName* code = (fault.getFaultcode() ? fault.getFaultcode()->getCode() : NULL); auto_ptr_char str((fault.getFaultstring() ? fault.getFaultstring()->getString() : NULL)); Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient").error( "SOAP client detected a Fault: (%s) (%s)", diff --git a/xmltooling/soap/impl/SOAPImpl.cpp b/xmltooling/soap/impl/SOAPImpl.cpp index f7f13b4..c635f30 100644 --- a/xmltooling/soap/impl/SOAPImpl.cpp +++ b/xmltooling/soap/impl/SOAPImpl.cpp @@ -34,6 +34,7 @@ using namespace soap11; using namespace xmltooling; +using namespace xercesc; using namespace std; using xmlconstants::SOAP11ENV_NS; using xmlconstants::SOAP11ENV_PREFIX; @@ -54,13 +55,13 @@ namespace { public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { - QName* m_qname; + xmltooling::QName* m_qname; public: virtual ~FaultcodeImpl() { delete m_qname; } - FaultcodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + FaultcodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) { } @@ -69,11 +70,11 @@ namespace { setCode(src.getCode()); } - const QName* getCode() const { + const xmltooling::QName* getCode() const { return m_qname; } - void setCode(const QName* qname) { + void setCode(const xmltooling::QName* qname) { m_qname=prepareForAssignment(m_qname,qname); if (m_qname) { auto_ptr_XMLCh temp(m_qname->toString().c_str()); @@ -96,7 +97,7 @@ namespace { public: virtual ~DetailImpl() {} - DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -158,7 +159,7 @@ namespace { public: virtual ~FaultImpl() {} - FaultImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + FaultImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -203,7 +204,7 @@ namespace { virtual ~BodyImpl() { } - BodyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + BodyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -245,7 +246,7 @@ namespace { virtual ~HeaderImpl() { } - HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } @@ -295,7 +296,7 @@ namespace { public: virtual ~EnvelopeImpl() {} - EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType) : AbstractXMLObject(nsURI, localName, prefix, schemaType) { init(); } @@ -370,7 +371,7 @@ static const XMLCh _SERVER[] = UNICODE_LITERAL_6(S,e,r, static const XMLCh _MUSTUNDERSTAND[] = UNICODE_LITERAL_14(M,u,s,t,U,n,d,e,r,s,t,a,n,d); static const XMLCh _VERSIONMISMATCH[] = UNICODE_LITERAL_15(V,e,r,s,i,o,n,M,i,s,m,a,t,c,h); -QName Faultcode::CLIENT(SOAP11ENV_NS,_CLIENT,SOAP11ENV_PREFIX); -QName Faultcode::SERVER(SOAP11ENV_NS,_SERVER,SOAP11ENV_PREFIX); -QName Faultcode::MUSTUNDERSTAND(SOAP11ENV_NS,_MUSTUNDERSTAND,SOAP11ENV_PREFIX); -QName Faultcode::VERSIONMISMATCH(SOAP11ENV_NS,_VERSIONMISMATCH,SOAP11ENV_PREFIX); +xmltooling::QName Faultcode::CLIENT(SOAP11ENV_NS,_CLIENT,SOAP11ENV_PREFIX); +xmltooling::QName Faultcode::SERVER(SOAP11ENV_NS,_SERVER,SOAP11ENV_PREFIX); +xmltooling::QName Faultcode::MUSTUNDERSTAND(SOAP11ENV_NS,_MUSTUNDERSTAND,SOAP11ENV_PREFIX); +xmltooling::QName Faultcode::VERSIONMISMATCH(SOAP11ENV_NS,_VERSIONMISMATCH,SOAP11ENV_PREFIX); diff --git a/xmltooling/unicode.cpp b/xmltooling/unicode.cpp index b8deeb3..dc0774c 100644 --- a/xmltooling/unicode.cpp +++ b/xmltooling/unicode.cpp @@ -26,12 +26,14 @@ #include #include +using namespace xercesc; + static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull }; char* xmltooling::toUTF8(const XMLCh* src, bool use_malloc) { - unsigned int eaten,factor=1,bufsize; - unsigned int srclen=XMLString::stringLen(src); + xsecsize_t eaten,factor=1,bufsize; + xsecsize_t srclen=XMLString::stringLen(src); XMLUTF8Transcoder t(UTF8, 4096); // block size isn't used any more anyway do { bufsize = factor*srclen + 10; @@ -63,8 +65,8 @@ char* xmltooling::toUTF8(const XMLCh* src, bool use_malloc) XMLCh* xmltooling::fromUTF8(const char* src, bool use_malloc) { - unsigned int eaten; - unsigned int srclen=strlen(src); + xsecsize_t eaten; + xsecsize_t srclen=strlen(src); XMLUTF8Transcoder t(UTF8, 4096); // block size isn't used any more anyway XMLCh* buf = use_malloc ? reinterpret_cast(malloc((srclen+1)*sizeof(XMLCh))) : new XMLCh[srclen + 1]; unsigned char* sizes=new unsigned char[srclen]; diff --git a/xmltooling/util/CurlNetAccessor.cpp b/xmltooling/util/CurlNetAccessor.cpp index e09ffe5..1774259 100644 --- a/xmltooling/util/CurlNetAccessor.cpp +++ b/xmltooling/util/CurlNetAccessor.cpp @@ -29,6 +29,7 @@ #include using namespace xmltooling; +using namespace xercesc; const XMLCh xmltooling::CurlNetAccessor::fgMyName[] = { diff --git a/xmltooling/util/CurlNetAccessor.hpp b/xmltooling/util/CurlNetAccessor.hpp index a1ff700..72ab0dd 100644 --- a/xmltooling/util/CurlNetAccessor.hpp +++ b/xmltooling/util/CurlNetAccessor.hpp @@ -37,13 +37,13 @@ namespace xmltooling { // a HTTP or FTP URL. // -class XMLTOOL_API CurlNetAccessor : public XMLNetAccessor +class XMLTOOL_API CurlNetAccessor : public xercesc::XMLNetAccessor { public : CurlNetAccessor(); ~CurlNetAccessor(); - virtual BinInputStream* makeNew(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo=0); + virtual xercesc::BinInputStream* makeNew(const xercesc::XMLURL& urlSource, const xercesc::XMLNetHTTPInfo* httpInfo=0); virtual const XMLCh* getId() const; private : diff --git a/xmltooling/util/CurlURLInputStream.cpp b/xmltooling/util/CurlURLInputStream.cpp index 532d318..fc716c1 100644 --- a/xmltooling/util/CurlURLInputStream.cpp +++ b/xmltooling/util/CurlURLInputStream.cpp @@ -36,7 +36,7 @@ #include using namespace xmltooling; - +using namespace xercesc; CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/) : fMemoryManager(urlSource.getMemoryManager()) @@ -64,7 +64,7 @@ size_t CurlURLInputStream::staticWriteCallback(void* ptr, size_t size, size_t nm } -unsigned int CurlURLInputStream::readBytes(XMLByte* const toFill, const unsigned int maxToRead) +xsecsize_t CurlURLInputStream::readBytes(XMLByte* const toFill, const xsecsize_t maxToRead) { if (!fInputStream) { // Allocate the curl easy handle. diff --git a/xmltooling/util/CurlURLInputStream.hpp b/xmltooling/util/CurlURLInputStream.hpp index cd6106a..9b708c1 100644 --- a/xmltooling/util/CurlURLInputStream.hpp +++ b/xmltooling/util/CurlURLInputStream.hpp @@ -40,14 +40,25 @@ namespace xmltooling { // parser. // -class XMLTOOL_API CurlURLInputStream : public BinInputStream +class XMLTOOL_API CurlURLInputStream : public xercesc::BinInputStream { public : - CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo=0); + CurlURLInputStream(const xercesc::XMLURL& urlSource, const xercesc::XMLNetHTTPInfo* httpInfo=0); ~CurlURLInputStream(); - unsigned int curPos() const; - unsigned int readBytes(XMLByte* const toFill, const unsigned int maxToRead); +#ifdef XMLTOOLING_XERCESC_64BITSAFE + XMLFilePos +#else + unsigned int +#endif + curPos() const; + xsecsize_t readBytes(XMLByte* const toFill, const xsecsize_t maxToRead); + +#ifdef XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE + const XMLCh* getContentType() const { + return NULL; + } +#endif private : // ----------------------------------------------------------------------- @@ -58,17 +69,23 @@ private : static size_t staticWriteCallback(void* ptr, size_t size, size_t nmemb, void* stream); - std::stringstream fUnderlyingStream; - MemoryManager* fMemoryManager; - XMLURL fURLSource; - ArrayJanitor fURL; + std::stringstream fUnderlyingStream; + xercesc::MemoryManager* fMemoryManager; + xercesc::XMLURL fURLSource; + xercesc::ArrayJanitor fURL; StreamInputSource::StreamBinInputStream* fInputStream; logging::Category& m_log; }; // CurlURLInputStream -inline unsigned int CurlURLInputStream::curPos() const +inline +#ifdef XMLTOOLING_XERCESC_64BITSAFE + XMLFilePos +#else + unsigned int +#endif +CurlURLInputStream::curPos() const { return fInputStream ? fInputStream->curPos() : 0; } diff --git a/xmltooling/util/DateTime.cpp b/xmltooling/util/DateTime.cpp index e5cb42c..ffe55cf 100644 --- a/xmltooling/util/DateTime.cpp +++ b/xmltooling/util/DateTime.cpp @@ -39,6 +39,7 @@ #include using namespace xmltooling; +using namespace xercesc; using namespace std; // @@ -1479,7 +1480,7 @@ void DateTime::fillString(XMLCh*& ptr, valueIndex ind, int expLen) const XMLCh strBuffer[16]; assert(expLen < 16); XMLString::binToText(fValue[ind], strBuffer, expLen, 10); - int actualLen = XMLString::stringLen(strBuffer); + int actualLen = (int) XMLString::stringLen(strBuffer); int i; //append leading zeros for (i = 0; i < expLen - actualLen; i++) @@ -1499,7 +1500,7 @@ int DateTime::fillYearString(XMLCh*& ptr, valueIndex ind) const XMLCh strBuffer[16]; // let's hope we get no years of 15 digits... XMLString::binToText(fValue[ind], strBuffer, 15, 10); - int actualLen = XMLString::stringLen(strBuffer); + int actualLen = (int) XMLString::stringLen(strBuffer); // don't forget that years can be negative... int negativeYear = 0; if(strBuffer[0] == chDash) diff --git a/xmltooling/util/DateTime.h b/xmltooling/util/DateTime.h index f73e244..b3fa78f 100644 --- a/xmltooling/util/DateTime.h +++ b/xmltooling/util/DateTime.h @@ -161,7 +161,7 @@ namespace xmltooling inline void DateTime::setBuffer(const XMLCh* const aString) { reset(); - fEnd = xercesc::XMLString::stringLen(aString); + fEnd = (int) xercesc::XMLString::stringLen(aString); if (fEnd > 0) { if (fEnd > fBufferMaxLen) { delete[] fBuffer; diff --git a/xmltooling/util/ParserPool.cpp b/xmltooling/util/ParserPool.cpp index 17133b3..abe019c 100644 --- a/xmltooling/util/ParserPool.cpp +++ b/xmltooling/util/ParserPool.cpp @@ -40,6 +40,7 @@ using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; ParserPool::ParserPool(bool namespaceAware, bool schemaAware) @@ -60,13 +61,26 @@ DOMDocument* ParserPool::newDocument() return DOMImplementationRegistry::getDOMImplementation(NULL)->createDocument(); } -DOMDocument* ParserPool::parse(DOMInputSource& domsrc) +DOMDocument* ParserPool::parse( +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + DOMLSInput& domsrc + ) +{ + DOMLSParser* parser=checkoutBuilder(); + XercesJanitor janitor(parser); + try { + DOMDocument* doc=parser->parse(&domsrc); + parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument,true); +#else + DOMInputSource& domsrc + ) { DOMBuilder* parser=checkoutBuilder(); XercesJanitor janitor(parser); try { DOMDocument* doc=parser->parse(domsrc); parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument,true); +#endif checkinBuilder(janitor.release()); return doc; } @@ -208,7 +222,19 @@ bool ParserPool::loadCatalog(const XMLCh* pathname) return true; } -DOMInputSource* ParserPool::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI) +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS +DOMLSInput* ParserPool::resolveResource( + const XMLCh *const resourceType, + const XMLCh *const namespaceUri, + const XMLCh *const publicId, + const XMLCh *const systemId, + const XMLCh *const baseURI + ) +#else +DOMInputSource* ParserPool::resolveEntity( + const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI + ) +#endif { #if _DEBUG xmltooling::NDC ndc("resolveEntity"); @@ -299,6 +325,10 @@ bool ParserPool::handleError(const DOMError& e) throw XMLParserException(string("unclassified error during XML parsing: ") + (temp.get() ? temp.get() : "no message")); } +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + +#else + DOMBuilder* ParserPool::createBuilder() { static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull }; @@ -356,10 +386,12 @@ void ParserPool::checkinBuilder(DOMBuilder* builder) } } -unsigned int StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const toFill, const unsigned int maxToRead) +#endif + +xsecsize_t StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const toFill, const xsecsize_t maxToRead) { XMLByte* target=toFill; - unsigned int bytes_read=0,request=maxToRead; + xsecsize_t bytes_read=0,request=maxToRead; // Fulfill the rest by reading from the stream. if (request && !m_is.eof() && !m_is.fail()) { diff --git a/xmltooling/util/ParserPool.h b/xmltooling/util/ParserPool.h index 3dcdde6..248645d 100644 --- a/xmltooling/util/ParserPool.h +++ b/xmltooling/util/ParserPool.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2008 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /** * @file xmltooling/util/ParserPool.h * - * A thread-safe pool of DOMBuilders that share characteristics. + * A thread-safe pool of parsers that share characteristics. */ #ifndef __xmltooling_pool_h__ @@ -34,6 +34,10 @@ #include #include +#ifndef XMLTOOLING_NO_XMLSEC +# include +#endif + #if defined (_MSC_VER) #pragma warning( push ) #pragma warning( disable : 4250 4251 ) @@ -44,7 +48,12 @@ namespace xmltooling { /** * A thread-safe pool of DOMBuilders that share characteristics. */ - class XMLTOOL_API ParserPool : public xercesc::DOMEntityResolver, xercesc::DOMErrorHandler + class XMLTOOL_API ParserPool : xercesc::DOMErrorHandler, +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + public xercesc::DOMLSResourceResolver +#else + public xercesc::DOMEntityResolver +#endif { MAKE_NONCOPYABLE(ParserPool); public: @@ -68,11 +77,17 @@ namespace xmltooling { /** * Parses a document using a pooled parser with the proper settings * - * @param domsrc A DOM source containing the content to be parsed + * @param domsrc An input source containing the content to be parsed * @return The DOM document resulting from the parse * @throws XMLParserException thrown if there was a problem reading, parsing, or validating the XML */ - xercesc::DOMDocument* parse(xercesc::DOMInputSource& domsrc); + xercesc::DOMDocument* parse( +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + xercesc::DOMLSInput& domsrc +#else + xercesc::DOMInputSource& domsrc +#endif + ); /** * Parses a document using a pooled parser with the proper settings @@ -109,7 +124,19 @@ namespace xmltooling { /** * Supplies all external entities (primarily schemas) to the parser */ - xercesc::DOMInputSource* resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI); +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + xercesc::DOMLSInput* resolveResource( + const XMLCh *const resourceType, + const XMLCh *const namespaceUri, + const XMLCh *const publicId, + const XMLCh *const systemId, + const XMLCh *const baseURI + ); +#else + xercesc::DOMInputSource* resolveEntity( + const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI + ); +#endif /** * Handles parsing errors @@ -117,9 +144,15 @@ namespace xmltooling { bool handleError(const xercesc::DOMError& e); private: +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + xercesc::DOMLSParser* createBuilder(); + xercesc::DOMLSParser* checkoutBuilder(); + void checkinBuilder(xercesc::DOMLSParser* builder); +#else xercesc::DOMBuilder* createBuilder(); xercesc::DOMBuilder* checkoutBuilder(); void checkinBuilder(xercesc::DOMBuilder* builder); +#endif #ifdef HAVE_GOOD_STL xstring m_schemaLocations; @@ -129,7 +162,11 @@ namespace xmltooling { std::map m_schemaLocMap; #endif bool m_namespaceAware,m_schemaAware; +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + std::stack m_pool; +#else std::stack m_pool; +#endif Mutex* m_lock; xercesc::SecurityManager* m_security; }; @@ -161,16 +198,24 @@ namespace xmltooling { /** * Constructs a Xerces input stream around a C++ input stream reference. * - * @param is reference to an input stream + * @param is reference to an input stream */ StreamBinInputStream(std::istream& is) : m_is(is), m_pos(0) {} /// @cond off - virtual unsigned int curPos() const { return m_pos; } - virtual unsigned int readBytes(XMLByte* const toFill, const unsigned int maxToRead); +#ifdef XMLTOOLING_XERCESC_64BITSAFE + XMLFilePos +#else + unsigned int +#endif + curPos() const { return m_pos; } + xsecsize_t readBytes(XMLByte* const toFill, const xsecsize_t maxToRead); +#ifdef XMLTOOLING_XERCESC_64BITSAFE + const XMLCh* getContentType() const { return NULL; } +#endif /// @endcond private: std::istream& m_is; - unsigned int m_pos; + xsecsize_t m_pos; }; private: diff --git a/xmltooling/util/ReloadableXMLFile.cpp b/xmltooling/util/ReloadableXMLFile.cpp index 172b813..ad43f6f 100644 --- a/xmltooling/util/ReloadableXMLFile.cpp +++ b/xmltooling/util/ReloadableXMLFile.cpp @@ -38,6 +38,7 @@ using namespace xmltooling::logging; using namespace xmltooling; +using namespace xercesc; using namespace std; static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i); diff --git a/xmltooling/util/StorageService.cpp b/xmltooling/util/StorageService.cpp index b5b5782..7b6717a 100644 --- a/xmltooling/util/StorageService.cpp +++ b/xmltooling/util/StorageService.cpp @@ -27,7 +27,7 @@ using namespace xmltooling; using namespace std; namespace xmltooling { - XMLTOOL_DLLLOCAL PluginManager::Factory MemoryStorageServiceFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory MemoryStorageServiceFactory; }; void XMLTOOL_API xmltooling::registerStorageServices() diff --git a/xmltooling/util/XMLConstants.cpp b/xmltooling/util/XMLConstants.cpp index 8796aea..94ea5dc 100644 --- a/xmltooling/util/XMLConstants.cpp +++ b/xmltooling/util/XMLConstants.cpp @@ -25,6 +25,8 @@ #include "util/XMLConstants.h" #include +using namespace xercesc; + const XMLCh xmlconstants::XML_NS[] = // http://www.w3.org/XML/1998/namespace { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash, diff --git a/xmltooling/util/XMLHelper.cpp b/xmltooling/util/XMLHelper.cpp index 7a68ef4..77f8d0f 100644 --- a/xmltooling/util/XMLHelper.cpp +++ b/xmltooling/util/XMLHelper.cpp @@ -29,6 +29,7 @@ #include using namespace xmltooling; +using namespace xercesc; using namespace std; static const XMLCh type[]={chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull }; @@ -44,7 +45,7 @@ bool XMLHelper::hasXSIType(const DOMElement* e) return false; } -QName* XMLHelper::getXSIType(const DOMElement* e) +xmltooling::QName* XMLHelper::getXSIType(const DOMElement* e) { DOMAttr* attribute = e->getAttributeNodeNS(xmlconstants::XSI_NS, type); if (attribute) { @@ -55,12 +56,12 @@ QName* XMLHelper::getXSIType(const DOMElement* e) XMLCh* prefix=new XMLCh[i+1]; XMLString::subString(prefix,attributeValue,0,i); prefix[i]=chNull; - QName* ret=new QName(e->lookupNamespaceURI(prefix), attributeValue + i + 1, prefix); + xmltooling::QName* ret=new xmltooling::QName(e->lookupNamespaceURI(prefix), attributeValue + i + 1, prefix); delete[] prefix; return ret; } else { - return new QName(e->lookupNamespaceURI(NULL), attributeValue); + return new xmltooling::QName(e->lookupNamespaceURI(NULL), attributeValue); } } } @@ -122,14 +123,14 @@ XMLObject* XMLHelper::getXMLObjectById(XMLObject& tree, const XMLCh* id) return NULL; } -QName* XMLHelper::getNodeQName(const DOMNode* domNode) +xmltooling::QName* XMLHelper::getNodeQName(const DOMNode* domNode) { if (domNode) - return new QName(domNode->getNamespaceURI(), domNode->getLocalName(), domNode->getPrefix()); + return new xmltooling::QName(domNode->getNamespaceURI(), domNode->getLocalName(), domNode->getPrefix()); return NULL; } -QName* XMLHelper::getAttributeValueAsQName(const DOMAttr* attribute) +xmltooling::QName* XMLHelper::getAttributeValueAsQName(const DOMAttr* attribute) { if (!attribute) return NULL; @@ -140,12 +141,12 @@ QName* XMLHelper::getAttributeValueAsQName(const DOMAttr* attribute) XMLCh* prefix=new XMLCh[i+1]; XMLString::subString(prefix,attributeValue,0,i); prefix[i]=chNull; - QName* ret=new QName(attribute->lookupNamespaceURI(prefix), attributeValue + i + 1, prefix); + xmltooling::QName* ret=new xmltooling::QName(attribute->lookupNamespaceURI(prefix), attributeValue + i + 1, prefix); delete[] prefix; return ret; } - return new QName(attribute->lookupNamespaceURI(NULL), attributeValue); + return new xmltooling::QName(attribute->lookupNamespaceURI(NULL), attributeValue); } DOMElement* XMLHelper::appendChildElement(DOMElement* parentElement, DOMElement* childElement) @@ -254,15 +255,31 @@ void XMLHelper::serialize(const DOMNode* n, std::string& buf, bool pretty) { static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull }; static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull }; + + MemBufFormatTarget target; DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype); - DOMWriter* serializer=(static_cast(impl))->createDOMWriter(); + +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + DOMLSSerializer* serializer = static_cast(impl)->createLSSerializer(); + XercesJanitor janitor(serializer); + if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) + serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); + DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); + XercesJanitor j_theOutput(theOutput); + theOutput->setEncoding(UTF8); + theOutput->setByteStream(&target); + if (!serializer->write(n, theOutput)) + throw XMLParserException("unable to serialize XML"); +#else + DOMWriter* serializer = static_cast(impl)->createDOMWriter(); XercesJanitor janitor(serializer); serializer->setEncoding(UTF8); if (pretty && serializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) serializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); - MemBufFormatTarget target; - if (!serializer->writeNode(&target,*n)) + if (!serializer->writeNode(&target, *n)) throw XMLParserException("unable to serialize XML"); +#endif + buf.erase(); buf.append(reinterpret_cast(target.getRawBuffer()),target.getLen()); } @@ -274,7 +291,7 @@ namespace { StreamFormatTarget(std::ostream& out) : m_out(out) {} ~StreamFormatTarget() {} - void writeChars(const XMLByte *const toWrite, const unsigned int count, XMLFormatter *const formatter) { + void writeChars(const XMLByte *const toWrite, const xsecsize_t count, XMLFormatter *const formatter) { m_out.write(reinterpret_cast(toWrite),count); } @@ -291,15 +308,31 @@ ostream& XMLHelper::serialize(const DOMNode* n, ostream& out, bool pretty) { static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull }; static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull }; + + StreamFormatTarget target(out); DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype); + +#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS + DOMLSSerializer* serializer = static_cast(impl)->createLSSerializer(); + XercesJanitor janitor(serializer); + if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) + serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); + DOMLSOutput *theOutput = static_cast(impl)->createLSOutput(); + XercesJanitor j_theOutput(theOutput); + theOutput->setEncoding(UTF8); + theOutput->setByteStream(&target); + if (!serializer->write(n, theOutput)) + throw XMLParserException("unable to serialize XML"); +#else DOMWriter* serializer=(static_cast(impl))->createDOMWriter(); XercesJanitor janitor(serializer); serializer->setEncoding(UTF8); if (pretty && serializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, pretty)) serializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, pretty); - StreamFormatTarget target(out); if (!serializer->writeNode(&target,*n)) throw XMLParserException("unable to serialize XML"); +#endif + return out; } diff --git a/xmltooling/xmltooling-lite.vcproj b/xmltooling/xmltooling-lite.vcproj index 572ee95..e15d999 100644 --- a/xmltooling/xmltooling-lite.vcproj +++ b/xmltooling/xmltooling-lite.vcproj @@ -66,7 +66,7 @@ /> @@ -452,7 +452,7 @@ > @@ -461,7 +461,7 @@ > @@ -470,7 +470,7 @@ > -- 2.1.4