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.