00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef VCSN_XML_TOOLS_HXX
00019 # define VCSN_XML_TOOLS_HXX
00020 
00021 # include <vaucanson/xml/strings.hh>
00022 
00023 namespace vcsn
00024 {
00025   namespace xml
00026   {
00027     namespace tools
00028     {
00033       inline
00034       bool
00035       has_attribute (const xercesc::Attributes& attrs,
00036                      const char* key,
00037                      const XMLCh* const uri)
00038       {
00039         return (get_attribute(attrs, key, uri) != 0);
00040       }
00041 
00042       inline
00043       bool
00044       has_attribute (const xercesc::Attributes& attrs,
00045                      const XMLCh* xkey,
00046                      const XMLCh* const uri)
00047       {
00048         return (get_attribute(attrs, xkey, uri) != 0);
00049       }
00050 
00051       inline
00052       const XMLCh*
00053       get_attribute (const xercesc::Attributes& attrs,
00054                      const char* key,
00055                      const XMLCh* const uri)
00056       {
00057         XMLCh* xkey = transcode(key);
00058         const XMLCh* tmp = attrs.getValue(uri, xkey);
00059         xercesc::XMLString::release(&xkey);
00060         return tmp;
00061       }
00062 
00063       inline
00064       const XMLCh*
00065       get_attribute (const xercesc::Attributes& attrs,
00066                      const XMLCh* xkey,
00067                      const XMLCh* const uri)
00068       {
00069         const XMLCh* tmp = attrs.getValue(uri, xkey);
00070         return tmp;
00071       }
00072 
00076       void
00077       set_attribute (xercesc::DOMElement* e,
00078                      const std::string& k, const std::string& v)
00079       {
00080         if (v != "")
00081           e->setAttribute (transcode(k), transcode(v));
00082       }
00086       xercesc::DOMElement*
00087       create_element(xercesc::DOMDocument* doc,
00088                      const std::string& e)
00089       {
00090         return doc->createElementNS(transcode(VCSN_XMLNS), transcode(e));
00091       }
00092     } 
00093   } 
00094 } 
00095 
00096 #endif // !VCSN_XML_TOOLS_HXX