Data Format Description Language (DFDL) v1.0 Specification
OGF Proposed Recommendation GFD-P-R.174, January 31, 2011
Variables provide a means for communication within a DFDL schema. They are defined as top-level elements in a schema and therefore have global scope. .
<dfdl:defineVariable
name = "NCName"
type? = "qname"
defaultValue? = "logical" value or dfdl expression
external? = ‘false’ | ‘true’ >
<!-- Content: logical value or dfdl expression (default value) -->
</dfdl:defineVariable>
The name of a newly defined variable is placed into the target namespace of the schema containing the annotation. Variable names are distinct from format, escape scheme and number format names and so cannot conflict with them. A variable can have any simple type.
The defaultValue is optional. This is a literal value or an expression which evaluates to a constant, and it can be specified as an attribute or as the element value. The expression must not contain forward references to elements which have not yet been processed nor to the current component. If specified the default value must match the type of the variable (otherwise it is a schema definition error).
Note that the syntax supports both a dfdl:defaultValue attribute and the 'defaultValue' being specified by the element value. Only one or the other may be present. (Schema definition error otherwise.)
Note the value of the name attribute is an NCName. The name of a variable is defined in the target namespace of the schema containing the definition. If multiple dfdl:defineVariable definitions have the same ‘name’ attribute in the same namespace then it is a schema definition error.
The scope of a variable name covers the entire schema in which it is defined. A default instance of the variable is created (with global scope) at the point of definition. Further instances of the variable may subsequently be created on schema elements. If the variable has a default value, this will used as the default value for any instances of the variable (unless overridden when the instance is created).
The external attribute is optional. If not specified it takes the default value ‘false’. If true the value may be provided by the DFDL processor and this external value will be used as the global default value (overriding any dfdl:defaultValue specified on the dfdl:defineVariable). The mechanism by which the processor provides this value is unspecified and implementation specific.
There is no required order between dfdl:defineVariable and other schema level annotations that may refer to the variable. For example, dfdl:defineFormat.
<dfdl:defineVariable name="EDIFACT_DS" type="xs:string"
defaultValue="," />
<dfdl:defineVariable name="codepage" type="xs:string"
external="true">utf-8</dfdl:defineVariable>
Name | Namespace URI | Type | Default value | External |
---|---|---|---|---|
encoding |
http://www.ogf.org/dfdl/dfdl-1.0/ |
xs:string |
'UTF-8' |
true |
byteOrder |
http://www.ogf.org/dfdl/dfdl-1.0/ |
xs:string |
'bigEndian’ |
true |
binaryFloatRep |
http://www.ogf.org/dfdl/dfdl-1.0/ |
xs:string |
'ieee’ |
true |
outputNewLine |
http://www.ogf.org/dfdl/dfdl-1.0/ |
xs:string |
'%LF;' |
true |
<xs:element name="title" type="xs:string">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:element encoding="{$dfdl:encoding}" />
</xs:appinfo>
</xs:annotation>
</xs:element>
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.