Re: possible bug in p:iteration select

James,

On 30 Sep 2008, at 21:00, James Garriss wrote:
> Ok, I see the idea:  to load documents, I need to use p:load.  But  
> how you used p:load left me confused.  This code doesn't seem right:
>
>    <p:load>
>       <p:option name="href" select="/c:file/@name"/>
>     </p:load>
>
> The href is a URI.  //c:file/@name is an XPath expression,  
> attempting to read the value of the "name" attribute.  Aren't we  
> mixing apples and oranges?


If you had a known URI, you'd do:

   <p:load>
     <p:option name="href" select="'/path/to/file.xml'" />
   </p:load>

Note the single quotes around the URI. That's because the select  
attribute on <p:option> is evaluated as an XPath expression to give  
the URI. So you have to use single quotes to indicate it's a string.

In the case where you have an XML document that holds the information,  
you need to point XProc at the relevant attribute or element using an  
XPath expression. In your case, the name attribute on the <c:file>  
element holds the URI, so you use:

   <p:load>
     <p:option name="href" select="/c:file/@name" />
   </p:load>

The XPath expression is evaluated to give a string (the value of the  
name attribute), and that's the value that's passed to the 'href'  
option.

Make sense?

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com

Received on Tuesday, 30 September 2008 20:12:55 UTC