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

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 UTC