From: togol m. <tog...@ly...> - 2005-10-18 09:53:39
|
Thanks for the prompt reply. If I am searching for an element not in the default namespace, then there s= hould no error messages regarding namespace registeration. Thats exactly wh= at is confusing because OWL namespace is not a default namespace as is defi= ned in the following OWL file.=20 <?xml version=3D"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=3D"&Example;#" xmlns:rdf=3D"&rdf;#" xmlns:rdfs=3D"&rdfs;#" xmlns:xsd=3D"&xsd;#" xmlns:owl=3D"&owl;#" xmlns:molecular_species=3D"&molecular_species;#" xmlns:phase_system=3D"&phase_system;#" xmlns:substance=3D"&substance;#" xml:base=3D"&Example;" > =20 <owl:Ontology rdf:about=3D"&Example;"> <owl:imports rdf:resource=3D"&phase_system;"/> <owl:imports rdf:resource=3D"&molecular_species;"/> </owl:Ontology> Now if I find the ontology node with the XPath expr "//owl:Ontology", the n= amespace registration error is thrown. If I explicitly register the OWL nam= espace using xmlXPathRegisterNs function, the error message does not appear= but the node set is still empty. It does not change even if I replace xmln= s:owl=3D"&owl;#" by xmlns:owl=3D"http://www.w3.org/2002/07/owl".=20 Togol=20 ----- Original Message ----- From: "Darko Miletic" <da...@uv...> To: "togol machillan" <tog...@ly...> Subject: Re: [libxml++] Searching nodes with ns prefix Date: Sun, 16 Oct 2005 14:38:34 -0300 >=20 > togol machillan wrote: > > Dear Members, > > > > I am facing the problem of finding nodes in an OWL file. The=20 > > importance of registering the namespace before calling the find()=20 > > function has been discussed before, but still the find function=20 > > in libxml++ v2.12 does not support this. I defined a new function=20 > > as follows. > > The "undefined namespace prefix" error message does not appear=20 > > anymore, but the node set is still empty. I call the find()=20 > > function for the root node rdf:RDF of the owl document with the=20 > > XPath expr //owl:Ontology. If I add a check to see whether the=20 > > OWL namespace is already registered using xmlSearchNs(), it=20 > > returns the namespace pointer since for OWL, the namespace is=20 > > always defined in the root node. Can somebody please point out=20 > > where the problem is? >=20 > Namespace needs to be registered ONLY if it is default namespace.=20 > Other namespaces are recognized properly. That means if you have=20 > xml file like this: >=20 > <?xml version=3D"1.0" encoding=3D"UTF-8"?> > <rootitem xmlns=3D"http://www.something.com/ns1" > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://www.something.com/ns1 ns1.= xsd" > version=3D"1.3"> >=20 > In this case you must register ns1.xsd before doing find. For=20 > example like this: >=20 > xmlXPathRegisterNs( ctxt, > "ns1", > "http://www.something.com/ns1"); >=20 > The when doing search you should prefix all nodes from default=20 > namespace with namespace name you registered: >=20 > node->find("//ns1:rootitem/otheritem"); >=20 > Not placing registered prefix for default namespace in xpath string=20 > is the most common error when using libxml++ or libxml2. >=20 > Darko >=20 >=20 >=20 > ------------------------------------------------------- > 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 > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libxmlplusplus-general --=20 _______________________________________________ Search for businesses by name, location, or phone number. -Lycos Yellow Pa= ges http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.as= p?SRC=3Dlycos10 |