<item id="org.eclipse.cdt.core.pathentry">\r
<pathentry include="C:/log4cpp-0.3.5rc1/include" kind="inc" path="" system="true"/>\r
<pathentry include="C:/xerces-c2_7_0-win32/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/xml-security-c-1.2.0/include" kind="inc" path="" system="true"/>\r
+<pathentry include="C:/cxxtest" kind="inc" path="" system="true"/>\r
<pathentry base-path="XMLTooling-C" include="" kind="inc" path="" system="true"/>\r
<pathentry base-path="XMLTooling-C" include="xmltooling" kind="inc" path="" system="true"/>\r
<pathentry kind="mac" name="_MSC_VER" path="" value=""/>\r
-<pathentry kind="src" path=""/>\r
+<pathentry kind="mac" name="WIN32" path="" value=""/>\r
<pathentry kind="out" path=""/>\r
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>\r
+<pathentry excluding="util/|io/|impl/" kind="src" path="xmltooling"/>\r
+<pathentry kind="src" path="xmltooling/util"/>\r
+<pathentry kind="src" path="xmltooling/io"/>\r
+<pathentry kind="src" path="xmltooling/impl"/>\r
+<pathentry kind="src" path="xmltoolingtest"/>\r
</item>\r
</data>\r
</cdtproject>\r
# Simulated Subversion default ignores end here
# The contents of the svn:ignore property on the branch root.
/debug
+/*.ncb
+/*.suo
+/release
# Visual Studio 2005\r
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmltooling", "xmltooling\xmltooling.vcproj", "{06B55A46-D3B3-41AE-B5A5-B57830BA010D}"\r
EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xmltoolingtest", "xmltoolingtest\xmltoolingtest.vcproj", "{3E34CDCC-FCBA-490D-A165-1CB6F4559799}"\r
+ ProjectSection(ProjectDependencies) = postProject\r
+ {06B55A46-D3B3-41AE-B5A5-B57830BA010D} = {06B55A46-D3B3-41AE-B5A5-B57830BA010D}\r
+ EndProjectSection\r
+EndProject\r
Global\r
GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
Debug|Win32 = Debug|Win32\r
{06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Debug|Win32.Build.0 = Debug|Win32\r
{06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Release|Win32.ActiveCfg = Release|Win32\r
{06B55A46-D3B3-41AE-B5A5-B57830BA010D}.Release|Win32.Build.0 = Release|Win32\r
+ {3E34CDCC-FCBA-490D-A165-1CB6F4559799}.Debug|Win32.ActiveCfg = Debug|Win32\r
+ {3E34CDCC-FCBA-490D-A165-1CB6F4559799}.Debug|Win32.Build.0 = Debug|Win32\r
+ {3E34CDCC-FCBA-490D-A165-1CB6F4559799}.Release|Win32.ActiveCfg = Release|Win32\r
+ {3E34CDCC-FCBA-490D-A165-1CB6F4559799}.Release|Win32.Build.0 = Release|Win32\r
EndGlobalSection\r
GlobalSection(SolutionProperties) = preSolution\r
HideSolutionNode = FALSE\r
void AbstractDOMCachingXMLObject::releaseDOM()\r
{\r
Category& log=Category::getInstance(XMLTOOLING_LOGCAT".DOM");\r
- if (log.isDebugEnabled())\r
- log.debug("releasing cached DOM reprsentation for %s", getElementQName().toString().c_str());\r
+ if (log.isDebugEnabled()) {\r
+ string qname=getElementQName().toString();\r
+ log.debug("releasing cached DOM representation for (%s)", qname.empty() ? "unknown" : qname.c_str());\r
+ }\r
setDOM(NULL);\r
}\r
\r
void AbstractDOMCachingXMLObject::releaseParentDOM(bool propagateRelease)\r
{\r
- Category& log=Category::getInstance(XMLTOOLING_LOGCAT".DOM");\r
- if (log.isDebugEnabled()) {\r
- log.debug(\r
- "releasing cached DOM representation for parent of %s with propagation set to %s",\r
- getElementQName().toString().c_str(), propagateRelease ? "true" : "false"\r
- );\r
- }\r
-\r
DOMCachingXMLObject* domCachingParent = dynamic_cast<DOMCachingXMLObject*>(getParent());\r
if (domCachingParent) {\r
+ Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
+ "releasing cached DOM representation for parent object with propagation set to %s",\r
+ propagateRelease ? "true" : "false"\r
+ );\r
domCachingParent->releaseDOM();\r
if (propagateRelease)\r
domCachingParent->releaseParentDOM(propagateRelease);\r
\r
void AbstractDOMCachingXMLObject::releaseChildrenDOM(bool propagateRelease)\r
{\r
- Category& log=Category::getInstance(XMLTOOLING_LOGCAT".DOM");\r
- if (log.isDebugEnabled()) {\r
- log.debug(\r
- "releasing cached DOM representation for children of %s with propagation set to %s",\r
- getElementQName().toString().c_str(), propagateRelease ? "true" : "false"\r
- );\r
- }\r
- \r
vector<XMLObject*> children;\r
- if (getOrderedChildren(children))\r
+ if (getOrderedChildren(children)) {\r
+ Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
+ "releasing cached DOM representation for children with propagation set to %s",\r
+ propagateRelease ? "true" : "false"\r
+ );\r
for_each(children.begin(),children.end(),bind2nd(_release(),propagateRelease));\r
+ }\r
}\r
\r
XMLObject* AbstractDOMCachingXMLObject::prepareForAssignment(const XMLObject* oldValue, XMLObject* newValue) {\r
\r
if (newValue && newValue->hasParent())\r
- throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
+ throw XMLObjectException("Child XMLObject cannot be added - it is already the child of another XMLObject");\r
\r
if (!oldValue) {\r
if (newValue) {\r
* @param namespaceURI the namespace the element is in\r
* @param elementLocalName the local name of the XML element this Object represents\r
*/\r
- AbstractDOMCachingXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName)\r
- : AbstractXMLObject(namespaceURI,elementLocalName), m_dom(NULL), m_document(NULL) {}\r
+ AbstractDOMCachingXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix)\r
+ : AbstractXMLObject(namespaceURI,elementLocalName, namespacePrefix), m_dom(NULL), m_document(NULL) {}\r
\r
private:\r
DOMElement* m_dom;\r
* @see XMLObject::addNamespace()\r
*/\r
void addNamespace(const Namespace& ns) {\r
- m_namespaces.insert(ns);\r
+ if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) {\r
+ m_namespaces.insert(ns);\r
+ }\r
}\r
\r
/**\r
* @param namespaceURI the namespace the element is in\r
* @param elementLocalName the local name of the XML element this Object represents\r
*/\r
- AbstractXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName)\r
- : m_elementQname(namespaceURI,elementLocalName), m_typeQname(NULL), m_parent(NULL) {}\r
+ AbstractXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix)\r
+ : m_elementQname(namespaceURI,elementLocalName, namespacePrefix), m_typeQname(NULL), m_parent(NULL) {\r
+ addNamespace(Namespace(namespaceURI, namespacePrefix));\r
+ }\r
\r
private:\r
XMLObject* m_parent;\r
\r
using namespace xmltooling;\r
\r
-Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix)\r
+Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix, bool alwaysDeclare) : m_pinned(alwaysDeclare)\r
{\r
#ifndef HAVE_GOOD_STL\r
m_uri=m_prefix=NULL;\r
{\r
m_uri=XMLString::replicate(src.getNamespaceURI());\r
m_prefix=XMLString::replicate(src.getNamespacePrefix());\r
+ m_pinned=src.getAlwaysDeclare();\r
}\r
\r
Namespace& Namespace::operator=(const Namespace& src)\r
{\r
m_uri=XMLString::replicate(src.getNamespaceURI());\r
m_prefix=XMLString::replicate(src.getNamespacePrefix());\r
+ m_pinned=src.getAlwaysDeclare();\r
return *this;\r
}\r
\r
bool xmltooling::operator==(const Namespace& op1, const Namespace& op2)\r
{\r
- return (!XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI()) &&\r
- !XMLString::compareString(op1.getNamespacePrefix(),op2.getNamespacePrefix()));\r
+ return (XMLString::equals(op1.getNamespaceURI(),op2.getNamespaceURI()) &&\r
+ XMLString::equals(op1.getNamespacePrefix(),op2.getNamespacePrefix()));\r
}\r
#endif\r
\r
public:\r
/**\r
* Constructor\r
- * @param uri namespace URI\r
- * @param prefix namespace prefix (without the colon)\r
+ * @param uri namespace URI\r
+ * @param prefix namespace prefix (without the colon)\r
+ * @param alwaysDeclare true iff the namespace should always be declared regardless of in-scope declarations\r
*/\r
- Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL);\r
+ Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL, bool alwaysDeclare=false);\r
\r
~Namespace();\r
#ifndef HAVE_GOOD_STL\r
#endif\r
\r
/**\r
+ * Returns true iff the namespace should always be declared regardless of in-scope declarations\r
+ * @return the alwaysDeclared setting\r
+ */\r
+ const bool alwaysDeclare() const { return m_pinned; } \r
+\r
+ /**\r
* Sets the namespace prefix\r
* @param prefix Null-terminated Unicode string containing the prefix, without the colon\r
*/\r
* @param uri Null-terminated Unicode string containing the URI\r
*/\r
void setNamespaceURI(const XMLCh* uri);\r
+\r
+ /**\r
+ * Sets the alwaysDeclared property\r
+ * @param alwaysDeclare true iff the namespace should always be declared regardless of in-scope declarations\r
+ */\r
+ void setAlwaysDeclare(bool alwaysDeclare) { m_pinned = alwaysDeclare; } \r
\r
private:\r
+ bool m_pinned;\r
#ifdef HAVE_GOOD_STL\r
xstring m_uri;\r
xstring m_prefix;\r
\r
string QName::toString() const\r
{\r
- if (!getLocalPart())\r
+ if (!hasLocalPart())\r
return "";\r
auto_ptr_char local(getLocalPart());\r
- if (getPrefix()) {\r
+ if (hasPrefix()) {\r
auto_ptr_char pre(getPrefix());\r
return string(pre.get()) + ':' + local.get(); \r
}\r
- else if (getNamespaceURI()) {\r
+ else if (hasNamespaceURI()) {\r
auto_ptr_char ns(getNamespaceURI());\r
return string("{") + ns.get() + '}' + local.get(); \r
}\r
\r
#ifdef HAVE_GOOD_STL\r
/**\r
+ * Indicates whether the QName has a prefix.\r
+ * @return true iff the prefix is non-empty\r
+ */\r
+ bool hasPrefix() const { return !m_prefix.empty(); }\r
+\r
+ /**\r
+ * Indicates whether the QName has a non-empty namespace.\r
+ * @return true iff the namespace is non-empty\r
+ */\r
+ bool hasNamespaceURI() const { return !m_uri.empty(); }\r
+\r
+ /**\r
+ * Indicates whether the QName has a non-empty local name.\r
+ * @return true iff the local name is non-empty\r
+ */\r
+ bool hasLocalPart() const { return !m_local.empty(); }\r
+\r
+ /**\r
* Returns the namespace prefix\r
* @return Null-terminated Unicode string containing the prefix, without the colon\r
*/\r
const XMLCh* getLocalPart() const { return m_local.c_str(); }\r
#else\r
/**\r
+ * Indicates whether the QName has a prefix.\r
+ * @return true iff the prefix is non-empty\r
+ */\r
+ bool hasPrefix() const { return m_prefix && *m_prefix; }\r
+\r
+ /**\r
+ * Indicates whether the QName has a non-empty namespace.\r
+ * @return true iff the namespace is non-empty\r
+ */\r
+ bool hasNamespaceURI() const { return m_uri && *m_uri; }\r
+\r
+ /**\r
+ * Indicates whether the QName has a non-empty local name.\r
+ * @return true iff the local name is non-empty\r
+ */\r
+ bool hasLocalPart() const { return m_local && *m_local; }\r
+\r
+ /**\r
* Returns the namespace prefix\r
* @return Null-terminated Unicode string containing the prefix, without the colon\r
*/\r
return xmlObjectBuilder;\r
}\r
\r
- log.error("no XMLObjectBuilder registered for element (%s), using default", elementName->toString().c_str());\r
+ if (log.isDebugEnabled()) {\r
+ log.debug("no XMLObjectBuilder registered for element (%s), returning default", elementName->toString().c_str());\r
+ }\r
return m_default;\r
}\r
\r
#include "exceptions.h"\r
#include "impl/UnknownElement.h"\r
#include "util/NDC.h"\r
+#include "util/XMLHelper.h"\r
\r
#include <log4cpp/Category.hh>\r
-#include <xercesc/framework/MemBufFormatTarget.hpp>\r
#include <xercesc/framework/MemBufInputSource.hpp>\r
#include <xercesc/framework/Wrapper4InputSource.hpp>\r
#include <xercesc/util/XMLUniDefs.hpp>\r
\r
void UnknownElementImpl::serialize(string& s) const\r
{\r
- if (getDOM()) {\r
- static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull };\r
- static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull };\r
- DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype);\r
- DOMWriter* serializer=(static_cast<DOMImplementationLS*>(impl))->createDOMWriter();\r
- serializer->setEncoding(UTF8);\r
- try {\r
- MemBufFormatTarget target;\r
- if (!serializer->writeNode(&target,*(getDOM())))\r
- throw XMLObjectException("unable to serialize XML to preserve DOM");\r
- s.erase();\r
- s.append(reinterpret_cast<const char*>(target.getRawBuffer()),target.getLen());\r
- serializer->release();\r
- }\r
- catch (...) {\r
- serializer->release();\r
- throw;\r
- }\r
- }\r
+ if (getDOM())\r
+ XMLHelper::serialize(getDOM(),s);\r
}\r
\r
DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMDocument* document) const\r
if (cachedDOM) {\r
if (!document || document==cachedDOM->getOwnerDocument()) {\r
log.debug("XMLObject has a usable cached DOM, reusing it");\r
- setDocumentElement(cachedDOM->getOwnerDocument(),cachedDOM);\r
+ if (document)\r
+ setDocumentElement(cachedDOM->getOwnerDocument(),cachedDOM);\r
unk->releaseParentDOM(true);\r
return cachedDOM;\r
}\r
{\r
public:\r
UnknownElementImpl() {}\r
+ virtual ~UnknownElementImpl() {}\r
\r
/**\r
* Overridden to ensure XML content of DOM isn't lost.\r
if (cachedDOM) {\r
if (!document || document==cachedDOM->getOwnerDocument()) {\r
XT_log.debug("XMLObject has a usable cached DOM, reusing it");\r
- setDocumentElement(cachedDOM->getOwnerDocument(),cachedDOM);\r
+ if (document)\r
+ setDocumentElement(cachedDOM->getOwnerDocument(),cachedDOM);\r
dc->releaseParentDOM(true);\r
return cachedDOM;\r
}\r
void AbstractXMLObjectMarshaller::marshallInto(XMLObject* xmlObject, DOMElement* targetElement) const\r
{\r
targetElement->setPrefix(xmlObject->getElementQName().getPrefix());\r
+ marshallElementType(xmlObject, targetElement);\r
marshallNamespaces(xmlObject, targetElement);\r
marshallAttributes(xmlObject, targetElement);\r
marshallChildElements(xmlObject, targetElement);\r
marshallElementContent(xmlObject, targetElement);\r
- marshallElementType(xmlObject, targetElement);\r
\r
/* TODO Signing/Encryption\r
if (xmlObject instanceof SignableXMLObject) {\r
void operator()(DOMElement* domElement, const Namespace& ns) const {\r
const XMLCh* prefix=ns.getNamespacePrefix();\r
const XMLCh* uri=ns.getNamespaceURI();\r
+ \r
+ // Check to see if the prefix is already declared properly above this node.\r
+ if (!ns.alwaysDeclare() && domElement->getParentNode() &&\r
+ XMLString::equals(domElement->getParentNode()->lookupNamespaceURI(prefix),uri))\r
+ return;\r
+ \r
if (prefix && *prefix) {\r
XMLCh* xmlns=new XMLCh[XMLString::stringLen(XMLConstants::XMLNS_PREFIX) + XMLString::stringLen(prefix) + 2*sizeof(XMLCh)];\r
*xmlns=chNull;\r
);\r
throw MarshallingException("Marshaller found unknown child element, but no default marshaller was found.");\r
}\r
- element->appendChild(marshaller->marshall(obj, element->getOwnerDocument()));\r
+ element->appendChild(marshaller->marshall(obj, element));\r
}\r
};\r
\r
attribute = static_cast<DOMAttr*>(childNode);\r
\r
const XMLCh* nsuri=attribute->getNamespaceURI();\r
- if (!XMLString::compareString(nsuri,XMLConstants::XMLNS_NS)) {\r
+ if (XMLString::equals(nsuri,XMLConstants::XMLNS_NS)) {\r
XT_log.debug("found namespace declaration, adding it to the list of namespaces on the XMLObject");\r
- xmlObject->addNamespace(Namespace(attribute->getValue(), attribute->getLocalName()));\r
+ xmlObject->addNamespace(Namespace(attribute->getValue(), attribute->getLocalName(), true));\r
continue;\r
}\r
- else if (!XMLString::compareString(nsuri,XMLConstants::XSI_NS) &&\r
- !XMLString::compareString(attribute->getLocalName(),type)) {\r
+ else if (XMLString::equals(nsuri,XMLConstants::XSI_NS) && XMLString::equals(attribute->getLocalName(),type)) {\r
XT_log.debug("found xsi:type declaration, setting the schema type of the XMLObject");\r
auto_ptr<QName> xsitype(XMLHelper::getAttributeValueAsQName(attribute));\r
xmlObject->setSchemaType(xsitype.get());\r
continue;\r
}\r
+ else if (nsuri) {\r
+ XT_log.debug("found namespace-qualified attribute, adding prefix to the list of namespaces on the XMLObject");\r
+ xmlObject->addNamespace(Namespace(nsuri, attribute->getPrefix()));\r
+ }\r
\r
XT_log.debug("processing generic attribute");\r
processAttribute(xmlObject, attribute);\r
}\r
return m;\r
}\r
-\r
- log.error("no Marshaller registered for element (%s), returning default", xmlObject->getElementQName().toString().c_str());\r
+ if (log.isDebugEnabled()) {\r
+ string qname=xmlObject->getElementQName().toString().c_str();\r
+ log.debug("no Marshaller registered for element (%s), returning default", qname.empty() ? "unknown" : qname.c_str());\r
+ }\r
return m_default;\r
}\r
\r
return m;\r
}\r
\r
- log.error("no Unmarshaller registered for element (%s), using default", elementName->toString().c_str());\r
+ if (log.isDebugEnabled()) {\r
+ log.debug("no Unmarshaller registered for element (%s), returning default", elementName->toString().c_str());\r
+ }\r
return m_default;\r
}\r
\r
*/\r
\r
#include "internal.h"\r
+#include "exceptions.h"\r
#include "util/XMLHelper.h"\r
#include "util/XMLConstants.h"\r
\r
+#include <xercesc/framework/MemBufFormatTarget.hpp>\r
#include <xercesc/util/XMLUniDefs.hpp>\r
\r
using namespace xmltooling;\r
parentElement->appendChild(childElement);\r
return childElement;\r
}\r
+\r
+void XMLHelper::serialize(const DOMElement* e, std::string& buf)\r
+{\r
+ static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull };\r
+ static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull };\r
+ DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype);\r
+ DOMWriter* serializer=(static_cast<DOMImplementationLS*>(impl))->createDOMWriter();\r
+ serializer->setEncoding(UTF8);\r
+ try {\r
+ MemBufFormatTarget target;\r
+ if (!serializer->writeNode(&target,*e))\r
+ throw XMLParserException("unable to serialize XML");\r
+ buf.erase();\r
+ buf.append(reinterpret_cast<const char*>(target.getRawBuffer()),target.getLen());\r
+ serializer->release();\r
+ }\r
+ catch (...) {\r
+ serializer->release();\r
+ throw;\r
+ }\r
+}\r
* @return true iff the element's qualified name matches the other parameters\r
*/\r
static bool isElementNamed(const DOMElement* e, const XMLCh* ns, const XMLCh* local) {\r
- return (e && !XMLString::compareString(ns,e->getNamespaceURI()) && !XMLString::compareString(local,e->getLocalName()));\r
+ return (e && XMLString::equals(ns,e->getNamespaceURI()) && XMLString::equals(local,e->getLocalName()));\r
}\r
+\r
+ /**\r
+ * Serializes the DOM Element provided into a buffer using UTF-8 encoding and\r
+ * the default XML serializer available. No manipulation or formatting is applied.\r
+ * \r
+ * @param e element to serialize\r
+ * @param buf buffer to serialize element into\r
+ */\r
+ static void serialize(const DOMElement* e, std::string& buf);\r
};\r
\r
};\r
--- /dev/null
+/Debug
+/*.user
+/*.cpp
+/Release
--- /dev/null
+/*\r
+ * Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "XMLObjectBaseTestCase.h"\r
+\r
+#include <fstream>\r
+#include <xmltooling/io/Marshaller.h>\r
+#include <xmltooling/io/Unmarshaller.h>\r
+\r
+\r
+class UnknownTest : public CxxTest::TestSuite {\r
+public:\r
+\r
+ void testUnknown() {\r
+ ifstream fs("../xmltoolingtest/data/SimpleXMLObjectWithChildren.xml");\r
+ DOMDocument* doc=nonvalidatingPool->parse(fs);\r
+ TS_ASSERT(doc!=NULL);\r
+\r
+ string buf1;\r
+ XMLHelper::serialize(doc->getDocumentElement(), buf1);\r
+\r
+ const Unmarshaller* u=Unmarshaller::getUnmarshaller(doc->getDocumentElement());\r
+ TS_ASSERT(u!=NULL);\r
+\r
+ auto_ptr<XMLObject> xmlObject(u->unmarshall(doc->getDocumentElement(),true)); // bind document\r
+ TS_ASSERT(xmlObject.get()!=NULL);\r
+\r
+ auto_ptr<XMLObject> clonedObject(xmlObject->clone());\r
+ TS_ASSERT(clonedObject.get()!=NULL);\r
+\r
+ const Marshaller* m=Marshaller::getMarshaller(clonedObject.get());\r
+ TS_ASSERT(m!=NULL);\r
+\r
+ DOMElement* rootElement=m->marshall(clonedObject.get());\r
+ TS_ASSERT(rootElement!=NULL);\r
+\r
+ rootElement=m->marshall(clonedObject.get()); // should reuse DOM\r
+ TS_ASSERT(rootElement!=NULL);\r
+\r
+ string buf2;\r
+ XMLHelper::serialize(rootElement, buf2);\r
+ TS_ASSERT_EQUALS(buf1,buf2);\r
+ }\r
+\r
+ void testUnknownWithDocChange() {\r
+ ifstream fs("../xmltoolingtest/data/SimpleXMLObjectWithChildren.xml");\r
+ DOMDocument* doc=nonvalidatingPool->parse(fs);\r
+ TS_ASSERT(doc!=NULL);\r
+\r
+ string buf1;\r
+ XMLHelper::serialize(doc->getDocumentElement(), buf1);\r
+\r
+ const Unmarshaller* u=Unmarshaller::getUnmarshaller(doc->getDocumentElement());\r
+ TS_ASSERT(u!=NULL);\r
+\r
+ auto_ptr<XMLObject> xmlObject(u->unmarshall(doc->getDocumentElement(),true)); // bind document\r
+ TS_ASSERT(xmlObject.get()!=NULL);\r
+\r
+ const Marshaller* m=Marshaller::getMarshaller(xmlObject.get());\r
+ TS_ASSERT(m!=NULL);\r
+\r
+ DOMDocument* newDoc=nonvalidatingPool->newDocument();\r
+ DOMElement* rootElement=m->marshall(xmlObject.get(), newDoc);\r
+ TS_ASSERT(rootElement!=NULL);\r
+\r
+ string buf2;\r
+ XMLHelper::serialize(rootElement, buf2);\r
+ TS_ASSERT_EQUALS(buf1,buf2);\r
+\r
+ newDoc->release();\r
+ }\r
+};\r
--- /dev/null
+/*\r
+ * Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <cxxtest/TestSuite.h>\r
+#include <xmltooling/XMLToolingConfig.h>\r
+#include <xmltooling/util/ParserPool.h>\r
+#include <xmltooling/util/XMLHelper.h>\r
+\r
+using namespace xmltooling;\r
+using namespace std;\r
+\r
+extern ParserPool* validatingPool;\r
+extern ParserPool* nonvalidatingPool;\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+ <uri name="http://www.w3.org/XML/1998/namespace" uri="../schemas/xml.xsd"/>
+ <uri name="http://www.w3.org/2001/04/xmlenc#" uri="../schemas/xenc-schema.xsd"/>
+ <uri name="http://www.w3.org/2000/09/xmldsig#" uri="../schemas/xmldsig-core-schema.xsd"/>
+</catalog>
--- /dev/null
+/*\r
+ * Copyright 2001-2005 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <cxxtest/TestSuite.h>\r
+#include <cxxtest/GlobalFixture.h>\r
+\r
+#include <xmltooling/XMLToolingConfig.h>\r
+#include <xmltooling/util/ParserPool.h>\r
+\r
+using namespace xmltooling;\r
+\r
+ParserPool* validatingPool=NULL;\r
+ParserPool* nonvalidatingPool=NULL;\r
+\r
+class ToolingFixture : public CxxTest::GlobalFixture\r
+{\r
+public:\r
+ bool setUpWorld() {\r
+ XMLToolingConfig::getConfig().log_config("DEBUG");\r
+ if (!XMLToolingConfig::getConfig().init())\r
+ return false;\r
+ validatingPool = new ParserPool(true,true);\r
+ nonvalidatingPool = new ParserPool();\r
+ return true;\r
+ }\r
+ bool tearDownWorld() {\r
+ delete validatingPool;\r
+ delete nonvalidatingPool;\r
+ XMLToolingConfig::getConfig().term();\r
+#if defined(_MSC_VER ) && defined(XMLTOOLINGTEST_LEAKCHECK)\r
+ _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );\r
+ _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );\r
+ _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );\r
+ _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );\r
+ _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );\r
+ _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );\r
+ _CrtDumpMemoryLeaks();\r
+#endif\r
+ return true;\r
+ }\r
+ //bool setUp() { printf( "</test>" ); return true; }\r
+ //bool tearDown() { printf( "</test>" ); return true; }\r
+};\r
+\r
+static ToolingFixture globalFixture;\r
+\r
+class CatalogTest : public CxxTest::TestSuite\r
+{\r
+public:\r
+ void testCatalog(void) {\r
+ auto_ptr_XMLCh temp("../xmltoolingtest/data/catalog.xml");\r
+ TS_ASSERT(validatingPool->loadCatalog(temp.get()));\r
+ }\r
+};\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="8.00"\r
+ Name="xmltoolingtest"\r
+ ProjectGUID="{3E34CDCC-FCBA-490D-A165-1CB6F4559799}"\r
+ RootNamespace="xmltoolingtest"\r
+ Keyword="Win32Proj"\r
+ >\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"\r
+ />\r
+ </Platforms>\r
+ <ToolFiles>\r
+ </ToolFiles>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Debug|Win32"\r
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+ IntermediateDirectory="$(ConfigurationName)"\r
+ ConfigurationType="1"\r
+ CharacterSet="2"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ AdditionalIncludeDirectories=".."\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+ MinimalRebuild="true"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="3"\r
+ UsePrecompiledHeader="0"\r
+ BrowseInformation="1"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="4"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="xerces-c_2D.lib"\r
+ LinkIncremental="2"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="1"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+ IntermediateDirectory="$(ConfigurationName)"\r
+ ConfigurationType="1"\r
+ CharacterSet="2"\r
+ WholeProgramOptimization="1"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ AdditionalIncludeDirectories=".."\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+ RuntimeLibrary="2"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="3"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="xerces-c_2.lib"\r
+ LinkIncremental="1"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="1"\r
+ OptimizeReferences="2"\r
+ EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Generated Code"\r
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+ >\r
+ <File\r
+ RelativePath=".\UnknownTest.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\xmltoolingtest.cpp"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Unit Tests"\r
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+ >\r
+ <File\r
+ RelativePath=".\UnknownTest.h"\r
+ >\r
+ <FileConfiguration\r
+ Name="Debug|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "$(InputName)".cpp "$(InputPath)""\r
+ Outputs=""$(InputName)".cpp"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "$(InputName)".cpp "$(InputPath)""\r
+ Outputs=""$(InputName)".cpp"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath=".\xmltoolingtest.h"\r
+ >\r
+ <FileConfiguration\r
+ Name="Debug|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --error-printer --have-eh --have-std --abort-on-fail -o "$(InputName)".cpp "$(InputPath)"
"\r
+ Outputs="$(InputName).cpp"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --error-printer --have-eh --have-std --abort-on-fail -o "$(InputName)".cpp "$(InputPath)"
"\r
+ Outputs=""$(InputName)".cpp"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ </Filter>\r
+ <File\r
+ RelativePath=".\XMLObjectBaseTestCase.h"\r
+ >\r
+ </File>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r