W3C home > Mailing lists > Public > xproc-dev@w3.org > September 2011

Re: Options as strings. Blech.

From: Florent Georges <fgeorges@fgeorges.org>
Date: Sun, 4 Sep 2011 18:27:57 +0200
Message-ID: <CADyR_r1R+PxJQdnsS_ExZ_fhLO=p45+yYoGVbfVhpZ0eyKTy_A@mail.gmail.com>
To: Norman Walsh <ndw@nwalsh.com>
Cc: XProc Dev <xproc-dev@w3.org>
On 2 September 2011 19:50, Norman Walsh wrote:

  Hi,

> <xsl:value-of select="(1,2)"/> => "1 2"

  This one uses the algorithm in [1] to construct a string out of
the sequence.

> <xsl:value-of select="string((1,2))"/> => err:XPTY004

  This one is a type error because the function string()'s
argument is item()? and you pass a sequence of 2 items.

  BTW, I don't know where this message comes from, but the error
code must be XPTY0004 (with 3 zeros) and not XPTY004 (with only 2
zeros).  Either a C'nP error or a typo in the processor (Saxon I
guess).

> Not sure which of those we should be doing.

  The spec says, about p:with-option/@select: "when XPath 2.0 is
being used, the value is an xs:untypedAtomic."  So I'd thend to
say it implies err:XPTY0004, but this sentence can be interpreted
differently by others.

  In my opinion, the safest is to raise an error, and if the user
really wants to accept sequences, then he/she has to specify
explicitely what to do, for instance:

    <xsl:value-of select="
        string-join(for $i in (1, 2) return string($i))"/>

  That's a bit more verbose, but that's the less-surprise path:
the user has to explicit what to do in such cases.  The problem
is that the XSLT algorithm to construct simple content is very
convenient in lots of cases, but it is not available as one
single standard function (and it is more complex than the example
above in the general case).  It could probably be provided
through a new XProc function, say p:string() or p:make-string(),
refering explicitely to [1]:

    <p:with-option ... select="p:string((1, 2))"/> => "1 2"

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

[1] http://www.w3.org/TR/xslt20/#constructing-simple-content
Received on Sunday, 4 September 2011 16:28:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 4 September 2011 16:28:46 GMT