#include <xercesc/util/XMLUniDefs.hpp>
using namespace xmltooling;
+using namespace xercesc;
using namespace std;
static const XMLCh type[]={chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull };
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) {
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);
}
}
}
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;
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)
{
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<DOMImplementationLS*>(impl))->createDOMWriter();
+
+#ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS
+ DOMLSSerializer* serializer = static_cast<DOMImplementationLS*>(impl)->createLSSerializer();
+ XercesJanitor<DOMLSSerializer> janitor(serializer);
+ if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty))
+ serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty);
+ DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();\r
+ XercesJanitor<DOMLSOutput> j_theOutput(theOutput);\r
+ theOutput->setEncoding(UTF8);\r
+ theOutput->setByteStream(&target);
+ if (!serializer->write(n, theOutput))
+ throw XMLParserException("unable to serialize XML");
+#else
+ DOMWriter* serializer = static_cast<DOMImplementationLS*>(impl)->createDOMWriter();
XercesJanitor<DOMWriter> 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<const char*>(target.getRawBuffer()),target.getLen());
}
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<const char*>(toWrite),count);
}
{
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<DOMImplementationLS*>(impl)->createLSSerializer();
+ XercesJanitor<DOMLSSerializer> janitor(serializer);
+ if (pretty && serializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty))
+ serializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, pretty);
+ DOMLSOutput *theOutput = static_cast<DOMImplementationLS*>(impl)->createLSOutput();\r
+ XercesJanitor<DOMLSOutput> j_theOutput(theOutput);\r
+ theOutput->setEncoding(UTF8);\r
+ theOutput->setByteStream(&target);
+ if (!serializer->write(n, theOutput))
+ throw XMLParserException("unable to serialize XML");
+#else
DOMWriter* serializer=(static_cast<DOMImplementationLS*>(impl))->createDOMWriter();
XercesJanitor<DOMWriter> 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;
}