Re: Compute attribute value with set-attribute

Dear,
You seem to miss the biggest trick of XProc : you should set to empty
the readable port of the with-option

   <p:declare-step xmlns:p="http://www.w3.org/ns/xproc">

      <p:output port="result"/>

      <p:add-attribute match="elem" attribute-name="a">
         <p:input port="source">
            <p:inline>
               <elem/>
            </p:inline>
         </p:input>
         <p:with-option name="attribute-value" select="'value'">
            <p:empty/>
         </p:with-option>
      </p:add-attribute>

   </p:declare-step>
Xmlizer
On Mon, Apr 6, 2009 at 11:12 PM, Florent Georges <fgeorges@fgeorges.org> wrote:
>
>  Hi,
>
>  I want to set an attribute on an element using an XPath
> expression.  So I use the step p:add-attribute, with a
> p:with-option for the attribute-value option:
>
>    <p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
>
>       <p:output port="result"/>
>
>       <p:add-attribute match="elem" attribute-name="a">
>          <p:input port="source">
>             <p:inline>
>                <elem/>
>             </p:inline>
>          </p:input>
>          <p:with-option name="attribute-value" select="'value'"/>
>       </p:add-attribute>
>
>    </p:declare-step>
>
> but I get an error running this pipeline:
>
>    Error : .../bug-calabash.xproc:15: option attribute-value
>    unbound on p:add-attribute step named #ANON.86 and no default
>    readable port.
>
>  If I set the option through the attribute:
>
>    <p:add-attribute match="elem" attribute-name="a" attribute-value="value">
>       <p:input port="source">
>          <p:inline>
>             <elem/>
>          </p:inline>
>       </p:input>
>    </p:add-attribute>
>
> everything runs fine and I get the expected result:
>
>    <elem a="value"/>
>
>  I use Calabash 0.9.7.  Did I miss something obvious with the
> step p:set-attribute or with options?
>
>  Regards,
>
> --
> Florent Georges
> http://www.fgeorges.org/
>

Received on Tuesday, 7 April 2009 05:51:25 UTC