Vaucanson 1.4
|
00001 // tools.hxx: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2007, 2008, 2009 The Vaucanson Group. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // The complete GNU General Public Licence Notice can be found as the 00013 // `COPYING' file in the root directory. 00014 // 00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 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 } // !tools 00093 } // !xml 00094 } // !vcsn 00095 00096 #endif // !VCSN_XML_TOOLS_HXX