Saturday, 28 July 2007
URI Templates Redux
URI Templates -01 is now an Internet-Draft.
After sitting on the spec for a while and trying to figure out an elegant solution to the encoding problem, we decided to take the simple route and see how it sticks. The only encoding that the template spec itself does is for characters that are outside the range of those allowed in URIs. Everything else is application-specifc.
So, for example, this variable;
foo = "/thing?@ <--stüff-->"
with this template:
will get expanded to this:
Notice how the space, angle brackets and non-ASCII characters were encoded, while the forward slash, ampersand and question mark were not.
If you want additional encoding, this needs to happen before the variable is fed to the template processor. This allows template processing to be simple and deterministic; you always know what you're going to get, and pretty much any legal URI can be templated. However, it does put more responsibility on the application to do the encoding to assure that the output is a legal URI.
The hope here is that toolkits will develop sensible patterns for this that will enable template definitions to easily trigger the right pre-encoding. The form that this will take is still up in the air, but I think that's OK for now.