Lookup should be by XMLObject.
authorScott Cantor <cantor.2@osu.edu>
Wed, 22 Feb 2006 18:02:18 +0000 (18:02 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 22 Feb 2006 18:02:18 +0000 (18:02 +0000)
xmltooling/io/Marshaller.cpp
xmltooling/io/Marshaller.h

index fe7424e..ed4e03f 100644 (file)
@@ -35,32 +35,31 @@ map<QName,Marshaller*> Marshaller::m_map;
 \r
 Marshaller* Marshaller::m_default=NULL;\r
 \r
-const Marshaller* Marshaller::getMarshaller(const DOMElement* domElement)\r
+const Marshaller* Marshaller::getMarshaller(const XMLObject* xmlObject)\r
 {\r
 #ifdef _DEBUG\r
     xmltooling::NDC ndc("getMarshaller");\r
 #endif\r
     Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Marshaller");\r
  \r
-    auto_ptr<QName> schemaType(XMLHelper::getXSIType(domElement));\r
-    const Marshaller* m = getMarshaller(*(schemaType.get()));\r
+    const QName* type=xmlObject->getSchemaType();\r
+    const Marshaller* m = type ? getMarshaller(*type) : NULL;\r
     if (m) {\r
         if (log.isDebugEnabled()) {\r
-            log.debug("Located Marshaller for schema type: %s", schemaType->toString().c_str());\r
+            log.debug("located Marshaller for schema type: %s", type->toString().c_str());\r
         }\r
         return m;\r
     }\r
     \r
-    auto_ptr<QName> elementName(XMLHelper::getNodeQName(domElement));\r
-    m = getMarshaller(*(elementName.get()));\r
+    m = getMarshaller(xmlObject->getElementQName());\r
     if (m) {\r
         if (log.isDebugEnabled()) {\r
-            log.debug("Located Marshaller for element name: %s", elementName->toString().c_str());\r
+            log.debug("located Marshaller for element name: %s", xmlObject->getElementQName().toString().c_str());\r
         }\r
         return m;\r
     }\r
 \r
-    log.error("No Marshaller was registered for element: %s", elementName->toString().c_str());\r
+    log.error("no Marshaller registered for element: %s", xmlObject->getElementQName().toString().c_str());\r
     return NULL;\r
 }\r
 \r
index fffc484..989796b 100644 (file)
@@ -58,7 +58,7 @@ namespace xmltooling {
          * \r
          * @throws MarshallingException thrown if there is a problem marshalling the given object\r
          */\r
-        virtual DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document) const=0;\r
+        virtual DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL) const=0;\r
 \r
         /**\r
          * Retrieves a Marshaller using the key it was registered with.\r
@@ -72,12 +72,12 @@ namespace xmltooling {
         }\r
 \r
         /**\r
-         * Retrieves a Marshaller for a DOM element\r
+         * Retrieves a Marshaller for an XML object\r
          * \r
-         * @param element the element for which to return a marshaller\r
+         * @param xmlObject the object for which to return a marshaller\r
          * @return the marshaller or NULL\r
          */\r
-        static const Marshaller* getMarshaller(const DOMElement* key);\r
+        static const Marshaller* getMarshaller(const XMLObject* xmlObject);\r
 \r
         /**\r
          * Retrieves default Marshaller for DOM elements\r