std::for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());\r
}\r
\r
-AbstractXMLObject::AbstractXMLObject(const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix)\r
- : m_elementQname(namespaceURI,elementLocalName, namespacePrefix), m_typeQname(NULL), m_parent(NULL),\r
+AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)\r
+ : m_elementQname(nsURI, localName, prefix), m_typeQname(NULL), m_parent(NULL),\r
m_log(&log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject"))\r
{\r
- addNamespace(Namespace(namespaceURI, namespacePrefix));\r
+ addNamespace(Namespace(nsURI, prefix));\r
+ if (schemaType) {\r
+ m_typeQname = new QName(*schemaType);\r
+ addNamespace(Namespace(m_typeQname->getNamespaceURI(), m_typeQname->getPrefix()));\r
+ }\r
}\r
\r
AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src)\r
return m_typeQname;\r
}\r
\r
- void setSchemaType(const QName* type) {\r
- delete m_typeQname;\r
- m_typeQname = NULL;\r
- if (type) {\r
- m_typeQname = new QName(*type);\r
- addNamespace(Namespace(type->getNamespaceURI(), type->getPrefix()));\r
- }\r
- }\r
- \r
bool hasParent() const {\r
return m_parent != NULL;\r
}\r
/**\r
* Constructor\r
* \r
- * @param namespaceURI the namespace the element is in\r
- * @param elementLocalName the local name of the XML element this Object represents\r
- * @param namespacePrefix the namespace prefix to use\r
+ * @param nsURI the namespace of the element\r
+ * @param localName the local name of the XML element this Object represents\r
+ * @param prefix the namespace prefix to use\r
+ * @param schemaType the xsi:type to use\r
*/\r
- AbstractXMLObject(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL);\r
+ AbstractXMLObject(\r
+ const XMLCh* nsURI=NULL, const XMLCh* localName=NULL, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
+ );\r
\r
/** Copy constructor. */\r
AbstractXMLObject(const AbstractXMLObject& src);\r
virtual const QName* getSchemaType() const=0;\r
\r
/**\r
- * Sets the XML schema type of this element. This translates to contents the xsi:type\r
- * attribute for the element.\r
- * \r
- * @param type XML schema type of this element\r
- */\r
- virtual void setSchemaType(const QName* type)=0;\r
- \r
- /**\r
* Checks to see if this object has a parent.\r
* \r
* @return true if the object has a parent, false if not\r
#include <map>
#include <xmltooling/QName.h>
#include <xmltooling/XMLObject.h>
+#include <xmltooling/util/XMLHelper.h>
#if defined (_MSC_VER)
#pragma warning( push )
/**
* Creates an empty XMLObject with a particular element name.
- * The results are undefined if elementLocalName is NULL or empty.
+ * The results are undefined if localName is NULL or empty.
*
- * @param namespaceURI namespace URI for element
- * @param elementLocalName local name of element
- * @param namespacePrefix prefix of element name
+ * @param nsURI namespace URI for element
+ * @param localName local name of element
+ * @param prefix prefix of element name
+ * @param schemaType xsi:type of the object
* @return the empty XMLObject
*/
virtual XMLObject* buildObject(
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL
) const=0;
/**
* @return the unmarshalled XMLObject
*/
XMLObject* buildFromElement(DOMElement* element, bool bindDocument=false) const {
- std::auto_ptr<XMLObject> ret(buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix()));
+ std::auto_ptr<XMLObject> ret(
+ buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element))
+ );
ret->unmarshall(element,bindDocument);
return ret.release();
}
#define BEGIN_XMLOBJECTBUILDERIMPL(cname,namespaceURI) \
class XMLTOOL_DLLLOCAL cname##BuilderImpl : public cname##Builder { \
public: \
- cname* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const; \
+ cname* buildObject( \
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\
+ ) const; \
cname* buildObject() const { \
return buildObject(namespaceURI,cname::LOCAL_NAME,cname::PREFIX); \
}
public:
virtual ~AnyElementImpl() {}
- AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)
- : AbstractXMLObject(nsURI, localName, prefix) {}
+ AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL)
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
AnyElementImpl* clone() const {
auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
XMLObject* AnyElementBuilder::buildObject(
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType
) const {
- return new AnyElementImpl(namespaceURI,elementLocalName,namespacePrefix);
+ return new AnyElementImpl(nsURI, localName, prefix, schemaType);
}
{
public:
XMLObject* buildObject(
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL
) const;
};
{\r
public:\r
XMLObject* buildObject(\r
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL\r
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
) const {\r
- return new UnknownElementImpl(namespaceURI,elementLocalName,namespacePrefix);\r
+ return new UnknownElementImpl(nsURI,localName,prefix);\r
}\r
};\r
\r
}\r
}\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
- setSchemaType(xsitype.get());\r
+ XT_log.debug("skipping xsi:type declaration");\r
continue;\r
}\r
else if (nsuri && !XMLString::equals(nsuri,XMLConstants::XML_NS)) {\r
public:\r
virtual ~KeyInfoImpl() {}\r
\r
- KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)\r
- : AbstractXMLObject(nsURI, localName, prefix), m_Id(NULL) {}\r
+ KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)\r
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Id(NULL) {}\r
\r
KeyInfoImpl(const KeyInfoImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),\r
AbstractElementProxy(src), AbstractValidatingXMLObject(src), m_Id(XMLString::replicate(src.m_Id)) {\r
#pragma warning( pop )\r
#endif\r
\r
-KeyInfo* KeyInfoBuilderImpl::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+KeyInfo* KeyInfoBuilderImpl::buildObject(\r
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType\r
+ ) const\r
{\r
- return new KeyInfoImpl(ns,name,prefix);\r
+ return new KeyInfoImpl(nsURI,localName,prefix,schemaType);\r
}\r
return this;\r
}\r
\r
-Signature* XMLSecSignatureBuilder::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+Signature* XMLSecSignatureBuilder::buildObject(\r
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType\r
+ ) const\r
{\r
- if (!XMLString::equals(ns,XMLConstants::XMLSIG_NS) || !XMLString::equals(name,Signature::LOCAL_NAME))\r
+ if (!XMLString::equals(nsURI,XMLConstants::XMLSIG_NS) || !XMLString::equals(localName,Signature::LOCAL_NAME))\r
throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
return buildObject();\r
}\r
class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public SignatureBuilder\r
{\r
public:\r
- Signature* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const;\r
+ Signature* buildObject(\r
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
+ ) const;\r
Signature* buildObject() const;\r
};\r
\r
kids.erase(kids.begin()+1);\r
TS_ASSERT_SAME_DATA(kids.back()->getValue(), bar.get(), XMLString::stringLen(bar.get()));\r
\r
- kids.push_back(b->buildObject(SimpleXMLObject::NAMESPACE,SimpleXMLObject::DERIVED_NAME,SimpleXMLObject::NAMESPACE_PREFIX));\r
- kids.back()->setSchemaType(&m_qtype);\r
+ kids.push_back(b->buildObject(SimpleXMLObject::NAMESPACE,SimpleXMLObject::DERIVED_NAME,SimpleXMLObject::NAMESPACE_PREFIX,&m_qtype));\r
kids.back()->setValue(baz.get());\r
\r
DOMElement* rootElement = sxObject->marshall();\r
static const XMLCh ID_ATTRIB_NAME[];
SimpleXMLObject(
- const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL
- ) : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix), m_id(NULL), m_value(NULL) {
+ const XMLCh* nsURI=NULL, const XMLCh* localName=NULL, const XMLCh* prefix=NULL, const QName* schemaType=NULL
+ ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL), m_value(NULL) {
#ifndef XMLTOOLING_NO_XMLSEC
m_children.push_back(NULL);
m_signature=m_children.begin();
}
SimpleXMLObject* buildObject(
- const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL
) const {
- return new SimpleXMLObject(namespaceURI,elementLocalName,namespacePrefix);
+ return new SimpleXMLObject(nsURI, localName, prefix, schemaType);
}
};