Re: Missing functions in XQuery 1.0 and XPath 2.0 Functions and O perators

 > speaking personally (i.e. without any W3C hats on!) I find this
 > use case compelling -- I have always found it frustrating when
 > languages add simple regexp matching without this, especially as
 > every regexp library I've ever used at the programming language
 > level provides the functionality.

We are 100% in agreement about this one.

 > On decoding URLs and a QUERY_SRING or QUERY_PATH, I suspect you'd
 > also want access to environment variables

Absolutely not! I am simply talking about transforming or querying
documents containing encoded URLs. URL encoding and decoding functions
fit perfectly in a functional language as they do not have any side
effect. This is true for the current fn:escape-url(), and would be
true for fn:unescape-url() (or whatever it is called).

This is a scenario I hit recently: A Web form based on XForms allows
the user to enter an URI, possibly with encoded query parameters, for
example:

http://example.org/rss?url=http%3A%2F%2Fwww.theserverside.com\
%2Fhome%2Fthread.jsp%3Fthread_id%3D21921

That form is submitted. An XForms instance containing that URI is
created, and looks like this:

<form>
   <my-uri>http://example.org/rss?url=http%3A%2F%2Fwww.theserverside.com\
%2Fhome%2Fthread.jsp%3Fthread_id%3D21921</my-uri>
</form>

Now, assume you want to process the XForms instance using XSLT or
XQuery (that's what we typically do in the product my company is
developing), and that you would like to decode the URL. You can easily
parse the string with regexps, with fn:tokenize() for example, and
obtain the value of the "url" parameter:

http%3A%2F%2Fwww.theserverside.com%2Fhome%2Fthread.jsp%3Fthread_id%3D21921

Then you need a function to decode it and get the original URL:

http://www.theserverside.com/home/thread.jsp/thread_id=21921

Somebody must have argued for the presence of fn:escape-url(). I argue
for the presence of the inverse function, both for reasons of
usefulness and of symmetry.

-Erik

Received on Thursday, 16 October 2003 19:16:43 UTC