LCOV - code coverage report
Current view: top level - /usr/include/xsd/cxx/tree - parsing.txx (source / functions) Coverage Total Hit
Test: mu2edaq.info.cleaned Lines: 0.0 % 37 0
Test Date: 2026-07-30 01:56:44 Functions: 0.0 % 7 0

            Line data    Source code
       1              : // file      : xsd/cxx/tree/parsing.txx
       2              : // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
       3              : // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
       4              : 
       5              : #include <string>
       6              : 
       7              : #include <xsd/cxx/ro-string.hxx>         // trim
       8              : 
       9              : #include <xsd/cxx/xml/string.hxx>        // xml::{string, transcode}
      10              : #include <xsd/cxx/xml/elements.hxx>      // xml::{prefix, uq_name}
      11              : #include <xsd/cxx/xml/bits/literals.hxx> // xml::bits::{xml_prefix,
      12              :                                          //             xml_namespace}
      13              : 
      14              : #include <xsd/cxx/tree/exceptions.hxx>   // no_prefix_mapping
      15              : #include <xsd/cxx/tree/elements.hxx>
      16              : #include <xsd/cxx/tree/types.hxx>
      17              : #include <xsd/cxx/tree/list.hxx>
      18              : #include <xsd/cxx/tree/text.hxx>         // text_content
      19              : 
      20              : namespace xsd
      21              : {
      22              :   namespace cxx
      23              :   {
      24              :     namespace tree
      25              :     {
      26              :       // Note that most of the types implemented here (except string,
      27              :       // (normalizedString, and base64Binary) cannot have whitespaces
      28              :       // in the value. As result we don't need to waste time collapsing
      29              :       // whitespaces. All we need to do is trim the string representation
      30              :       // which can be done without copying.
      31              :       //
      32              : 
      33              :       // type
      34              :       //
      35            0 :       inline _type::
      36            0 :       _type (const xercesc::DOMElement& e, flags f, container* c)
      37            0 :           : container_ (c)
      38              :       {
      39            0 :         if (f & flags::extract_content)
      40            0 :           content_.reset (new dom_content_type (e));
      41              : 
      42            0 :         if (f & flags::keep_dom)
      43            0 :           dom_info_ = dom_info_factory::create (e, *this, c == 0);
      44            0 :       }
      45              : 
      46            0 :       inline _type::
      47            0 :       _type (const xercesc::DOMAttr& a, flags f, container* c)
      48            0 :           : container_ (c)
      49              :       {
      50              :         // anyType cannot be an attribute type so no content extraction.
      51              : 
      52            0 :         if (f & flags::keep_dom)
      53            0 :           dom_info_ = dom_info_factory::create (a, *this);
      54            0 :       }
      55              : 
      56              :       template <typename C>
      57              :       inline _type::
      58              :       _type (const std::basic_string<C>&,
      59              :              const xercesc::DOMElement*,
      60              :              flags,
      61              :              container* c)
      62              :           : container_ (c) // List elements don't have associated DOM nodes.
      63              :       {
      64              :         // anyType cannot be a list element type so no content extraction.
      65              :       }
      66              : 
      67              :       // simple_type
      68              :       //
      69              :       template <typename C, typename B>
      70            0 :       inline simple_type<C, B>::
      71              :       simple_type (const xercesc::DOMElement& e, flags f, container* c)
      72            0 :           : B (e, (f & ~flags::extract_content), c)
      73              :       {
      74            0 :         if (f & flags::extract_content)
      75            0 :           this->content_.reset (
      76            0 :             new text_content_type (tree::text_content<C> (e)));
      77            0 :       }
      78              : 
      79              :       template <typename C, typename B>
      80            0 :       inline simple_type<C, B>::
      81              :       simple_type (const xercesc::DOMAttr& a, flags f, container* c)
      82            0 :           : B (a, (f & ~flags::extract_content), c)
      83              :       {
      84            0 :         if (f & flags::extract_content)
      85            0 :           this->content_.reset (new text_content_type (
      86            0 :                             xml::transcode<C> (a.getValue ())));
      87            0 :       }
      88              : 
      89              :       template <typename C, typename B>
      90              :       inline simple_type<C, B>::
      91              :       simple_type (const std::basic_string<C>& s,
      92              :                    const xercesc::DOMElement* e,
      93              :                    flags f,
      94              :                    container* c)
      95              :           : B (s, e, (f & ~flags::extract_content), c)
      96              :       {
      97              :         if (f & flags::extract_content)
      98              :           this->content_.reset (new text_content_type (s));
      99              :       }
     100              : 
     101              :       // fundamental_base
     102              :       //
     103              :       template <typename T, typename C, typename B, schema_type::value ST>
     104              :       fundamental_base<T, C, B, ST>::
     105              :       fundamental_base (const xercesc::DOMElement& e, flags f, container* c)
     106              :           : B (e, f, c),
     107              :             facet_table_ (0),
     108              :             x_ (traits<T, C, ST>::create (e, f, c))
     109              :       {
     110              :       }
     111              : 
     112              :       template <typename T, typename C, typename B, schema_type::value ST>
     113              :       fundamental_base<T, C, B, ST>::
     114              :       fundamental_base (const xercesc::DOMAttr& a, flags f, container* c)
     115              :           : B (a, f, c),
     116              :             facet_table_ (0),
     117              :             x_ (traits<T, C, ST>::create (a, f, c))
     118              :       {
     119              :       }
     120              : 
     121              :       template <typename T, typename C, typename B, schema_type::value ST>
     122              :       fundamental_base<T, C, B, ST>::
     123              :       fundamental_base (const std::basic_string<C>& s,
     124              :                         const xercesc::DOMElement* e,
     125              :                         flags f,
     126              :                         container* c)
     127              :           : B (s, e, f, c),
     128              :             facet_table_ (0),
     129              :             x_ (traits<T, C, ST>::create (s, e, f, c))
     130              :       {
     131              :       }
     132              : 
     133              : 
     134              :       // Parsing c-tors for list.
     135              :       //
     136              : 
     137              :       namespace bits
     138              :       {
     139              :         // Find first non-space character.
     140              :         //
     141              :         template <typename C>
     142              :         typename std::basic_string<C>::size_type
     143              :         find_ns (const C* s,
     144              :                  typename std::basic_string<C>::size_type size,
     145              :                  typename std::basic_string<C>::size_type pos)
     146              :         {
     147              :           while (pos < size &&
     148              :                  (s[pos] == C (0x20) || // space
     149              :                   s[pos] == C (0x0D) || // carriage return
     150              :                   s[pos] == C (0x09) || // tab
     151              :                   s[pos] == C (0x0A)))
     152              :             ++pos;
     153              : 
     154              :           return pos < size ? pos : std::basic_string<C>::npos;
     155              :         }
     156              : 
     157              :         // Find first space character.
     158              :         //
     159              :         template <typename C>
     160              :         typename std::basic_string<C>::size_type
     161              :         find_s (const C* s,
     162              :                 typename std::basic_string<C>::size_type size,
     163              :                 typename std::basic_string<C>::size_type pos)
     164              :         {
     165              :           while (pos < size &&
     166              :                  s[pos] != C (0x20) && // space
     167              :                  s[pos] != C (0x0D) && // carriage return
     168              :                  s[pos] != C (0x09) && // tab
     169              :                  s[pos] != C (0x0A))
     170              :             ++pos;
     171              : 
     172              :           return pos < size ? pos : std::basic_string<C>::npos;
     173              :         }
     174              :       }
     175              : 
     176              :       // Individual items of the list have no DOM association. Therefore
     177              :       // we clear keep_dom from flags.
     178              :       //
     179              : 
     180              :       template <typename T, typename C, schema_type::value ST>
     181              :       list<T, C, ST, false>::
     182              :       list (const xercesc::DOMElement& e, flags f, container* c)
     183              :           : sequence<T> (c)
     184              :       {
     185              :         init (tree::text_content<C> (e), &e, f & ~flags::keep_dom);
     186              :       }
     187              : 
     188              :       template <typename T, typename C, schema_type::value ST>
     189              :       list<T, C, ST, false>::
     190              :       list (const xercesc::DOMAttr& a, flags f, container* c)
     191              :           : sequence<T> (c)
     192              :       {
     193              :         init (xml::transcode<C> (a.getValue ()),
     194              :               a.getOwnerElement (),
     195              :               f & ~flags::keep_dom);
     196              :       }
     197              : 
     198              :       template <typename T, typename C, schema_type::value ST>
     199              :       list<T, C, ST, false>::
     200              :       list (const std::basic_string<C>& s,
     201              :             const xercesc::DOMElement* e,
     202              :             flags f,
     203              :             container* c)
     204              :           : sequence<T> (c)
     205              :       {
     206              :         init (s, e, f & ~flags::keep_dom);
     207              :       }
     208              : 
     209              :       template <typename T, typename C, schema_type::value ST>
     210              :       void list<T, C, ST, false>::
     211              :       init (const std::basic_string<C>& s,
     212              :             const xercesc::DOMElement* parent,
     213              :             flags f)
     214              :       {
     215              :         if (s.size () == 0)
     216              :           return;
     217              : 
     218              :         using std::basic_string;
     219              :         typedef typename basic_string<C>::size_type size_type;
     220              : 
     221              :         const C* data (s.c_str ());
     222              :         size_type size (s.size ());
     223              : 
     224              :         // Traverse the data while logically collapsing spaces.
     225              :         //
     226              :         for (size_type i (bits::find_ns<C> (data, size, 0));
     227              :              i != basic_string<C>::npos;)
     228              :         {
     229              :           size_type j (bits::find_s (data, size, i));
     230              : 
     231              :           if (j != basic_string<C>::npos)
     232              :           {
     233              :             this->push_back (
     234              :               traits<T, C, ST>::create (
     235              :                 basic_string<C> (data + i, j - i),
     236              :                 parent,
     237              :                 f,
     238              :                 this->container_));
     239              : 
     240              :             i = bits::find_ns (data, size, j);
     241              :           }
     242              :           else
     243              :           {
     244              :             // Last element.
     245              :             //
     246              :             this->push_back (
     247              :               traits<T, C, ST>::create (
     248              :                 basic_string<C> (data + i, size - i),
     249              :                 parent,
     250              :                 f,
     251              :                 this->container_));
     252              : 
     253              :             break;
     254              :           }
     255              :         }
     256              :       }
     257              : 
     258              :       template <typename T, typename C, schema_type::value ST>
     259              :       list<T, C, ST, true>::
     260              :       list (const xercesc::DOMElement& e, flags, container* c)
     261              :           : sequence<T> (c)
     262              :       {
     263              :         init (tree::text_content<C> (e), &e);
     264              :       }
     265              : 
     266              :       template <typename T, typename C, schema_type::value ST>
     267              :       inline list<T, C, ST, true>::
     268              :       list (const xercesc::DOMAttr& a, flags, container* c)
     269              :           : sequence<T> (c)
     270              :       {
     271              :         init (xml::transcode<C> (a.getValue ()), a.getOwnerElement ());
     272              :       }
     273              : 
     274              :       template <typename T, typename C, schema_type::value ST>
     275              :       inline list<T, C, ST, true>::
     276              :       list (const std::basic_string<C>& s,
     277              :             const xercesc::DOMElement* parent,
     278              :             flags,
     279              :             container* c)
     280              :           : sequence<T> (c)
     281              :       {
     282              :         init (s, parent);
     283              :       }
     284              : 
     285              :       template <typename T, typename C, schema_type::value ST>
     286              :       inline void list<T, C, ST, true>::
     287              :       init (const std::basic_string<C>& s, const xercesc::DOMElement* parent)
     288              :       {
     289              :         if (s.size () == 0)
     290              :           return;
     291              : 
     292              :         using std::basic_string;
     293              :         typedef typename basic_string<C>::size_type size_type;
     294              : 
     295              :         const C* data (s.c_str ());
     296              :         size_type size (s.size ());
     297              : 
     298              :         // Traverse the data while logically collapsing spaces.
     299              :         //
     300              :         for (size_type i (bits::find_ns<C> (data, size, 0));
     301              :              i != basic_string<C>::npos;)
     302              :         {
     303              :           size_type j (bits::find_s (data, size, i));
     304              : 
     305              :           if (j != basic_string<C>::npos)
     306              :           {
     307              :             this->push_back (
     308              :               traits<T, C, ST>::create (
     309              :                 basic_string<C> (data + i, j - i), parent, 0, 0));
     310              : 
     311              :             i = bits::find_ns (data, size, j);
     312              :           }
     313              :           else
     314              :           {
     315              :             // Last element.
     316              :             //
     317              :             this->push_back (
     318              :               traits<T, C, ST>::create (
     319              :                 basic_string<C> (data + i, size - i), parent, 0, 0));
     320              : 
     321              :             break;
     322              :           }
     323              :         }
     324              :       }
     325              : 
     326              : 
     327              :       // Parsing c-tors for built-in types.
     328              :       //
     329              : 
     330              : 
     331              :       // string
     332              :       //
     333              :       template <typename C, typename B>
     334            0 :       string<C, B>::
     335              :       string (const xercesc::DOMElement& e, flags f, container* c)
     336              :           : B (e, f, c),
     337            0 :             base_type (tree::text_content<C> (e))
     338              :       {
     339            0 :       }
     340              : 
     341              :       template <typename C, typename B>
     342            0 :       string<C, B>::
     343              :       string (const xercesc::DOMAttr& a, flags f, container* c)
     344              :           : B (a, f, c),
     345            0 :             base_type (xml::transcode<C> (a.getValue ()))
     346              :       {
     347            0 :       }
     348              : 
     349              :       template <typename C, typename B>
     350              :       string<C, B>::
     351              :       string (const std::basic_string<C>& s,
     352              :               const xercesc::DOMElement* e,
     353              :               flags f,
     354              :               container* c)
     355              :           : B (s, e, f, c), base_type (s)
     356              :       {
     357              :       }
     358              : 
     359              : 
     360              :       // normalized_string
     361              :       //
     362              :       template <typename C, typename B>
     363              :       normalized_string<C, B>::
     364              :       normalized_string (const xercesc::DOMElement& e, flags f, container* c)
     365              :           : base_type (e, f, c)
     366              :       {
     367              :         normalize ();
     368              :       }
     369              : 
     370              :       template <typename C, typename B>
     371              :       normalized_string<C, B>::
     372              :       normalized_string (const xercesc::DOMAttr& a, flags f, container* c)
     373              :           : base_type (a, f, c)
     374              :       {
     375              :         normalize ();
     376              :       }
     377              : 
     378              :       template <typename C, typename B>
     379              :       normalized_string<C, B>::
     380              :       normalized_string (const std::basic_string<C>& s,
     381              :                          const xercesc::DOMElement* e,
     382              :                          flags f,
     383              :                          container* c)
     384              :           : base_type (s, e, f, c)
     385              :       {
     386              :         normalize ();
     387              :       }
     388              : 
     389              :       template <typename C, typename B>
     390              :       void normalized_string<C, B>::
     391              :       normalize ()
     392              :       {
     393              :         typedef typename std::basic_string<C>::size_type size_type;
     394              : 
     395              :         size_type size (this->size ());
     396              : 
     397              :         for (size_type i (0); i < size; ++i)
     398              :         {
     399              :           C& c ((*this)[i]);
     400              : 
     401              :           if (c == C (0x0D) || // carriage return
     402              :               c == C (0x09) || // tab
     403              :               c == C (0x0A))
     404              :             c = C (0x20);
     405              :         }
     406              :       }
     407              : 
     408              : 
     409              :       // token
     410              :       //
     411              :       template <typename C, typename B>
     412              :       token<C, B>::
     413              :       token (const xercesc::DOMElement& e, flags f, container* c)
     414              :           : base_type (e, f, c)
     415              :       {
     416              :         collapse ();
     417              :       }
     418              : 
     419              :       template <typename C, typename B>
     420              :       token<C, B>::
     421              :       token (const xercesc::DOMAttr& a, flags f, container* c)
     422              :           : base_type (a, f, c)
     423              :       {
     424              :         collapse ();
     425              :       }
     426              : 
     427              :       template <typename C, typename B>
     428              :       token<C, B>::
     429              :       token (const std::basic_string<C>& s,
     430              :              const xercesc::DOMElement* e,
     431              :              flags f,
     432              :              container* c)
     433              :           : base_type (s, e, f, c)
     434              :       {
     435              :         collapse ();
     436              :       }
     437              : 
     438              :       template <typename C, typename B>
     439              :       void token<C, B>::
     440              :       collapse ()
     441              :       {
     442              :         // We have all whitespace normilized by our base. We just
     443              :         // need to collapse them.
     444              :         //
     445              :         typedef typename std::basic_string<C>::size_type size_type;
     446              : 
     447              :         size_type size (this->size ()), j (0);
     448              :         bool subs (false), trim (true);
     449              : 
     450              :         for (size_type i (0); i < size; ++i)
     451              :         {
     452              :           C c ((*this)[i]);
     453              : 
     454              :           if (c == C (0x20))
     455              :           {
     456              :             subs = true;
     457              :           }
     458              :           else
     459              :           {
     460              :             if (subs)
     461              :             {
     462              :               subs = false;
     463              : 
     464              :               if (!trim)
     465              :                 (*this)[j++] = C (0x20);
     466              :             }
     467              : 
     468              :             if (trim)
     469              :               trim = false;
     470              : 
     471              :             (*this)[j++] = c;
     472              :           }
     473              :         }
     474              : 
     475              :         this->resize (j);
     476              :       }
     477              : 
     478              : 
     479              :       // nmtoken
     480              :       //
     481              :       template <typename C, typename B>
     482              :       nmtoken<C, B>::
     483              :       nmtoken (const xercesc::DOMElement& e, flags f, container* c)
     484              :           : base_type (e, f, c)
     485              :       {
     486              :       }
     487              : 
     488              :       template <typename C, typename B>
     489              :       nmtoken<C, B>::
     490              :       nmtoken (const xercesc::DOMAttr& a, flags f, container* c)
     491              :           : base_type (a, f, c)
     492              :       {
     493              :       }
     494              : 
     495              :       template <typename C, typename B>
     496              :       nmtoken<C, B>::
     497              :       nmtoken (const std::basic_string<C>& s,
     498              :                const xercesc::DOMElement* e,
     499              :                flags f,
     500              :                container* c)
     501              :           : base_type (s, e, f, c)
     502              :       {
     503              :       }
     504              : 
     505              : 
     506              :       // nmtokens
     507              :       //
     508              :       template <typename C, typename B, typename nmtoken>
     509              :       nmtokens<C, B, nmtoken>::
     510              :       nmtokens (const xercesc::DOMElement& e, flags f, container* c)
     511              :           : B (e, f, c), base_type (e, f, this)
     512              :       {
     513              :       }
     514              : 
     515              :       template <typename C, typename B, typename nmtoken>
     516              :       nmtokens<C, B, nmtoken>::
     517              :       nmtokens (const xercesc::DOMAttr& a, flags f, container* c)
     518              :           : B (a, f, c), base_type (a, f, this)
     519              :       {
     520              :       }
     521              : 
     522              :       template <typename C, typename B, typename nmtoken>
     523              :       nmtokens<C, B, nmtoken>::
     524              :       nmtokens (const std::basic_string<C>& s,
     525              :                 const xercesc::DOMElement* e,
     526              :                 flags f,
     527              :                 container* c)
     528              :           : B (s, e, f, c), base_type (s, e, f, this)
     529              :       {
     530              :       }
     531              : 
     532              : 
     533              :       // name
     534              :       //
     535              :       template <typename C, typename B>
     536              :       name<C, B>::
     537              :       name (const xercesc::DOMElement& e, flags f, container* c)
     538              :           : base_type (e, f, c)
     539              :       {
     540              :       }
     541              : 
     542              :       template <typename C, typename B>
     543              :       name<C, B>::
     544              :       name (const xercesc::DOMAttr& a, flags f, container* c)
     545              :           : base_type (a, f, c)
     546              :       {
     547              :       }
     548              : 
     549              :       template <typename C, typename B>
     550              :       name<C, B>::
     551              :       name (const std::basic_string<C>& s,
     552              :             const xercesc::DOMElement* e,
     553              :             flags f,
     554              :             container* c)
     555              :           : base_type (s, e, f, c)
     556              :       {
     557              :       }
     558              : 
     559              : 
     560              :       // ncname
     561              :       //
     562              :       template <typename C, typename B>
     563              :       ncname<C, B>::
     564              :       ncname (const xercesc::DOMElement& e, flags f, container* c)
     565              :           : base_type (e, f, c)
     566              :       {
     567              :       }
     568              : 
     569              :       template <typename C, typename B>
     570              :       ncname<C, B>::
     571              :       ncname (const xercesc::DOMAttr& a, flags f, container* c)
     572              :           : base_type (a, f, c)
     573              :       {
     574              :       }
     575              : 
     576              :       template <typename C, typename B>
     577              :       ncname<C, B>::
     578              :       ncname (const std::basic_string<C>& s,
     579              :               const xercesc::DOMElement* e,
     580              :               flags f,
     581              :               container* c)
     582              :           : base_type (s, e, f, c)
     583              :       {
     584              :       }
     585              : 
     586              : 
     587              :       // language
     588              :       //
     589              :       template <typename C, typename B>
     590              :       language<C, B>::
     591              :       language (const xercesc::DOMElement& e, flags f, container* c)
     592              :           : base_type (e, f, c)
     593              :       {
     594              :       }
     595              : 
     596              :       template <typename C, typename B>
     597              :       language<C, B>::
     598              :       language (const xercesc::DOMAttr& a, flags f, container* c)
     599              :           : base_type (a, f, c)
     600              :       {
     601              :       }
     602              : 
     603              :       template <typename C, typename B>
     604              :       language<C, B>::
     605              :       language (const std::basic_string<C>& s,
     606              :                 const xercesc::DOMElement* e,
     607              :                 flags f,
     608              :                 container* c)
     609              :           : base_type (s, e, f, c)
     610              :       {
     611              :       }
     612              : 
     613              : 
     614              :       // id
     615              :       //
     616              :       template <typename C, typename B>
     617              :       id<C, B>::
     618              :       id (const xercesc::DOMElement& e, flags f, container* c)
     619              :           : base_type (e, f, c), identity_ (*this)
     620              :       {
     621              :         register_id ();
     622              :       }
     623              : 
     624              :       template <typename C, typename B>
     625              :       id<C, B>::
     626              :       id (const xercesc::DOMAttr& a, flags f, container* c)
     627              :           : base_type (a, f, c), identity_ (*this)
     628              :       {
     629              :         register_id ();
     630              :       }
     631              : 
     632              :       template <typename C, typename B>
     633              :       id<C, B>::
     634              :       id (const std::basic_string<C>& s,
     635              :           const xercesc::DOMElement* e,
     636              :           flags f,
     637              :           container* c)
     638              :           : base_type (s, e, f, c), identity_ (*this)
     639              :       {
     640              :         register_id ();
     641              :       }
     642              : 
     643              : 
     644              :       // idref
     645              :       //
     646              :       template <typename C, typename B, typename T>
     647              :       idref<C, B, T>::
     648              :       idref (const xercesc::DOMElement& e, flags f, container* c)
     649              :           : base_type (e, f, c), identity_ (*this)
     650              :       {
     651              :       }
     652              : 
     653              :       template <typename C, typename B, typename T>
     654              :       idref<C, B, T>::
     655              :       idref (const xercesc::DOMAttr& a, flags f, container* c)
     656              :           : base_type (a, f , c), identity_ (*this)
     657              :       {
     658              :       }
     659              : 
     660              :       template <typename C, typename B, typename T>
     661              :       idref<C, B, T>::
     662              :       idref (const std::basic_string<C>& s,
     663              :              const xercesc::DOMElement* e,
     664              :              flags f,
     665              :              container* c)
     666              :           : base_type (s, e, f, c), identity_ (*this)
     667              :       {
     668              :       }
     669              : 
     670              : 
     671              :       // idrefs
     672              :       //
     673              :       template <typename C, typename B, typename idref>
     674              :       idrefs<C, B, idref>::
     675              :       idrefs (const xercesc::DOMElement& e, flags f, container* c)
     676              :           : B (e, f, c), base_type (e, f, this)
     677              :       {
     678              :       }
     679              : 
     680              :       template <typename C, typename B, typename idref>
     681              :       idrefs<C, B, idref>::
     682              :       idrefs (const xercesc::DOMAttr& a, flags f, container* c)
     683              :           : B (a, f, c), base_type (a, f, this)
     684              :       {
     685              :       }
     686              : 
     687              :       template <typename C, typename B, typename idref>
     688              :       idrefs<C, B, idref>::
     689              :       idrefs (const std::basic_string<C>& s,
     690              :               const xercesc::DOMElement* e,
     691              :               flags f,
     692              :               container* c)
     693              :           : B (s, e, f, c), base_type (s, e, f, this)
     694              :       {
     695              :       }
     696              : 
     697              : 
     698              :       // uri
     699              :       //
     700              :       template <typename C, typename B>
     701              :       uri<C, B>::
     702              :       uri (const xercesc::DOMElement& e, flags f, container* c)
     703              :           : B (e, f, c),
     704              :             base_type (trim (tree::text_content<C> (e)))
     705              :       {
     706              :       }
     707              : 
     708              :       template <typename C, typename B>
     709              :       uri<C, B>::
     710              :       uri (const xercesc::DOMAttr& a, flags f, container* c)
     711              :           : B (a, f, c),
     712              :             base_type (trim (xml::transcode<C> (a.getValue ())))
     713              :       {
     714              :       }
     715              : 
     716              :       template <typename C, typename B>
     717              :       uri<C, B>::
     718              :       uri (const std::basic_string<C>& s,
     719              :            const xercesc::DOMElement* e,
     720              :            flags f,
     721              :            container* c)
     722              :           : B (s, e, f, c), base_type (trim (s))
     723              :       {
     724              :       }
     725              : 
     726              : 
     727              :       // qname
     728              :       //
     729              :       template <typename C, typename B, typename uri, typename ncname>
     730              :       qname<C, B, uri, ncname>::
     731              :       qname (const xercesc::DOMElement& e, flags f, container* c)
     732              :           : B (e, f, c)
     733              :       {
     734              :         std::basic_string<C> v (trim (tree::text_content<C> (e)));
     735              :         ns_ = resolve (v, &e);
     736              :         name_ = xml::uq_name (v);
     737              :       }
     738              : 
     739              :       template <typename C, typename B, typename uri, typename ncname>
     740              :       qname<C, B, uri, ncname>::
     741              :       qname (const xercesc::DOMAttr& a, flags f, container* c)
     742              :           : B (a, f, c)
     743              :       {
     744              :         std::basic_string<C> v (trim (xml::transcode<C> (a.getValue ())));
     745              :         ns_ = resolve (v, a.getOwnerElement ());
     746              :         name_ = xml::uq_name (v);
     747              :       }
     748              : 
     749              :       template <typename C, typename B, typename uri, typename ncname>
     750              :       qname<C, B, uri, ncname>::
     751              :       qname (const std::basic_string<C>& s,
     752              :              const xercesc::DOMElement* e,
     753              :              flags f,
     754              :              container* c)
     755              :           : B (s, e, f, c)
     756              :       {
     757              :         std::basic_string<C> v (trim (s));
     758              :         ns_ = resolve (v, e);
     759              :         name_ = xml::uq_name (v);
     760              :       }
     761              : 
     762              :       template <typename C, typename B, typename uri, typename ncname>
     763              :       uri qname<C, B, uri, ncname>::
     764              :       resolve (const std::basic_string<C>& s, const xercesc::DOMElement* e)
     765              :       {
     766              :         std::basic_string<C> p (xml::prefix (s));
     767              : 
     768              :         if (e)
     769              :         {
     770              :           // This code is copied verbatim from xml/dom/elements.hxx.
     771              :           //
     772              : 
     773              :           // 'xml' prefix requires special handling and Xerces folks refuse
     774              :           // to handle this in DOM so I have to do it myself.
     775              :           //
     776              :           if (p == xml::bits::xml_prefix<C> ())
     777              :             return xml::bits::xml_namespace<C> ();
     778              : 
     779              :           const XMLCh* xns (
     780              :             e->lookupNamespaceURI (
     781              :               p.empty () ? 0 : xml::string (p).c_str ()));
     782              : 
     783              :           if (xns != 0)
     784              :             return xml::transcode<C> (xns);
     785              :           else if (p.empty ())
     786              :             return std::basic_string<C> ();
     787              :         }
     788              : 
     789              :         throw no_prefix_mapping<C> (p);
     790              :       }
     791              : 
     792              : 
     793              :       // base64_binary
     794              :       //
     795              :       // We are not doing whitespace collapsing since the decode
     796              :       // functions can handle it like this.
     797              :       //
     798              :       template <typename C, typename B>
     799            0 :       base64_binary<C, B>::
     800              :       base64_binary (const xercesc::DOMElement& e, flags f, container* c)
     801            0 :           : B (e, f, c)
     802              :       {
     803              :         // This implementation is not optimal.
     804              :         //
     805            0 :         std::basic_string<C> str (trim (tree::text_content<C> (e)));
     806            0 :         decode (xml::string (str).c_str ());
     807            0 :       }
     808              : 
     809              :       template <typename C, typename B>
     810              :       base64_binary<C, B>::
     811              :       base64_binary (const xercesc::DOMAttr& a, flags f, container* c)
     812              :           : B (a, f, c)
     813              :       {
     814              :         std::basic_string<C> str (trim (xml::transcode<C> (a.getValue ())));
     815              :         decode (xml::string (str).c_str ());
     816              :       }
     817              : 
     818              :       template <typename C, typename B>
     819              :       base64_binary<C, B>::
     820              :       base64_binary (const std::basic_string<C>& s,
     821              :                      const xercesc::DOMElement* e,
     822              :                      flags f,
     823              :                      container* c)
     824              :           : B (s, e, f, c)
     825              :       {
     826              :         std::basic_string<C> str (trim (s));
     827              :         decode (xml::string (str).c_str ());
     828              :       }
     829              : 
     830              : 
     831              :       // hex_binary
     832              :       //
     833              :       template <typename C, typename B>
     834              :       hex_binary<C, B>::
     835              :       hex_binary (const xercesc::DOMElement& e, flags f, container* c)
     836              :           : B (e, f, c)
     837              :       {
     838              :         // This implementation is not optimal.
     839              :         //
     840              :         std::basic_string<C> str (trim (tree::text_content<C> (e)));
     841              :         decode (xml::string (str).c_str ());
     842              :       }
     843              : 
     844              :       template <typename C, typename B>
     845              :       hex_binary<C, B>::
     846              :       hex_binary (const xercesc::DOMAttr& a, flags f, container* c)
     847              :           : B (a, f, c)
     848              :       {
     849              :         std::basic_string<C> str (trim (xml::transcode<C> (a.getValue ())));
     850              :         decode (xml::string (str).c_str ());
     851              :       }
     852              : 
     853              :       template <typename C, typename B>
     854              :       hex_binary<C, B>::
     855              :       hex_binary (const std::basic_string<C>& s,
     856              :                   const xercesc::DOMElement* e,
     857              :                   flags f,
     858              :                   container* c)
     859              :           : B (s, e, f, c)
     860              :       {
     861              :         std::basic_string<C> str (trim (s));
     862              :         decode (xml::string (str).c_str ());
     863              :       }
     864              : 
     865              :       // entity
     866              :       //
     867              :       template <typename C, typename B>
     868              :       entity<C, B>::
     869              :       entity (const xercesc::DOMElement& e, flags f, container* c)
     870              :           : base_type (e, f, c)
     871              :       {
     872              :       }
     873              : 
     874              :       template <typename C, typename B>
     875              :       entity<C, B>::
     876              :       entity (const xercesc::DOMAttr& a, flags f, container* c)
     877              :           : base_type (a, f, c)
     878              :       {
     879              :       }
     880              : 
     881              :       template <typename C, typename B>
     882              :       entity<C, B>::
     883              :       entity (const std::basic_string<C>& s,
     884              :               const xercesc::DOMElement* e,
     885              :               flags f,
     886              :               container* c)
     887              :           : base_type (s, e, f, c)
     888              :       {
     889              :       }
     890              : 
     891              : 
     892              :       // entities
     893              :       //
     894              :       template <typename C, typename B, typename entity>
     895              :       entities<C, B, entity>::
     896              :       entities (const xercesc::DOMElement& e, flags f, container* c)
     897              :           : B (e, f, c), base_type (e, f, this)
     898              :       {
     899              :       }
     900              : 
     901              :       template <typename C, typename B, typename entity>
     902              :       entities<C, B, entity>::
     903              :       entities (const xercesc::DOMAttr& a, flags f, container* c)
     904              :           : B (a, f, c), base_type (a, f, this)
     905              :       {
     906              :       }
     907              : 
     908              :       template <typename C, typename B, typename entity>
     909              :       entities<C, B, entity>::
     910              :       entities (const std::basic_string<C>& s,
     911              :                 const xercesc::DOMElement* e,
     912              :                 flags f,
     913              :                 container* c)
     914              :           : B (s, e, f, c), base_type (s, e, f, this)
     915              :       {
     916              :       }
     917              :     }
     918              :   }
     919              : }
        

Generated by: LCOV version 2.0-1