Proposal to allow empty string to be used as a value for DFDL variables of type xs:string and xs:hexBinary (or derived from them) without resorting to using an expression.

To set empty string use the attribute syntax, eg:

<dfdl:defineVariable name="myVar" type="xs:string" defaultValue=""/>
<dfdl:newVariableInstance ref="myVar" defaultValue=""/>
<dfdl:setVariable ref="myVar" value=""/>

The following are schema definition errors as they do not set the value to anything.

<dfdl:setVariable ref="myVar"></dfdl:setVariable>
<dfdl:setVariable ref="myVar"/>

That allows us to apply a semantic to these syntaxes in a future DFDL release if we need to (eg, unsets the value).

Regards

Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair,
OGF DFDL Working Group
IBM SWG, Hursley, UK

smh@uk.ibm.com
tel:+44-1962-815848




From:        Steve Hanson/UK/IBM
To:        Mike Beckerle <mbeckerle.dfdl@gmail.com>,
Cc:        Mark Frost/UK/IBM, Tim Kimber/UK/IBM@IBMGB
Date:        21/11/2012 09:48
Subject:        Re: [DFDL-WG] Fw: setVariable with no value set - supported?



Here's what Sandy had to say on this. He raised a good point about the future possibility of unsetting a variable using the empty syntax.
Steve Hanson Hi Sandy - please can you ping back when free ? Ta!
Sandy (S.) Gao hi steve
Steve Hanson Hi
From DFDL WG call today...
2. What is correct syntax for setting the value of a variable to empty string?
DFDL variables allow both XSDL lexical form and DFDL expressions as values, so it seems
plausible that <dfdl:setVariable ref="x" value=""/> or even <dfdl:setVariable ref="x"/> is an allowed
syntax for setting the value of a string or hexBinary variable to empty string
What's your opinion here?
Syntax for setting a DFDL variable to empty string.
Sandy (S.) Gao the first looks reasonable. if you want to distinguish between an unset value / null value vs. empty value, then you may not want to use the second. in xml, there's a difference between an attribute that's not present and an attribute with empty value.
unless you are using element content as the value for the second case.
Steve Hanson That's the issue - DFDL treats the attr form and element form as equivalent
Sandy (S.) Gao so for non-empty value, you could <setV ... value="abc"/> or <setV ...>abc</setV>?
Steve Hanson correct
Sandy (S.) Gao ic... then i suppose you need to be consistent and allow both of those forms.
but can someone specify a null value? or unset a variable?
Steve Hanson null not allowed
I don't think we allow unsetting either
Good points though
Sandy (S.) Gao if a value is required, then i don't see any issue in this approach.
Steve Hanson ok - I will raise the unset issue, as we don't want to box ourselves in for future
thanks Sandy
Sandy (S.) Gao np... i guess you'll need to add a new element e.g. <unsetValue> or a special value <setV...>##unset</setV> to support it.
Steve Hanson yes - if we don't allow the empty element + missing attr to mean that
Sandy (S.) Gao exactly


Regards

Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair,
OGF DFDL Working Group
IBM SWG, Hursley, UK

smh@uk.ibm.com
tel:+44-1962-815848





From:        Mike Beckerle <mbeckerle.dfdl@gmail.com>
To:        Steve Hanson/UK/IBM@IBMGB,
Date:        19/11/2012 15:11
Subject:        Re: [DFDL-WG] Fw: setVariable with no value set - supported?





Here is the way I would set a variable to the empty string.

<dfdl:setVariable ref="someQName">{ "" }</dfdl:setVariable>

Note that the value is an expression and so must have the {...} surround, the expression returns an empty string as its value.

If you don't mind quoting hell, then

<dfdl:setVariable ref="someQName" value='{ "" }'/>

would also work.

The DFDL validator doesn't catch the error about the value attribute being missing because both the above forms are accepted and XML Schema's validation can't enforce an OR of  "you have to have an element child value OR the value attribute".

This check has to be done by the DFDL implementation itself, not just XSD validation of the DFDL annotations.

On Mon, Nov 19, 2012 at 9:34 AM, Steve Hanson <smh@uk.ibm.com> wrote:
See below...

Regards

Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair,
OGF DFDL Working Group
IBM SWG, Hursley, UK

smh@uk.ibm.com
tel:
+44-1962-815848
----- Forwarded by Steve Hanson/UK/IBM on 19/11/2012 14:23 -----


From:        
Steve Hanson/UK/IBM
To:        
Mark Frost/UK/IBM,
Cc:        
Shane Cartledge/Toronto/IBM@IBMCA, Anita Leung/Toronto/IBM@IBMCA
Date:        
16/11/2012 11:46
Subject:        
Re: setVariable with no value set - supported?



The specific example that Shane gives is invalid anyway as you can't set the value of one of the pre-defined DFDL variables. Assuming a realistic example like:


<dfdl:setVariable ref="myVar"/>


I'm wondering how you would set empty string for an element of type xs:string or xs:hexBinary.


<dfdl:setVariable ref="myVar" value=""/>


But why isn't that the same as


<dfdl:setVariable ref="myVar"></dfdl:setVariable>


which in XML rules is equivalent to:


<dfdl:setVariable ref="myVar"/>


I will raise with the DFDL WG.


Thanks


Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair,
OGF DFDL Working Group
IBM SWG, Hursley, UK

smh@uk.ibm.com
tel:
+44-1962-815848



From:        
Mark Frost/UK/IBM
To:        
Shane Cartledge/Toronto/IBM@IBMCA, Steve Hanson/UK/IBM@IBMGB,
Cc:        
Anita Leung/Toronto/IBM@IBMCA
Date:        
16/11/2012 11:19
Subject:        
Re: setVariable with no value set - supported?



Hi Shane,


While the spec isn't super-specific, I'd interpret it to mean "you must give exactly one of the value attribute or element value"


Spec Section 7.9 :

        "The syntax supports both a dfdl:value attribute and the 'value' being specified by the element value. Only one or the other may be present. (Schema definition error otherwise.)"

Steve:

        do you think altering the spec wording above to something like "
Exactly one of the dfdl:value or the element value must be present.  (Schema definition error otherwise.)"


Regards,
Mark Frost
_____________________________________
MP 211, IBM Hursley, Winchester, SO21 2JN
Phone: (01962) 817009 or x247009
Email:
frostmar@uk.ibm.com




From:        
Shane Cartledge/Toronto/IBM@IBMCA
To:        
Mark Frost/UK/IBM@IBMGB,
Cc:        
Anita Leung/Toronto/IBM@IBMCA
Date:        
15/11/2012 22:56
Subject:        
setVariable with no value set - supported?



Hi Mark,


Do you know if DFDL should supports a setVariable with no value set? Thought this may have already come up with your runtime testing.


For example:


<dfdl:setVariable ref="dfdl:binaryFloatRep"/>


The DFDL specification is not clear on this point, and the DFDL validator does not flag it as an error.


Thanks.


Shane Cartledge
Business Integration Tooling
Phone:
1-905-413-5171, Tie Line: 313-5171


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


--
  dfdl-wg mailing list
 
dfdl-wg@ogf.org
 
https://www.ogf.org/mailman/listinfo/dfdl-wg



--
Mike Beckerle | OGF DFDL WG Co-Chair 
Tel:  781-330-0412


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU