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

Re: How do I specify a dynamic value for href in p:store?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 17 Jan 2009 17:17:55 +0000
Cc: "'xproc-dev@w3.org'" <xproc-dev@w3.org>
Message-Id: <1745622C-E3A6-4C12-A98C-3C2A3EE2647D@jenitennison.com>
To: "Costello, Roger L." <costello@mitre.org>

Roger,

> I want to use p:foreach to iterate through each <juicer> element and  
> p:store each <juicer> element into a different file, using the child  
> <name> element concatenated with '.xml'
>
> Here's my attempt at it:
>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
>
>        <p:input port="source">
>            <p:document href="juicers.xml"/>
>        </p:input>
>        <p:output port="result" sequence="true" />
>
>    <p:for-each>
>        <p:iteration-source select="//juicer"/>
>        <p:output port="result"/>
>        <p:identity name="juicer" />
>        <p:store name="store">
>            <p:with-option name="href" select="concat(name, '.xml')">
>                <p:pipe step="juicer" port="result"/>
>            </p:with-option>
>        </p:store>
>        <p:identity>
>            <p:input port="source">
>                <p:pipe step="store" port="result"/>
>            </p:input>
>        </p:identity>
>    </p:for-each>
>
> </p:declare-step>


The select attribute is being evaluated in the context of the document  
node for the juicer document, whose document element is a <juicer>  
element. I think you need:

   <xsl:with-option name="href" select="concat(/juicer/name, '.xml')" />

No need for the <p:pipe> inside since that happens by default. I don't  
think there's any need for the <p:identity> before the <p:store> step  
either, but perhaps you're just using that to give yourself an easy  
name to refer to.

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com
Received on Saturday, 17 January 2009 17:18:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 17 January 2009 17:18:31 GMT