aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml/dom/elements.txx
blob: c49367632a63f614340ef17c40d1687d1954506f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// file      : xsd/cxx/xml/dom/elements.txx
// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#include <xsd/cxx/xml/string.hxx>

namespace xsd
{
  namespace cxx
  {
    namespace xml
    {
      namespace dom
      {
        template <typename C>
        qualified_name<C>
        name (const xercesc::DOMAttr& a)
        {
          const XMLCh* n (a.getLocalName ());

          // If this DOM doesn't support namespaces then use getName.
          //
          if (n != 0)
          {
            if (const XMLCh* ns = a.getNamespaceURI ())
              return qualified_name<C> (transcode<C> (n), transcode<C> (ns));
            else
              return qualified_name<C> (transcode<C> (n));
          }
          else
            return qualified_name<C> (transcode<C> (a.getName ()));
        }


        template <typename C>
        qualified_name<C>
        name (const xercesc::DOMElement& e)
        {
          const XMLCh* n (e.getLocalName ());

          // If this DOM doesn't support namespaces then use getTagName.
          //
          if (n != 0)
          {
            if (const XMLCh* ns = e.getNamespaceURI ())
              return qualified_name<C> (transcode<C> (n), transcode<C> (ns));
            else
              return qualified_name<C> (transcode<C> (n));
          }
          else
            return qualified_name<C> (transcode<C> (e.getTagName ()));
        }
      }
    }
  }
}