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       const XMLCh*
00044       get_attribute (const xercesc::Attributes& attrs,
00045                      const char* key,
00046                      const XMLCh* const uri)
00047       {
00048         XMLCh* xkey = transcode(key);
00049         const XMLCh* tmp = attrs.getValue(uri, xkey);
00050         xercesc::XMLString::release(&xkey);
00051         return tmp;
00052       }
00053 
00057       void
00058       set_attribute (xercesc::DOMElement* e,
00059                      const std::string& k, const std::string& v)
00060       {
00061         if (v != "")
00062           e->setAttribute (transcode(k), transcode(v));
00063       }
00067       xercesc::DOMElement*
00068       create_element(xercesc::DOMDocument* doc,
00069                      const std::string& e)
00070       {
00071         return doc->createElement(transcode(e));
00072       }
00073     } 
00074   } 
00075 } 
00076 
00077 #endif // !VCSN_XML_TOOLS_HXX