/* * call-seq: * add_namespace_definition(prefix, href) * * Adds a namespace definition with +prefix+ using +href+ */ static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href) { xmlNodePtr node; xmlNsPtr ns; Data_Get_Struct(self, xmlNode, node); ns = xmlNewNs( node, (const xmlChar *)StringValuePtr(href), (const xmlChar *)(NIL_P(prefix) ? NULL : StringValuePtr(prefix)) ); if(!ns) { ns = xmlSearchNs( node->doc, node, (const xmlChar *)(NIL_P(prefix) ? NULL : StringValuePtr(prefix)) ); } if(NIL_P(prefix)) xmlSetNs(node, ns); return Nokogiri_wrap_xml_namespace(node->doc, ns); }