From: Ilya M. <m_...@us...> - 2003-03-26 21:21:45
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv26744 Modified Files: XPathContext.xs XPathContext.pm Log Message: Add unregisterNs() method Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- XPathContext.xs 26 Mar 2003 15:26:47 -0000 1.23 +++ XPathContext.xs 26 Mar 2003 21:21:41 -0000 1.24 @@ -531,8 +531,8 @@ void registerNs( pxpath_context, prefix, ns_uri ) SV * pxpath_context - char * prefix - char * ns_uri + SV * prefix + SV * ns_uri PREINIT: xmlXPathContextPtr ctxt = NULL; int ret = -1; @@ -543,9 +543,15 @@ } LibXML_configure_xpathcontext(ctxt); PPCODE: - ret = xmlXPathRegisterNs(ctxt, prefix, ns_uri); - if(ret == -1) { - croak("XPathContext:cannot register namespace"); + if(SvOK(ns_uri)) { + if(xmlXPathRegisterNs(ctxt, SvPV_nolen(prefix), + SvPV_nolen(ns_uri)) == -1) { + croak("XPathContext: cannot register namespace"); + } + } else { + if(xmlXPathRegisterNs(ctxt, SvPV_nolen(prefix), NULL) == -1) { + croak("XPathContext: cannot unregister namespace"); + } } SV* Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- XPathContext.pm 26 Mar 2003 17:16:46 -0000 1.15 +++ XPathContext.pm 26 Mar 2003 21:21:41 -0000 1.16 @@ -64,6 +64,12 @@ return; } +sub unregisterNs { + my ($self, $prefix) = @_; + $self->registerNs($prefix, undef); + return; +} + sub unregisterFunction { my ($self, $name) = @_; $self->registerFunctionNS($name, undef, undef); @@ -132,6 +138,7 @@ $xc->registerFunctionNS($name, $namespace_uri, sub { ... }); $xc->registerVarLookupFunc(sub { ... }, $data); + $xc->unregisterNs($prefix); $xc->unregisterFunction($name); $xc->unregisterFunctionNS($name, $namespace_uri); $xc->unregisterVarLookupFunc($name); @@ -238,6 +245,10 @@ =item B<registerNs($prefix, $namespace_uri)> Registers namespace I<$prefix> to I<$namespace_uri>. + +=item B<unregisterNs($prefix)> + +Unregisters namespace I<$prefix>. =item B<registerVarLookupFunc($callback, $data)> |