W3C home > Mailing lists > Public > xproc-dev@w3.org > September 2008

Re: p:add/set-attribute and p:label-elements

From: Norman Walsh <ndw@nwalsh.com>
Date: Tue, 30 Sep 2008 12:13:03 -0400
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m2tzbxr4s0.fsf@nwalsh.com>
James Garriss <james@garriss.org> writes:

> It seems that p:add-attribute and p:set-attribute have overlapping
> functionality with p:label-elements.  Can someone plz differentiate these
> for me?  

p:add-attribute adds a single attribute with a single, fixed value to
a set of matching elements.

p:set-attributes adds a collection of attributes, each with a single, fixed
value to a set of matching elements.

In this regard, p:add-attribute is just a convenience step for those
cases where you want to add a single attribute.

<p:add-attribute match="h:div"

is "syntactic sugar" for

<p:set-attributes match="h:div">
  <p:input port="attributes">
      <element-name-doesn't-matter class="org.div"/>

In either case, if you started with


you'd get

 <h:div class='org.div'>
   <h:div class='org.div'>

If you want to set two or more attributes, then p:set-attributes is easier.

What's different about p:label-elements is that the attribute *value*
can vary on a per-element basis.

<p:label-elements match="h:div"
                  label="concat('ID_', $p:index)"/>

would turn the example above into

 <h:div id="ID_1">
   <h:div id="ID_2">


                                        Be seeing you,

Norman Walsh <ndw@nwalsh.com> | The function of the imagination is not
http://nwalsh.com/            | to make strange things settled, so much
                              | as it is to make settled things
                              | strange.--G. K. Chesterton

Received on Tuesday, 30 September 2008 16:13:50 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:03 UTC