[DFDL-WG] Action Item 049: Built-in specification description and schemas
Suman Kalia
kalia at ca.ibm.com
Mon Feb 1 18:21:37 CST 2010
I am trying to create DFDL definition for COBOL copy book and have
experienced a usability issue with TextNumberFormat which have to be named
and referenced from dfdl:element and dfdl:simpleType annotations. Consider
a sample COBOL copy book, attached below, where I have 3 elements having
PIC 9999 display clause (a.k.a zoned decimal) and 2 external (standard)
decimal. They all have same length but the main difference between them is
number is sign which could leading or trailing. As per the V.38 spec, I
would have to create a named textNumberFormat for each of the picture
clause. The key difference in the named textNumberFormats for these
definitions would be numberPattern and rest of the attributes for standard
decimal and zoned decimal are going to be same for a particular platform
or data definition format. The generated DFDL schema will be containing
many occurrences of TextNumberFormat and in the worst case scenario one
for each element defined in the COBOL copy book. This is not very usable
and also user would have to carefully choose the name for these formats so
he can easily identify and distinguish if wants to resue them something
like TextNumberStandardLength5SignLeading etc..
01 CobolTypes.
* External decimal ( Zoned decimal)
05 elem9 PIC 9999 DISPLAY.
05 elem9Signed PIC S9999 DISPLAY.
05 elem9SignedLeading PIC S9999 DISPLAY
SIGN LEADING.
* in DFDL - modeled as standard decimal
05 elem9SignedLeadingSeparate PIC S9999 DISPLAY
SIGN LEADING SEPARATE.
05 elem9SignedTrailingSeparate PIC S9999 DISPLAY
SIGN TRAILING SEPARATE.
Number Format
When textNumberRepresentation is ‘zoned’ only the pattern for positive
numbers is used. Only the following pattern characters may be used: '+' to
indicate whether the leading or trailing digit carries the overpunched
sign, 'V' to indicate the location of an implied decimal point and '0' to
indicate the number of digits (including overpunched). The number is '0'
characters must match the number of digits in the representation otherwise
it is a schema definition error.
Better approach would be
Add numberPattern to dfdl:element and dfdl:simpleType annotation and rest
of the attributes from TextNumberFormat block to either a) dfdl:format
only or (b) both dfdl:format and dfdl:element and dfdl:simpleType.
Let's discuss this in the DFDL workgroup call tomorrow ..
Attached below is a schema coded with the assumption (a) listed above..
<xsd:complexType name="CobolTypes">
<xsd:sequence>
<!---------------- External Decimal
-------------------------------->
<xsd:element name="elem9" dfdl:ref=
"dfdlCobolFmt:CobolZonedDecimalFormat"
dfdl:length="4" dfdl:representation="text"
dfdl:numberPattern="0000">
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value=
"0" />
<xsd:maxInclusive value=
"9999" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="elem9Signed" dfdl:ref=
"dfdlCobolFmt:CobolZonedDecimalFormat"
dfdl:length="4" dfdl:representation="text"
dfdl:numberPattern="0000+" >
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value=
"-9999" />
<xsd:maxInclusive value=
"9999" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="elem9SignedLeading" dfdl:ref=
"dfdlCobolFmt:CobolZonedDecimalFormat"
dfdl:length="4" dfdl:representation="text"
dfdl:numberPattern="+0000">
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value=
"-9999" />
<xsd:maxInclusive value=
"9999" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="elem9SignedLeadingSeparate"
dfdl:ref="dfdlCobolFmt:CobolStandardDecimalFormat"
dfdl:length="5" dfdl:representation="text"
dfdl:numberPattern="+0000;-00000" >
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value=
"-9999" />
<xsd:maxInclusive value=
"9999" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="elem9SignedTrailingSeparate"
dfdl:ref="dfdlCobolFmt:CobolStandardDecimalFormat"
dfdl:length="5" dfdl:representation="text"
dfdl:numberPattern="0000+;00000-">
<xsd:simpleType>
<xsd:restriction base="xsd:short">
<xsd:minInclusive value=
"-9999" />
<xsd:maxInclusive value=
"9999" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
----- Data format Definitions
<xsd:defineFormat name=
"CobolStandardDecimalFormat">
<xsd:format ref=
"tns:BaseTextNumberStandardDecimal" dfdl:lengthKind="explicit"
dfdl:lengthUnits="bytes"
dfdl:alignment="1" dfdl:alignmentUnits="bytes"
dfdl:leadingSkipBytes="0"
dfdl:trailingSkipBytes="0" />
</xsd:defineFormat>
<xsd:defineFormat name="CobolZonedDecimalFormat">
<xsd:format ref=
"tns:BaseTextNumberZonedDecimal" dfdl:lengthKind="explicit"
dfdl:lengthUnits="bytes"
dfdl:alignment="1" dfdl:alignmentUnits="bytes"
dfdl:leadingSkipBytes="0"
dfdl:trailingSkipBytes="0" />
</xsd:defineFormat>
-- Text number Formats ( added here for reference to identify applicable
attributes for standard and zoned decimal)
<xsd:defineTextNumberFormat name=
"ZonedDecimalNumberFormat">
<xsd:textNumberFormat numberCheckPolicy=
"lax" numberRoundingMode="roundUp"
numberZonedSignStyle=
"asciiStandard" />
</xsd:defineTextNumberFormat>
<xsd:defineTextNumberFormat name=
"StandardDecimalFormat">
<xsd:textNumberFormat
numberGroupingSeparator=","
numberDecimalSeparator="."
numberExponentCharacter="E" numberCheckPolicy="lax"
numberInfinityRep="\u221E"
numberNanRep="\uFFFD" numberRoundingMode="roundUp"
numberZeroRep="" "" />
</xsd:defineTextNumberFormat>
Suman Kalia
IBM Toronto Lab
WMB Toolkit Architect and Development Lead
WebSphere Business Integration Application Connectivity Tools
http://www.ibm.com/developerworks/websphere/zones/businessintegration/wmb.html
Tel : 905-413-3923 T/L 969-3923
Fax : 905-413-4850 T/L 969-4850
Internet ID : kalia at ca.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ogf.org/pipermail/dfdl-wg/attachments/20100201/ffcc692b/attachment-0001.html
More information about the dfdl-wg
mailing list