Comment on xquery/xpath operators draft

Given that you're in last call, I hope these comments aren't too late.

I ran into two problems in a recent use of XSLT/XPath 1.0 that do not appear
to be well handled by "XQuery 1.0 and XPath 2.0 Functions and Operators",
W3C Working Draft 02 May 2003.

Problem #1:

My application is one that involves handling of bibliographic metadata on
academic articles found in the ACM Digital Library. These articles have a
page range which may either be a range ("45-203") or a single page ("55").
In my application I wanted to sort the application of templates by the first
page number in ascending order (the XML input is the output of a WebDAV
PROPFIND method):

  <xsl:apply-templates select="D:multistatus/D:response">
     <xsl:sort select="substring-before(D:propstat/D:prop/BIB:pages, '-')"
data-type="number"/>
  </xsl:apply-templates>

This means that I wanted to strip out the numbers up to the dash, if a dash
is present, otherwise use all of the numbers present (i.e., from the two
previous page ranges, I want "45" and "55"). If I use the substring-before
operator (substring-before(., '-') then the first range returns "45" but the
single page returns a null string, since there is no dash present.

Ideally what I'd like is the absence of the second operator (the dash in my
case)  cause the entire string to be returned. This operator could be called
"substring-before-or-full" or somesuch.

It's possible this scenario could be handled by operations on sequences.
After reading the specification it wasn't entirely clear.

Problem #2:

In the same application, I wanted to be able to strip off just the final
path segment of an arbitrary length URI. That is, given:

http://www.webdav.org/articles/january/webdav.pdf
http://ocean.cse.ucsc.edu/repos/articles/january/p3-smith.pdf

I'd like to be able to easily strip out "webdav.pdf" and "p3-smith.pdf".
Using substring-after doesn't work, since there are an unknown number of "/"
characters. ends-with doesn't work either, since I don't know ahead of time
what the final path segment will be. What would work is a
"substring-after-last(op1, op2)" that returns the substring of op1 after the
last op2 in the string.


I also ran into lots of problems with date conversions, so I'm really glad
to see such a rich set of date operations in the new draft!

- Jim Whitehead
ejw@cs.ucsc.edu

Received on Wednesday, 16 July 2003 13:07:36 UTC