[libxml++] Searching nodes with ns prefix



Dear Members,

I am facing the problem of finding nodes in an OWL file. The importance of registering the namespace before calling the find() function has been discussed before, but still the find function in libxml++ v2.12 does not support this. I defined a new function as follows.

NodeSet Node::find_with_ns(const std::string& xpath, const std::string& ns_prefix, const std::string& uri) const
{
  xmlXPathContext* ctxt = xmlXPathNewContext(impl_->doc);
  if (!xmlXPathRegisterNs(ctxt, (const xmlChar*)ns_prefix.c_str(), (const xmlChar*)uri.c_str())){
	  std::cout << "Namespace registered successfully" << std::endl;
  }
  ctxt->node = impl_;
... 

The "undefined namespace prefix" error message does not appear anymore, but the node set is still empty. I call the find() function for the root node rdf:RDF of the owl document with the XPath expr //owl:Ontology. If I add a check to see whether the OWL namespace is already registered using xmlSearchNs(), it returns the namespace pointer since for OWL, the namespace is always defined in the root node. 
Can somebody please point out where the problem is?
 
Thanks,

Togol   

-- 
_______________________________________________

Search for businesses by name, location, or phone number.  -Lycos Yellow Pages

http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]