Optional indicator in direct element and attribute constructors.

This is an enhancement proposal based upon a very frequently encountered
problem among users of our implementation: an external consumer of XML
generated by XQuery does want to have certain empty elements and
attributes to be omitted. 

For example: 
for a query 
<a><b>{()}</b><c foo="{()}"/></a>, 

instead of returning 
<a><b/><c foo=""/></a>

to return 
<a><c/></a>

Producing this result using computed constructors, conditional
statements and custom functions turns out to be quite inelegant,
cumbersome and hard to maintain.

Proposed extension is to add "optional" indicators, using '?' character
("?"?) to the direct element and attribute constructors:

Change production DirElemConstructor to

[94]    DirElemConstructor    ::=    "<" QName "?"? DirAttributeList
("/>" | (">" DirElemContent* "</" QName S? ">")) /* ws: explicit */ 
   

And for 
[95]    DirAttributeList    ::=    (S (QName "?"? S? "=" S?
DirAttributeValue)?)*

When '?' is present, elements with no children should be omitted, and
attributes with value "" should be omitted.

Query in the example would be written

<a><b?>{()}</b><c foo?="{()}"/></a>

To produce <a><c/></a>

Daniel;

Received on Friday, 13 May 2005 01:52:01 UTC