*/
#define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
+ static cname* new##cname() { \
+ const cname##Builder* b = dynamic_cast<const cname##Builder*>( \
+ XMLObjectBuilder::getBuilder(xmltooling::QName(namespaceURI,cname::LOCAL_NAME)) \
+ ); \
+ if (b) \
+ return b->buildObject(); \
+ throw xmltooling::XMLObjectException("Unable to obtain typed builder for "#cname"."); \
+ } \
END_XMLOBJECTBUILDER
/**
#include <xmltooling/XMLObjectBuilder.h>\r
#include <xmltooling/signature/SigningContext.h>\r
#include <xmltooling/signature/VerifyingContext.h>\r
+#include <xmltooling/util/XMLConstants.h>\r
\r
/**\r
* @namespace xmlsignature\r
* @return empty Signature object\r
*/\r
virtual Signature* buildObject() const;\r
+\r
+ static Signature* newSignature() {\r
+ const SignatureBuilder* b = dynamic_cast<const SignatureBuilder*>(\r
+ xmltooling::XMLObjectBuilder::getBuilder(\r
+ xmltooling::QName(xmltooling::XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME)\r
+ )\r
+ );\r
+ if (b)\r
+ return b->buildObject();\r
+ throw xmltooling::XMLObjectException("Unable to obtain typed builder for Signature.");\r
+ }\r
};\r
\r
DECL_XMLTOOLING_EXCEPTION(SignatureException,xmlsignature,xmltooling::XMLToolingException,Exceptions in signature processing);\r
TS_TRACE("testMarshallingWithAttributes");\r
\r
QName qname(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME);\r
- const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));\r
- auto_ptr<SimpleXMLObject> sxObject(b->buildObject());\r
+ auto_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::newSimpleXMLObject());\r
TS_ASSERT(sxObject.get()!=NULL);\r
auto_ptr_XMLCh expected("Firefly");\r
sxObject->setId(expected.get());\r
TS_TRACE("testMarshallingWithElementContent");\r
\r
QName qname(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME);\r
- const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));\r
- auto_ptr<SimpleXMLObject> sxObject(b->buildObject());\r
+ auto_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::newSimpleXMLObject());\r
TS_ASSERT(sxObject.get()!=NULL);\r
auto_ptr_XMLCh expected("Sample Content");\r
sxObject->setValue(expected.get());\r
kids[1]->setValue(bar.get());\r
\r
// Append a Signature.\r
- const SignatureBuilder* sigb=dynamic_cast<const SignatureBuilder*>(XMLObjectBuilder::getBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME)));\r
- Signature* sig=sigb->buildObject();\r
+ Signature* sig=SignatureBuilder::newSignature();\r
sxObject->setSignature(sig);\r
\r
// Signing context for the whole document.\r
) const {
return new SimpleXMLObject(nsURI, localName, prefix, schemaType);
}
+
+ static SimpleXMLObject* newSimpleXMLObject() {\r
+ const SimpleXMLObjectBuilder* b = dynamic_cast<const SimpleXMLObjectBuilder*>(\r
+ XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME))\r
+ );\r
+ if (b)\r
+ return b->buildObject();\r
+ throw XMLObjectException("Unable to obtain typed builder for SimpleXMLObject.");\r
+ }\r
};
#if defined (_MSC_VER)