[redland-dev] Are ns names and local names accessible somewhere after parsing?

Stephen Waterbury golux at comcast.net
Wed Sep 1 07:35:11 BST 2004


Hi Dave,

I'm using Redland's Python binding's Parser.parse_into_model to
read an rdf file and then using Model.find to pull out (to begin
with) any rdfs and owl Class "declarations".  I'd like to
re-capture if possible (as opposed to guessing by parsing the URI
strings ;) the namespace names if any "custom" namespaces (like "vs",
"foaf", "wot", and "dc" below) are explicitly declared in
the rdf file -- as they are, e.g., in the foaf ontology:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:owl="http://www.w3.org/2002/07/owl#"
  xmlns:vs="http://www.w3.org/2003/06/sw-vocab-status/ns#"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:wot="http://xmlns.com/wot/0.1/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
>

I.e., after the Parser assembles these into the nodes' full URIs,
does it discard the xmlns's (and the local names and/or QNames,
e.g. "owl:Ontology") or can I get to them somehow?

I couldn't find any methods or attributes for that on
Model (which seemed the most likely place to look) or URI or
anywhere else in the Redland Python API docs or Python code.

If I *do* need to extract ns names and local names from the
URIs, I found this rule in section 8 of the RDF/XML Syntax
Specification:

"It is recommended that implementors of RDF serializers,
in order to break a URI into a namespace name and a local name,
split it after the last XML non-NCName  character, ensuring that
the first character of the name is a Letter or '_'."

Is that a good rule to rely on (assuming the local name contains
only letters and underscores)?

Thanks!
Steve



More information about the redland-dev mailing list