W3C home > Mailing lists > Public > public-forms@w3.org > November 2011

Re: Node creation functions

From: John Boyer <boyerj@ca.ibm.com>
Date: Wed, 2 Nov 2011 15:15:21 -0700
To: Nick Van den Bleeken <Nick.Van.den.Bleeken@inventivegroup.com>
Cc: public-forms@w3.org
Message-ID: <OFBAF00E85.364BE50E-ON8825793C.0079B6D6-8825793C.007A44F1@ca.ibm.com>
Hi Nick,

One reason I am asking about use cases is because the functions don't, in 
my opinion, contribute as much to readability as I'd like, and at the same 
time it seems like they contribute implementation complexity.

It's a bit bizarre to contruct and XML tree out of a long series of 
function calls, especially when you realize that function parameters tend 
to get evaluated before invoking the function, so technically a larger XML 
gets assembled from the bottom up.

I just started wondering if we really needed to create attributes and 
especially namespace nodes separate from and before containing elements.

By comparison, if we had a parse() function, it seems it would be still 
easy to achieve all the same use cases, but then the actual nodes would 
all be created at once and have a context relative to one another.

Moreover, parse() has other uses that element() and attribute() just don't 
solve.

Cheers,
John M. Boyer, Ph.D.
Distinguished Engineer, IBM Forms and Smarter Web Applications
IBM Canada Software Lab, Victoria
E-Mail: boyerj@ca.ibm.com 

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed: 
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw





From:   Nick Van den Bleeken <Nick.Van.den.Bleeken@inventivegroup.com>
To:     John Boyer/CanWest/IBM@IBMCA
Cc:     "<public-forms@w3.org>" <public-forms@w3.org>
Date:   11/02/2011 08:25 AM
Subject:        Re: Node creation functions



John, 

Thank you for reading this and giving your comments.

For use cases. I use those functions most when I need to set an attribute 
or need to insert an element of which I only have the 'template/structure' 
at design time because the actual values of the attributes and element 
text content are known at run time. Both these cases could be done in 
XForms 1.1 but require you to do extra set value actions after inserting 
the attribute/element. Being able to write the XML fragment inline makes 
the form much more readable in a lot of cases and makes the form less 
complex because you need less actions to fulfill the job (definitely when 
you are inserting multiple nodes at once). 

1) it would be good for the examples to show the serialization of the 
nodes created by the example function calls 
I added this to the wiki
2) more text is needed to indicate what happens, if anything, in invalid 
scenarios, e.g. what if the qname contains an undefined namespace prefix? 
Will add some text for that (the undefined namespace prefix case is 
already covered by XPath expressions in XForms section, but I will repeat 
it here and also say something about invalid qnames in general) 
3) More text needed to describe how the created nodes connect to the rest 
of the machinery of XML.  For example, is the example given really 
intended to assign an ID to an attribute?  Will subsequent calls to id() 
return the node?  Can ID-ness be attached by adding an xsi:type attribute 
to an element being created?  Does attribute creation include the ability 
to create namespace declarations? 
What happens when you clone a node with an insert action and update the 
id/xsi:type attribute? Same should happen here
4) Provide a real example where the attribute() function must be called 
independently of the element() function, such as inserting an attribute. 
I will add that example

Kind 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
www.inventivedesigners.com




On 01 Nov 2011, at 19:58, John Boyer wrote:

We have a wiki page: 
http://www.w3.org/MarkUp/Forms/wiki/Node_Creation_XPath_Functions 

This indicates the functions are "already in Orbeon".  OK, why? 

A too-technical answer is "it would be nice to create elements/attributes 
not expressed beforehand in an instance", but I'm asking what are the use 
cases for the element() and attribute() functions? 

For example, one could say "I was trying to write a form that would be an 
XML editor and so I need to be able to create nodes whose names are 
defined by a user, not by a form author who wrote an instance."  Question: 
Was this the use case, or are there any others? 

Going a bit further, we now have a version of spec-ready text: 
http://www.w3.org/MarkUp/Forms/wiki/XPath_Expressions_Module#Node_creation_Functions 


Feedback: 
1) it would be good for the examples to show the serialization of the 
nodes created by the example function calls 
2) more text is needed to indicate what happens, if anything, in invalid 
scenarios, e.g. what if the qname contains an undefined namespace prefix? 
3) More text needed to describe how the created nodes connect to the rest 
of the machinery of XML.  For example, is the example given really 
intended to assign an ID to an attribute?  Will subsequent calls to id() 
return the node?  Can ID-ness be attached by adding an xsi:type attribute 
to an element being created?  Does attribute creation include the ability 
to create namespace declarations? 
4) Provide a real example where the attribute() function must be called 
independently of the element() function, such as inserting an attribute. 

Thanks, 
John M. Boyer, Ph.D.
Distinguished Engineer, IBM Forms and Smarter Web Applications
IBM Canada Software Lab, Victoria
E-Mail: boyerj@ca.ibm.com 

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed: 
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 



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




picture
(image/png attachment: 01-part)

picture
(image/png attachment: 02-part)

picture
(image/png attachment: 03-part)

Received on Wednesday, 2 November 2011 22:16:36 UTC

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