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.

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

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.


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

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 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

To make it more interesting,

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

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

Received on Monday, 26 January 2009 07:44:54 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:45 UTC