# Namespace for URI Templates?


By Ben Ramsey

Published on February 22, 2008


I was giving some thought to [Joe Gregorio's](http://bitworking.org/news/) latest draft of [URI Templates](http://tools.ietf.org/html/draft-gregorio-uritemplate-02) and considering how to use them with [paginated feeds](http://tools.ietf.org/html/rfc5005).

For example, I have an Atom Feed that includes the following link elements:

```xml
<link rel="first" type="application/atom+xml;type=feed" href="http://example.org/content"/>
<link rel="last" type="application/atom+xml;type=feed" href="http://example.org/content?idx=48336"/>
<link rel="previous" type="application/atom+xml;type=feed" href="http://example.org/content?idx=1"/>
<link rel="next" type="application/atom+xml;type=feed" href="http://example.org/content?idx=41"/>
```

It's obvious that, to traverse the Feed, the Client need only change the "idx" parameter. So, why not tell the Client that they can do this with a URI Template?

To do this, I could use a `template` element, but in what namespace? That's where my problem comes in.

I've searched all over the [W3C URI mailing list](http://lists.w3.org/Archives/Public/uri/), in addition to the Atom lists and [all](http://www.mnot.net/blog/) [the](http://www.tbray.org/ongoing/) [usual](http://web.archive.org/web/20100124120915/http://snellspace.com/wp/) [suspects](http://intertwingly.net/blog/), but I haven't seen where anyone has made a formal a recommendation.

I did stumble across a [post by James Snell](http://web.archive.org/web/20080226131804/http://www.snellspace.com/wp/?p=469) in which he proposed an approach to create a namespace to describe URI template variable names, but the post is stale (October 2006) and the approach doesn't address the template itself.

So, without a good lead to go on and a strong desire not to create my own namespace, I sent an e-mail to Mark Nottingham asking if he would be interested in considering an update of the [fh namespace](http://tools.ietf.org/html/rfc5005) to include a template element for this purpose?

For example:

```xml
<fh:template>http://example.org/content{-prefix|?idx=|index}</fh:template>
```

But then I found recent [post by Joe Gregorio](http://bitworking.org/news/296/How-To-Do-RESTful-Partial-Updates) that doesn't specifically address this, but does include in one of his examples the following snippet, defining a "t" namespace for the `link_template` element.

```xml
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xmlns:t="http://blah...">
  <t:link_template rel="sub" href="http://example.org/edit/first-post/{-listjoin|;|id}"/>
...
```

I don't know how I feel about having a general purpose `template` element in a separate namespace rather than having various namespaces define their own `template` elements. In the `fh:template` example, the template is within the "feed history" namespace, which gives it meaning; the URI template provided is for feed histories. If there is a separate namespace, then the template can lose context.

So, what do you think? Should there be a separate XML namespace to define URI templates? Is there an effort to do so, and where is the discussion occurring if there is?


