Re: [libxml++] Searching nodes with ns prefix



Thanks for the prompt reply.

If I am searching for an element not in the default namespace, then there should no error messages regarding namespace registeration. Thats exactly what is confusing because OWL namespace is not a default namespace as is defined in the following OWL file. 

<?xml version="1.0"?>

<!DOCTYPE rdf:RDF [
  <!ENTITY root                 "file:/C:/OntoCAPE/">
  <!ENTITY owl                  "http://www.w3.org/2002/07/owl";>
  <!ENTITY xsd                  "http://www.w3.org/2001/XMLSchema";>
  <!ENTITY rdf                  "http://www.w3.org/1999/02/22-rdf-syntax-ns";>
  <!ENTITY rdfs                 "http://www.w3.org/2000/01/rdf-schema";>
  <!ENTITY molecular_species    "&root;molecular_species.owl">
  <!ENTITY phase_system         "&root;phase_system.owl">
  <!ENTITY Example              "&root;Example_v1.owl">
  <!ENTITY substance            "&root;substance.owl">
]>

<rdf:RDF
    xmlns="&Example;#"
    xmlns:rdf="&rdf;#"
    xmlns:rdfs="&rdfs;#"
    xmlns:xsd="&xsd;#"
    xmlns:owl="&owl;#"
    xmlns:molecular_species="&molecular_species;#"
    xmlns:phase_system="&phase_system;#"
    xmlns:substance="&substance;#"
    xml:base="&Example;"
>
 
  <owl:Ontology rdf:about="&Example;">
    <owl:imports rdf:resource="&phase_system;"/>
    <owl:imports rdf:resource="&molecular_species;"/>
  </owl:Ontology>

Now if I find the ontology node with the XPath expr "//owl:Ontology", the namespace registration error is thrown. If I explicitly register the OWL namespace using xmlXPathRegisterNs function, the error message does not appear but the node set is still empty. It does not change even if I replace xmlns:owl="&owl;#" by xmlns:owl="http://www.w3.org/2002/07/owl";. 

Togol 

----- Original Message -----
From: "Darko Miletic" <darko uvcms com>
To: "togol machillan" <togolmach2 lycos com>
Subject: Re: [libxml++] Searching nodes with ns prefix
Date: Sun, 16 Oct 2005 14:38:34 -0300

> 
> togol machillan wrote:
> > 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.
> > 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?
> 
> Namespace needs to be registered ONLY if it is default namespace. 
> Other namespaces are recognized properly. That means if you have 
> xml file like this:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <rootitem xmlns="http://www.something.com/ns1";
>                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>                   xsi:schemaLocation="http://www.something.com/ns1 ns1.xsd"
>   version="1.3">
> 
> In this case you must register ns1.xsd before doing find. For 
> example like this:
> 
>        xmlXPathRegisterNs( ctxt,
>                            "ns1",
>                            "http://www.something.com/ns1";);
> 
> The when doing search you should prefix all nodes from default 
> namespace with namespace name you registered:
> 
>    node->find("//ns1:rootitem/otheritem");
> 
> Not placing registered prefix for default namespace in xpath string 
> is the most common error when using libxml++ or libxml2.
> 
> Darko
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Libxmlplusplus-general mailing list
> Libxmlplusplus-general lists sourceforge net
> https://lists.sourceforge.net/lists/listinfo/libxmlplusplus-general


-- 
_______________________________________________

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]