combining names and namespaces into a one URI

N

nallen05

Is there a standardized recommendation for combining names and
namespaces into a single URI?

I found a post on the Stylus Studio forum asking the same question,
the response was "use James Clark's {http://www.namespace.com}name
notation". The post is 7 years old and I'm wondering if anything has
changed...

thanks

Nick
 
J

Joe Kesselman

Is there a standardized recommendation for combining names and
namespaces into a single URI?

I found a post on the Stylus Studio forum asking the same question,
the response was "use James Clark's {http://www.namespace.com}name
notation". The post is 7 years old and I'm wondering if anything has
changed...

That combined form isn't a URI.

It's still one common solution to displaying the NSURI/localname pair,
but there is absolutely no "standard" behind it; it's just that most
folks are aware of it and find it adequate for their needs.

But the more common solution is to just declare (or explain) your use of
prefixes and use standard Qualified Names. The combined form is
generally not particularly necessary or useful except, perhaps, as a
debugging tool; if you're looking for an internal representation(s) of
this value pair, something which lets you more efficiently
access/compare/store the information is generally preferable -- struct
references, table indices, that sort of thing.
 
N

nallen05

Hey Joe

That combined form isn't a URI.
Right



It's still one common solution to displaying the NSURI/localname pair,
but there is absolutely no "standard" behind it; it's just that most
folks are aware of it and find it adequate for their needs.

But the more common solution is to just declare (or explain) your use of
prefixes and use standard Qualified Names. The combined form is
generally not particularly necessary or useful except, perhaps, as a
debugging tool; if you're looking for an internal representation(s) of
this value pair, something which lets you more efficiently
access/compare/store the information is generally preferable -- struct
references, table indices, that sort of thing.

I want to take some data in and out of an rdf-oriented triple store in
standard XML syntax, not RDF/XML... I'd like to do it in as "least
bad" a manner as possible... ;-)

Looking at other people's RDF/XML (like this from Wikipedia)

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="http://en.wikipedia.org/wiki/
Tony_Benn">
<dc:title>Tony Benn</dc:title>
<dc:publisher>Wikipedia</dc:publisher>
</rdf:Description>
</rdf:RDF>

when it is transformed to N-Triples RDF

<http://en.wikipedia.org/wiki/Tony_Benn> <http://purl.org/dc/elements/
1.1/title> "Tony Benn" .
<http://en.wikipedia.org/wiki/Tony_Benn> <http://purl.org/dc/elements/
1.1/publisher> "Wikipedia" .

"{http://purl.org/dc/elements/1.1/}title" changes to "http://purl.ord/
dc/elements/1.1/title". But even the other ns url "http://www.w3.org/
1999/02/22-rdf-syntax-ns#" ends in a hash and not a /...

thanks for your time

Nick


 
J

Joe Kesselman

I want to take some data in and out of an rdf-oriented triple store in
standard XML syntax, not RDF/XML... I'd like to do it in as "least
bad" a manner as possible... ;-)

In that case, it's sorta "whatever works", right? You aren't (very)
concerned about human-readability, you just want something that lets you
efficiently recover both values from the single string.

The {nsuri}local solution counts on the fact that the {} characters
aren't permitted in localnames and are uncommon in URIs. To unbundle,
you skip the leading {, and search backward for the last } as a division
point between the two fields. Not hugely pretty, but it works and is
reasonably fast. But the leading { isn't really necessary if you know a
priori that the value will be in this form.

The other example you've shown us just concatenates the NSURI and
localname. As you noted, that has a nontrivial problem: most namespace
URIs don't end with a / so the combined form is likely to be hard to
divide up again. The best I can call this is "sloppy". I would recommend
always inserting a delimiter character so you are *certain* you know how
to break it apart again. If you want something that looks URI-like you
could use / as your delimiter (or :, for that matter), but that's really
a matter of taste since nobody outside your own applications should ever
be trying to parse these.
 
J

Joe Kesselman

Joe said:
always inserting a delimiter character so you are *certain* you know how
to break it apart again. If you want something that looks URI-like you
could use / as your delimiter (or :, for that matter)

Or #. The important thing is that it's something that absolutely can't
appear in the localname and that it be inserted every time, so you can
always be sure the last instance of it is the delimiter between
namespace name and localname.

Which brings me back to "What's easiest for your own code to handle?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,268
Members
46,867
Latest member
Lonny Petersen

Latest Threads

Top