W3C home > Mailing lists > Public > www-ql@w3.org > July to September 2004

RE: Generating RDF-style URIs from a namespace

From: Howard Katz <howardk@fatdog.com>
Date: Wed, 8 Sep 2004 09:15:38 -0700
To: "Michael Kay" <mhk@mhk.me.uk>, "'Per Bothner'" <per@bothner.com>
Cc: <www-ql@w3.org>

The use case, which is still somewhat vague, is motivated by the need to be
able to work with either qnames or uris (more properly, urirefs) in an
RDF-processing application, and to be able to programmatically map back and
forth between the two.

As a bit of quick background, in a typical RDF scenario the sequence of
urirefs :


can be said to represent resources belonging to the vocabulary
"http://foo/", where the "bar" and "baz" suffixes indicate specific terms
within that vocabulary. Using qnames as a syntactic shorthand, this list can
be represented more compactly and in more human-friendly fashion as :


where the common component "http://foo/" is mapped to the qname prefix
"foo". This mapping looks very much like an XQuery namespace declaration,
although it's not exactly the same thing. Close enough for a cigar however.
RDF commonly uses this adaptation of the XML qname and namespace concepts to
map from uris to qnames and back again.

My original question was motivated by a question from a colleague with whom
I'm just starting to explore the use of XQuery for processing RDF. His
specific question was :

"I know that you can declare a namespace in the prolog (and in a number of
other more subtle ways), but just how can you *use* it? The specs only seem
to demonstrate use in direct constructors and the like; can you just use it
to build URIs inline? i.e. I want to generate the sequence ( http://foo/bar,
http://foo/baz ). Will this do:

   declare namespace foo="http://foo/"
   foo:bar, foo:baz

If this question and my recasting of it were somewhat vague, I apologize.
We're just starting to explore this area, and we don't yet understand enough
to be able to ask more meaningful questions or pose a more clearly
delineated use case at this point. That will come in time.

In the meantime, both Paul and Per's response's have been helpful to me.
It's now clear that in order to be able to use an XQuery namespace
declaration, the prefix-to-namespace mapping needs to be known statically at
query time. In some RDF scenarios -- when you're working with "well-known"
prefixes such as "rdf" and "owl" for example -- that works just fine. In
other scenarios, where the uris are not well known and you would need to be
able to generate the namespace mappings from the uris dynamically, that
clearly won't work and straight string manipulation will have to be used

If and when I have a clearer understanding of what the issues are and what a
clear and realistic use case might be, I'll be happy to post that to the


> -----Original Message-----
> From: www-ql-request@w3.org [mailto:www-ql-request@w3.org]On Behalf Of
> Michael Kay
> Sent: Wednesday, September 08, 2004 1:00 AM
> To: 'Per Bothner'; 'Howard Katz'
> Cc: www-ql@w3.org
> Subject: RE: Generating RDF-style URIs from a namespace
> I avoided weighing into this because I really found the question very
> unclear, but since namespaces and QNames are such a thorny area
> (one that is
> still being refined in the spec) the use case deserves examination.
> Could you explain exactly what your input is, what your desired output is,
> and what information is known statically? Preferably in language that
> doesn't rely on any knowledge of RDF.
> Michael Kay
> > Paul Cotton wrote:
> >
> > > This means that the NamespaceDecl cannot contain function calls or
> > > string concatentation.
> >
> > But the question wasn't generating namespaces, but generating URIs.
> >
> > It seems to me you should be able to use a cast to a QName:
> >
> > declare namespace foo="http://foo/";
> > for $name in ("bar", "baz")
> > let $qname := QName(concat("foo:",$name) return
> > xs:anyURI( concat(namespace-uri-from-QName($name),
> >                    local-name-from-QName($name)))
> >
> > or
> >
> > declare namespace foo="http://foo/";
> > let $foo := namespace-uri-from-QName(QName("foo:unused"))
> > for $name in ("bar", "baz")
> > xs:anyURI( concat($foo, $name))
> > --
> > 	--Per Bothner
> > per@bothner.com   http://per.bothner.com/
> >
> >
Received on Wednesday, 8 September 2004 16:14:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:43:43 UTC