RE: Can xforms add attributes to elements in instance data?

Jason,

> 	I was recently trying to use xforms to manipulate a
> pretty basic bit of xml. I needed the ability to dynamically 
> add elements AND attributes. The elements bit was ok, I can 
> do that with an xf:insert, but what about attributes?

You need to use xf:duplicate, which is a feature of XForms 1.1 [1]. The
major difference between xf:duplicate and xf:insert is that the latter can
only insert a node into a nodeset, the former can also append a child to a
node.

Despite being a 1.1 feature, we have already implemented xf:duplicate in
formsPlayer, since as you have rightly indicated it is crucial to producing
powerful forms. Forms like our RSS Reader side-bar [2] are only possible
with the new xf:duplicate and xf:destroy features.

I believe other processors have also implemented xf:duplicate/xf:destroy in
their 'version 1' processors, but I don't know which ones for certain, so
it's probably best if those responsible reply to this thread ... just in
case I get it wrong!

If anyone would like to see how xf:duplicate and xf:destroy can be used, you
can view the fully commented source code for the formsPlayer RSS Reader here
(even without installing formsPlayer):

  <http://www.formsPlayer.com/bars/rss-reader.html.txt>

Regards,

Mark

[1] <http://www.w3.org/TR/xforms11/#duplicate-action>

[2] The side-bar is installed automatically when using fP 1.3.
    To access it, go to:

      View >> Explorer Bar >> formsPlayer RSS Reader


Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from
http://www.formsPlayer.com/

Received on Monday, 14 February 2005 10:41:09 UTC