W3C home > Mailing lists > Public > public-forms@w3.org > April 2010

Could we put the node creation functions back on the agenda for XForms 1.2?

From: Nick Van den Bleeken <Nick.Van.den.Bleeken@inventivegroup.com>
Date: Wed, 21 Apr 2010 09:54:23 +0200
To: "public-forms@w3.org" <public-forms@w3.org>
Message-ID: <98F519CDC2FA6146AE00069E9A1D91FD87074446D2@erganix.dc.intranet>
Hi,

Could we put the node creation functions back on the agenda for XForms 1.2?  I ran into the use case of needing to add an attribute to a node, and this simple thing requires a lot of work in XForms.

Assume that you want to add an attribute 'bar' with value 'baz' to the node 'foo'.

First attempt (setvalue):

<xf:setvalue ref="foo/@bar">baz</ xf:setvalue>

-> This fails because the node 'foo/@bar' doesn't exist


Second attempt (insert):

<xf:instance id="template-instance">
  <templates xmlns="" @bar=""/>
</ xf:instance >

<xf:insert context="foo" origin="instance('template-instance')/@bar/>
<xf:setvalue ref="foo/@bar">baz</ xf:setvalue>

-> This is a lot of markup to just add one attribute (insert action, setvalue action and an instance that contains a 'template' of the attribute)


Proposed solution (XPath function that can create an attribute)

<xf:insert context="foo" origin="xf:attribute('bar', 'baz')/>

-> Due to the XForms xpath function attribute() we aren't required to create the extra instance and only have one insert action. Which is quite author friendly, definitely compared to what you have to do now.



(This is a simplification of the real use case I hit today (again), in which the value wasn't a constant value.)

Regards,

Nick Van den Bleeken
R&D Manager

Phone: +32 3 821 01 70
Office Fax: +32 3 821 01 71
nick.van.den.bleeken@inventivegroup.com <mailto:nick.van.den.bleeken@inventivegroup.com>
http://www.inventivedesigners.com<http://www.inventivedesigners.com/>
Linked in<http://be.linkedin.com/in/nvdbleek>


________________________________
Inventive Designers' Email Disclaimer:
http://www.inventivedesigners.com/email-disclaimer

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
Received on Wednesday, 21 April 2010 07:55:06 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 October 2013 22:06:53 UTC