Re: Compute attribute value with set-attribute

This was discussed in detail beginning here :
http://markmail.org/message/pct65tn7p7rj7ky5

And the WG decided to leave it 'as is' for the reasons you mention.

Although I still belive its 'non-ideal' I accept consistancy over idealism 
:)


----- Original Message ----- 
From: "James Sulak" <jsulak@gmail.com>
To: "XProc Dev" <xproc-dev@w3.org>
Sent: Tuesday, April 07, 2009 11:29 AM
Subject: Re: Compute attribute value with set-attribute


It's kind of a shame that in situations the p:with-option select
expression doesn't require any context, the user is still required to
supply one.  For example:

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

    <p:output port="result"/>

    <p:option name="option-a" select="'Hello'"/>
    <p:option name="option-b" select="'World!'"/>

    <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="concat($option-a, ' ', $option-b)">
            <p:empty/>
        </p:with-option>
    </p:add-attribute>

</p:declare-step>

This is a potential gotcha for pipeline writers. On the face of it,
p:empty is superfluous. A solution would be to allow XProc
implementations to conditionally ignore the lack of context when it
doesn't need it.

This is just an idea; I'm not sure if it's actually a good one.  In
practice, I doubt this problem will happen much, since steps generally
have a default readable port available.  And the current approach has
the virtue of consistency, even if it is more verbose.

-James



On Tue, Apr 7, 2009 at 9:27 AM, Florent Georges <fgeorges@gmail.com> wrote:
> 2009/4/7 ? wrote:
>
>> In the first example, you have to use p:empty because there is no
>> default readable port in p:add-attribute (because you are using
>> p:declare-step with no input port for the top-level pipeline).
>
> Thanks! I think I got it now. I think I mixed up the source for
> the step and for the with-option. The following example shows the
> difference between both:
>
> <p:identity>
> <p:input port="source">
> <p:inline>
> <what>world</what>
> </p:inline>
> </p:input>
> </p:identity>
>
> <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="
> concat('Hello, ', what, '!')"/>
> </p:add-attribute>
>
> ==>
>
> <elem a="Hello, world!"/>
>
> Thanks! Regards,
>
> --
> Florent Georges
> http://www.fgeorges.org/
>
>

Received on Tuesday, 7 April 2009 15:51:06 UTC