aboutsummaryrefslogtreecommitdiff
path: root/xsd-frontend/xml.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-01-08 14:04:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-01-08 14:04:58 +0200
commit448760cbdb8f1ee1f3eb3559c7b05e7a61e37a88 (patch)
tree02c404a950281d7af209ee3f786e8abe13d4565f /xsd-frontend/xml.hxx
parent4bbabb3f78ab943c1fecbed08b1920db9609bc34 (diff)
Resolve namespace for default/fixed values of QName type
Diffstat (limited to 'xsd-frontend/xml.hxx')
-rw-r--r--xsd-frontend/xml.hxx42
1 files changed, 33 insertions, 9 deletions
diff --git a/xsd-frontend/xml.hxx b/xsd-frontend/xml.hxx
index ed7d181..8c9b01c 100644
--- a/xsd-frontend/xml.hxx
+++ b/xsd-frontend/xml.hxx
@@ -6,13 +6,15 @@
#ifndef XSD_FRONTEND_XML_HXX
#define XSD_FRONTEND_XML_HXX
-#include <xsd-frontend/types.hxx>
-#include <xsd-frontend/schema-dom-parser.hxx>
+#include <ostream>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
-#include <ostream>
+#include <cult/containers/vector.hxx>
+
+#include <xsd-frontend/types.hxx>
+#include <xsd-frontend/schema-dom-parser.hxx>
namespace XSDFrontend
{
@@ -172,7 +174,7 @@ namespace XSDFrontend
~XMLChString ()
{
- Xerces::XMLString::release (&s_);
+ delete[] s_;
}
XMLCh const*
@@ -339,7 +341,7 @@ namespace XSDFrontend
// Throws NoMapping if there is no prefix-namespace association.
//
inline String
- ns_name (Element const& e, String const& prefix)
+ ns_name (Xerces::DOMElement const* e, String const& prefix)
{
// 'xml' prefix requires special handling and Xerces folks refuse
// to handle this in DOM so I have to do it myself.
@@ -350,7 +352,7 @@ namespace XSDFrontend
// 0 means "no prefix" to Xerces.
//
XMLCh const* xns (
- e.dom_element ()->lookupNamespaceURI (
+ e->lookupNamespaceURI (
prefix.empty () ? 0 : XMLChString (prefix).c_str ()));
if (xns == 0)
@@ -362,8 +364,7 @@ namespace XSDFrontend
class NoPrefix {};
inline String
- ns_prefix (Element const& e,
- String const& wns)
+ ns_prefix (Element const& e, String const& wns)
{
XMLChString ns (wns);
@@ -403,7 +404,7 @@ namespace XSDFrontend
try
{
- String ns (ns_name (e, prefix (n)));
+ String ns (ns_name (e.dom_element (), prefix (n)));
return ns + L'#' + un;
}
catch (XML::NoMapping const&)
@@ -527,6 +528,29 @@ namespace XSDFrontend
private:
X* x_;
};
+
+ template <typename X>
+ struct PtrVector: Cult::Containers::Vector<X*>
+ {
+ typedef Cult::Containers::Vector<X*> Base;
+
+ ~PtrVector ()
+ {
+ for (typename Base::Iterator i (this->begin ()), e (this->end ());
+ i != e; ++i)
+ {
+ if (*i)
+ (*i)->release ();
+ }
+ }
+
+ Void
+ push_back (AutoPtr<X>& x)
+ {
+ Base::push_back (0);
+ this->back () = x.release ();
+ }
+ };
}
}