W3C home > Mailing lists > Public > xproc-dev@w3.org > January 2009

RE: Puzzled about options

From: <Toman_Vojtech@emc.com>
Date: Mon, 26 Jan 2009 02:44:00 -0500
Message-ID: <6E216CCE0679B5489A61125D0EFEC7870E4C0C1F@CORPUSMX10A.corp.emc.com>
To: <xproc-dev@w3.org>

> Hi Folks,
> 
> Consider the following examples which show the use of the 
> "select" and "href" options.
> 
> 
> OPTIONS USED AS ATTRIBUTES

There is a difference between specifying the options as attributes (also
called 'the shortcut form') and as child elements (using p:with-option).

When you use the shortcut form, the value is taken as is, as a simple
constant string. If you use <p:with-option name="..." select="...">, the
value of the p:with-option/@select attribute is interpreted (and
evaluated) as an XPath expression, and the option will be assigned the
result of evaluating this expression. See section 4.8.1 of the
specification.

This is why:

<p:store href="/Book/Filename"/>

will use the '/Book/Filename' string value as the value of the 'href'
option. And because p:store interprets 'href' as an URI, it will attempt
to store the document to URI "/Book/Filename" - which is probably not
what you want.

However,

<p:store>
  <p:with-option name="href" select="/Book/Filename"/>
</p:store>

will apply the '/Book/Filename' XPath expression on the current context
first, and then use this as the value for the 'href' option.

--

This works the same for all steps, although for some of them - such as
p:filter - it may be more confusing, since they interpret some of the
options as XPath expressions (for instance, the 'select' option of
p:filter):

<p:filter select="/BookStore/Book[Date=1998]"/>

will take the '/BookStore/Book[Date=1998]' string value and assign it
(as is, as a constant) to the 'select' option. The step then takes this
value and evaluates it as an XPath expression when processing the input
document.

To make it more interesting,

<p:filter>
  <p:with-option name="select" 
    select="/BookStore/Book[Date=1998]"  />
</p:filter>

will first evaluate the '/BookStore/Book[Date=1998]' XPath expression to
get the value for the 'select' option. The step then takes this value
and evaluates it as an XPath expression again. So, in this case, you
have an XPath expression that should evaluate to another XPath
expression...


Regards,
Vojtech
Received on Monday, 26 January 2009 07:44:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 26 January 2009 07:44:54 GMT