On Wed, 2011-11-09 at 16:48 -0800, Kevin Corcoran wrote: > Sorry about the missing attachment - I've posted my example code at > http://pastie.org/2839258 > > Chris, thanks for the info about Jena's handling of namespaces. That all > makes sense but I don't think it addresses the particular case that I'm > dealing with. > > To give a very brief description of my situation: > * I've got a namespace with a prefix defined in the opening <rdf:RDF> tag. > ( xmlns:wn="http://www.ontologyportal.org/WordNet.owl#" ) > * An element in the namespace is referenced using the prefix ( > <subsumingRelation rdf:resource="*wn#WN30-201691057*"/> )
That's your problem. The reference "wn#WN30-201691057" has no connection to the namespace declaration. As far as RDF/XML is concerned that's a relative URI so it is resolved relative to the xml:base or base URI of your document. I assume your base is effectively: http://www.ontologyportal.org/WordNet.owl Resolving "wn#WN30-201691057" relative to that base gives the URI: http://www.ontologyportal.org/wn#WN30-201691057 Calling getNamespace on that URI will (correctly) give you: http://www.ontologyportal.org/wn# The standard pattern people tend to use is to define entities: <!DOCTYPE rdf:RDF [ <!ENTITY wn 'http://www.ontologyportal.org/wn#'> <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'> <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'> <!ENTITY owl "http://www.w3.org/2002/07/owl#" > ]> then use those in your namespace declarations: xmlns:wm = "&wm;" and in your URIs: <subsumingRelation rdf:resource="&wn;WN30-201691057"/> Dave [Actually the *standard* pattern is to run screaming from RDF/XML and use Turtle instead :) ]
