Data Format Description Language (DFDL) v1.0 Specification
OGF Proposed Recommendation GFD-P-R.174, January 31, 2011
This section describes the processing for nil and default.
Sometimes it is desirable to represent an unshipped element, unknown information, or inapplicable information explicitly with an element, rather than by an absent element. For example, it may be desirable to represent a "null" value being sent to or from a relational database with an element that is present. Such cases can be represented using the DFDL nil mechanism which is based on the XML Schema's nil mechanism and allows "out of band" nil values. Nil processing is used when the XSDL ‘nillable’ attribute of an element is true.
Default processing provides a value for an element that is missing from the data stream on parsing or the infoset on unparsing. Default processing applies to both simple and complex elements.
Definition ‘has default’
A simple element has a default if any of these are true:
The xs:default attribute exists. The default value is the attribute’s value.
The xs:fixed attribute exists. The default value is the attribute’s value.
The element has xs:nillable='true' and dfdl:useNilForDefault is specified. The default value is nil.
A complex element has a default if either:
The content is a sequence and all the required children of a complex element have a default.
The content is a choice and one of the choice branches has a default. The default is the first choice branch in schema definition order to have a default.
Otherwise the element has no default.
Definition: 'required parent context'
A required element (defined below) is only required when its enclosing parent element is one of the following
The document root
A required element within a sequence.
An optional element that is not missing within a sequence
The selected branch of a xs:choice
Definition: 'required element'
When an element is in a 'required parent context', we define the term 'required element' to be :
A scalar element
An element of a fixed-occurrence array
An element of a variable-occurrence array if its index is less than or equal to the value of minOccurs.
On parsing, a required element in a required parent context must produce a value in the infoset otherwise it is a processing error.
On unparsing a required element in a required parent context must produce a value in the augmented infoset otherwise it is a processing error.
Definition 'missing element'
On parsing, an element is missing
IF an intiator is defined AND dfdl:emptyValueDelimiterPolicy is 'initiator' or 'both' but the initiator is not found in the data stream.
OR the content region in the data stream is empty.
On unparsing, an element is missing if it is not in the infoset.
Definition 'is nil'
On parsing an element is nil if xs:nillable is 'true' AND one of the following:
dfdl:nilKind is 'logicalValue' and the SimpleRepresentation region of the data stream, converted to its logical type, matches any of the dfdl:nilValue values.
dfdl:nilKind is 'literalValue' and the SimpleRepresentation region of the data stream matches any of the dfdl:nilValue values
dfdl:nilKind is ‘literalCharacter’ and all characters in the SimpleRepresentation region of the data stream match the dfdl:nilValue character.
On unparsing an element is nil if xs:nillable is 'true' AND the element value is nil in the infoset.
Definition 'nil output representation'
The 'nil output representation' is one of the following:
When dfdl:nilKind is 'logicalValue' then the representation value is the first value of dfdl:nilValue converted to the physical representation.
When dfdl:nilKind is 'literalValue' then the representation value is the first value of dfdl:nilValue
When dfdl:nilKind is ‘literalCharacter’ then the representation value is the character from dfdl:nilValue repeated to the required length
For simple elements the following applies:
If 'missing element':
If both dfdl:initiator and dfdl:terminator are not specified
If 'is nil' then the infoset value is nil
Else if 'required element', and 'has a default' then the infoset value is the value provided by the default
Else If 'required element', it is a processing error
Otherwise nothing is added to the infoset
Otherwise
If 'is nil' and the initiator and/or terminator comply with dfdl:nilValueDelimiterPolicy then the infoset value is nil
Else if 'required element', and 'has a default' and the initiator and/or terminator comply with dfdl:emptyValueDelimiterPolicy then the infoset value is the value provided by the default
Else If 'required element', it is a processing error
Otherwise nothing is added to the infoset
Otherwise
If both dfdl:initiator and dfdl:terminator are not specified
If 'is nil' then the infoset value is nil
Otherwise the infoset value is the parsed value from the data stream
Otherwise
If 'is nil' and the initiator and/or terminator comply with dfdl:nilValueDelimiterPolicy then the infoset value is nil
Otherwise the infoset value is the parsed value from the data stream
For complex elements the following applies:
If 'missing element':
If both dfdl:initiator and dfdl:terminator are not specified
If 'required element', and 'has a default' then the element is added to the Infoset and 'missing element' processing is applied to all child elements.
Else if 'required element' it is a processing error
Otherwise nothing is added to the infoset
Otherwise
If 'required element', and 'has a default' and the initiator and/or terminator comply with dfdl:emptyValueDelimiterPolicy then the element is added to the infoset and 'missing element' processing is applied to all child elements.
Else if 'required element' it is a processing error
Otherwise nothing is added to the infoset
Otherwise the element is added to the infoset.
For simple elements the following applies:
If 'missing element'
If both dfdl:initiator and dfdl:terminator are not specified
If 'required element' and 'has a default' then the output value is the unparsed value provided by the default.
Else if 'required element' it is a processing error
Otherwise nothing is output
Otherwise
If 'required element' and 'has a default' then the output value is the unparsed value provided by the default, with initiator and/or terminator as controlled by dfdl:emptyValueDelimiterPolicy if the value is the empty string or dfdl:nilValueDelimiterPolicy if dfdl:useNilForDefault' is 'true' .
Else if 'required element' it is a processing error
Otherwise nothing is output
Otherwise
If xs:nillable is not 'true' and the infoset value is nil it is a processing error.
Else if both dfdl:initiator and dfdl:terminator are not specified
If 'is nil' then the 'nil output representation' is output .
Otherwise the output value is the unparsed value from the infoset..
Otherwise
If 'is nil' then the 'nil output representation' is output with initiator and/or terminator as controlled by dfdl:nilValueDelimiterPolicy.
Otherwise the output value is the unparsed value from the infoset with initiator and/or terminator as controlled by dfdl:emptyValueDelimiterPolicy if the value is the empty string.
For complex elements the following applies:
If 'missing element'
If both dfdl:initiator and dfdl:terminator are not specified
If 'required element' and 'has a default' then 'missing element' processing is applied to all child elements.
Else if 'required element' it is a processing error
Otherwise nothing is output
Otherwise
If 'required element' and 'has a default' then 'missing element' processing is applied to all child elements, and initiator and/or terminator are output (as controlled by dfdl:emptyValueDelimiterPolicy if the children’s total representation is the empty string).
Else if 'required element' it is a processing error
Otherwise nothing is output
Otherwise
If dfdl:initiator and dfdl:terminator are not specified then nothing is output for this element .
Else if dfdl:initiator and/or dfdl:terminator are specified then the initiator and/or terminator are output as controlled by dfdl:emptyValueDelimiterPolicy if the children’s total representation is the empty string
Copyright (C) Open Grid Forum (2005-2010). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the OGF or other organizations, except as needed for the purpose of developing Grid Recommendations in which case the procedures for copyrights defined in the OGF Document process must be followed, or as required to translate it into languages other than English.