Examples of the schema describing the binary data

Overview.

How to use the data converter.

Storage format commands for the converter.

Examples.

The actual data converter page.


Here we gives some examples of schema that can be used in the conversion, as well as schema that be compared with other DFDL solutions. If you click the "try it" button in non-IE browser, the sample data will show up in the converter so you can try it out. Hopefully this gives insight of how the storage format commands work.



A schema that does a hex-dump of a binary file




<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">
  <xsd:element name="hexDump" type="xsd:hexBinary" data:dataCounter="EOF"/>
</xsd:schema>


A schema that generate XML listType



Hexadecimal data
040100020003000400
The schema
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">
  <xsd:element name="listOfIntegers" data:dataCounter="xsd:unsignedByte">
    <xsd:simpleType>
      <xsd:list itemType="xsd:short"/>
    </xsd:simpleType>
  </xsd:element>
</xsd:schema>
Generated XML
<listOfIntegers>1 2 3 4</listOfIntegers>

The fixed length list has not yet implemented. Right now fixed length list is treated as variable length list. So you have to be careful if you dealing with list.


Boolean in attributes, elements and list



Hexadecimal data
010100010104000101000102000100
The schema
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

  <xsd:annotation>
    <xsd:appinfo>   
      <data:format dataCounter="xsd:unsignedShort"/>
    </xsd:appinfo>
  </xsd:annotation>

  <xsd:element name="booleanTest">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="booleanList">
          <xsd:simpleType>
            <xsd:list itemType="xsd:boolean"/>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="booleanElement" type="xsd:boolean" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="attrib1" type="xsd:boolean"/>
      <xsd:attribute name="attrib2" type="xsd:boolean"/>
      <xsd:attribute name="attrib3" type="xsd:boolean"/>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Generated XML
<booleanTest attrib1="true" attrib3="true">
  <booleanList>true true false true</booleanList>
  <booleanElement>true</booleanElement>
  <booleanElement>false</booleanElement>
</booleanTest>

---------------------------------------------------------

Same XML from packed boolean field



Hexadecimal data
0504000B020001
Schema packing booleans
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

  <xsd:annotation>
    <xsd:appinfo>   
      <data:format dataCounter="xsd:unsignedShort" bitField="lowBitFirst"/>
    </xsd:appinfo>
  </xsd:annotation>

  <xsd:element name="booleanTest">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="booleanList">
          <xsd:simpleType>
            <xsd:list itemType="xsd:boolean"/>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="booleanElement" type="xsd:boolean" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="attrib1" type="xsd:boolean"/>
      <xsd:attribute name="attrib2" type="xsd:boolean"/>
      <xsd:attribute name="attrib3" type="xsd:boolean"/>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
The same generated XML
<booleanTest attrib1="true" attrib3="true">
  <booleanList>true true false true</booleanList>
  <booleanElement>true</booleanElement>
  <booleanElement>false</booleanElement>
</booleanTest>

Clearly the binary data is more compact in this case. However, boolean are not always packed even if you specified it to be. This is discussed in more detail in storage formats.


Here is an example in BizTalk 2004 Flat File Schema Tutorial by Tomas Restrepo and how to handle it in this converter. You can compare the BizTalk solution with our solution.



binary data from the tutorial
CITYLIST
CSEATTLE                       WA00198776
SWASHINGTON                    WA
SARIZONA                       AZ
CTUCSON                        AZ89112299
.
MILKPRICES
SEATTLE                         1000USD
TUCSON                         19200USD
or in hexadecimal since the binary data is sensitive to line ending
434954594C4953540D0A4353454154544C452020202020202020202020202020
202020202020202020574130303139383737360D0A5357415348494E47544F4E
202020202020202020202020202020202020202057410D0A534152495A4F4E41
2020202020202020202020202020202020202020202020415A0D0A4354554353
4F4E202020202020202020202020202020202020202020202020415A38393131
323239390D0A2E0D0A4D494C4B5052494345530D0A53454154544C4520202020
202020202020202020202020202020202020202020313030305553440D0A5455
43534F4E20202020202020202020202020202020202020202020202020313932
30305553440D0A

Schema used in our converter:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

  <xs:annotation>
    <xs:appinfo>
      <data:format dataCounter="" fieldWidth="xs:maxLength"/>
    </xs:appinfo>
  </xs:annotation>

  <xs:element name="MultiFile">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CityList">
          <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded" data:itemCounter=".\r\n">
              <xs:element name="City" data:choiceTag="C">
                <xs:complexType>
                <xs:sequence>
                  <xs:element name="Name">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:maxLength value="30"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="State">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:length value="2"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="NumSewers" data:printf="%0*u\r\n">
                    <xs:simpleType>
                      <xs:restriction base="xs:nonNegativeInteger">
                        <xs:totalDigits value="8"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="State" data:choiceTag="S">
                <xs:complexType>
                <xs:sequence>
                  <xs:element name="Name">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:maxLength value="30"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="Initials" type="xs:string" data:dataCounter="\r\n"/>
                </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:choice>
            <xs:attribute name="readFrom" use="required" type="xs:string" data:dataCounter="\r\n"/>
          </xs:complexType>
        </xs:element>
        <xs:element name="MilkPrices">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="MilkPrice" data:itemCounter="EOF">
                <xs:complexType>
                <xs:sequence>
                  <xs:element name="CityName">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:maxLength value="31"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="Price" data:printf="% *u">
                    <xs:simpleType>
                      <xs:restriction base="xs:nonNegativeInteger">
                        <xs:totalDigits value="5"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                  <xs:element name="Currency" type="xs:string" data:printf="%3s\r\n"/>
                </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="readFrom" use="required" type="xs:string" data:dataCounter="\r\n"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>   

Generated XML
<?xml version="1.0"?>
<MultiFile>
  <CityList readFrom="CITYLIST">
    <City>
      <Name>SEATTLE</Name>
      <State>WA</State>
      <NumSewers>00198776</NumSewers>
    </City>
    <State>
      <Name>WASHINGTON</Name>
      <Initials>WA</Initials>
    </State>
    <State>
      <Name>ARIZONA</Name>
      <Initials>AZ</Initials>
    </State>
    <City>
      <Name>TUCSON</Name>
      <State>AZ</State>
      <NumSewers>89112299</NumSewers>
    </City>
  </CityList>
  <MilkPrices readFrom="MILKPRICES">
    <MilkPrice>
      <CityName>SEATTLE</CityName>
      <Price>1000</Price>
      <Currency>USD</Currency>
    </MilkPrice>
    <MilkPrice>
      <CityName>TUCSON</CityName>
      <Price>19200</Price>
      <Currency>USD</Currency>
    </MilkPrice>
  </MilkPrices>
</MultiFile>

Note this in this example and the following examples where we are comparing our solution with other DFDL solutions, we try to use a schema that has a structure that is similar to the schema we are comparing with.

Of course this is not always possible, and we would try to keep the change to a minimum. In this case we have to change the attribute to element because we do not yet support empty element. Anyway I think it is better to use elements rather than attributes here.

In binary file like this one, which is also just a text file, the line ending depends on the platform, and you might have to adjust the schema to accommodate it. Also you must be very careful if you are copying data and paste. It is very easy to introduce an extra blank line and screw up the data.


Here is an example from the Virtual XML Garden



hexadecimal data
01 01 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 f0 3f
02 02 00 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 40
Schema used in our converter:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

 <xs:annotation>
  <xs:appinfo>
    <data:format byteOrder="littleEndian"/>
  </xs:appinfo>
 </xs:annotation>

 <xs:element name="sextet">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="group" minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="byte" type="xs:byte"/>
       <xs:element name="short" type="xs:short"/>
       <xs:element name="int" type="xs:int"/>
       <xs:element name="long" type="xs:long"/>
       <xs:element name="float" type="xs:float"/>
       <xs:element name="double" type="xs:double"/>
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>
Generated XML
<?xml version="1.0"?>
<sextet>
  <group>
    <byte>1</byte>
    <short>1</short>
    <int>1</int>
    <long>1</long>
    <float>1</float>
    <double>1</double>
  </group>
  <group>
    <byte>2</byte>
    <short>2</short>
    <int>2</int>
    <long>2</long>
    <float>2</float>
    <double>2</double>
  </group>
</sextet>
We are able to read and write the binary numeric data types.



Here is another example from the Virtual XML Garden




the binary data
ROSE                KRISTOFFER     0402025555555         
ROSE                SOFUS          0060000000000         
or in hexadecimal since the binary data is sensitive to line ending
524F5345202020202020202020202020202020204B524953544F464645522020
202020303430323032353535353535352020202020202020200D0A524F534520
202020202020202020202020202020534F465553202020202020202020203030
36303030303030303030302020202020202020200D0A
Schema used in our converter:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

 <xs:annotation>
  <xs:appinfo>
   <data:format byteOrder="littleEndian" dataCounter="" fieldWidth="xs:maxLength"/>
  </xs:appinfo>
 </xs:annotation>

  <!-- COPYBOOK types -->

 <xs:simpleType name="last-name">
  <xs:restriction base="xs:string">
   <xs:maxLength value="20"/>
  </xs:restriction>
 </xs:simpleType>

 <xs:simpleType name="first-name">
  <xs:restriction base="xs:string">
   <xs:maxLength value="15"/>
  </xs:restriction>
 </xs:simpleType>

 <xs:simpleType name="age" data:printf="%0*u">
  <xs:restriction base="xs:positiveInteger">
   <xs:totalDigits value="3"/>
  </xs:restriction>
 </xs:simpleType>

 <xs:simpleType name="phone" data:printf="%-19s\r\n">
  <xs:restriction base="xs:string">
   <xs:pattern value="\d{10}"/>
  </xs:restriction>
 </xs:simpleType>
 
 <xs:element name="copybook">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="CUSTOMER-RECORD" minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="CUSTOMER-LAST-NAME" type="last-name"/>
       <xs:element name="CUSTOMER-FIRST-NAME" type="first-name"/>
       <xs:element name="CUSTOMER-AGE" type="age"/>
       <xs:element name="CUSTOMER-PHONE" type="phone"/>
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

</xs:schema>
Generated XML
<?xml version="1.0"?>
<copybook>
  <CUSTOMER-RECORD>
    <CUSTOMER-LAST-NAME>ROSE</CUSTOMER-LAST-NAME>
    <CUSTOMER-FIRST-NAME>KRISTOFFER</CUSTOMER-FIRST-NAME>
    <CUSTOMER-AGE>40</CUSTOMER-AGE>
    <CUSTOMER-PHONE>2025555555</CUSTOMER-PHONE>
  </CUSTOMER-RECORD>
  <CUSTOMER-RECORD>
    <CUSTOMER-LAST-NAME>ROSE</CUSTOMER-LAST-NAME>
    <CUSTOMER-FIRST-NAME>SOFUS</CUSTOMER-FIRST-NAME>
    <CUSTOMER-AGE>6</CUSTOMER-AGE>
    <CUSTOMER-PHONE>0000000000</CUSTOMER-PHONE>
  </CUSTOMER-RECORD>
</copybook>
Compare with the Generated XML from Virtual XML Garden
<copybooks CUSTOMER-RECORD-COUNT="2">
  <CUSTOMER-RECORD>
    <CUSTOMER-LAST-NAME>ROSE                </CUSTOMER-LAST-NAME>
    <CUSTOMER-FIRST-NAME>KRISTOFFER     </CUSTOMER-FIRST-NAME>
    <CUSTOMER-AGE>40</CUSTOMER-AGE>
    <CUSTOMER-PHONE>2025555555</CUSTOMER-PHONE>
  </CUSTOMER-RECORD>
  <CUSTOMER-RECORD>
    <CUSTOMER-LAST-NAME>ROSE                </CUSTOMER-LAST-NAME>
    <CUSTOMER-FIRST-NAME>SOFUS          </CUSTOMER-FIRST-NAME>
    <CUSTOMER-AGE>6</CUSTOMER-AGE>
    <CUSTOMER-PHONE>0000000000</CUSTOMER-PHONE>
  </CUSTOMER-RECORD>
</copybooks>

Comparing with the Virtual XML Garden schema, the obvious difference is that we have removed the customer record count attribute. Since we want XML data that can be edited manually, it is not a good idea for the user who is editing to manually enter the customer record count.

The original data is supposed to be in EBCDIC. Since we cannot deal with EBCDIC, we are using the ASCII equivalent. Another difference is that the age data type is positiveInteger (or maybe it should be nonNegativeInteger in our schema and not int. For us, being int means that it would be stored as 4 bytes integer. So we have to change the data type to reflect the binary/text data. We change the schema so that we use the maxLength facet rather than the length facet is in the Virtual XML Garden. This resulted in the trailing space being stripped off in the XML. Finally the terminator for the phone looks strange with a bunch of spaces before the line ending. This is due to that for some reason there are 9 spaces at the end of each line in the original data.


Here is another example from the Virtual XML Garden



the binary data
[homes]
 comment=Home Directories
 browseable=no
[printers]
 comment=All Printers
 browseable=no
Schema used in our converter:
<xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

 <xs:annotation>
  <xs:appinfo>
    <data:format dataCounter="\r\n"/>
  </xs:appinfo>
 </xs:annotation>

 <xs:element name="configuration">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="section" minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="name" type="xs:string" data:printf="[%s]"/>
       <xs:element name="properties">
        <xs:complexType>
         <xs:all>
          <xs:element name="comment" type="xs:string" data:choiceTag=" comment="/>
          <xs:element name="browseable" minOccurs="0" type="xs:string" data:choiceTag=" browseable="/>
         </xs:all>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>
Generated XML
<?xml version="1.0"?>

<configuration>
 <section>
  <name>homes</name>
  <properties>
   <comment>Home Directories</comment>
   <browseable>no</browseable>
  </properties>
 </section>
 <section>
  <name>printers</name>
  <properties>
   <comment>All Printers</comment>
   <browseable>no</browseable>
  </properties>
 </section>
</configuration>
Compare with the Generated XML from Virtual XML Garden (corrected for what I think is a typo)
<configuration>
 <section>
  <name>homes</name>
  <key><name>comment</name><value>Home Directories</value></key>
  <key><name>browseable</name><value>no</value></key>
  <name>printers</name>
  <key><name>comment</name><value>All Printers</value></key>
  <key><name>browseable</name><value>no</value></key>
 </section>
</configuration>
We are using a different approach here. The key value pair approach reminds me of the Mac OSX plist XML, which I really hate. In the current approach, you have to write a more elaborate schema. However this also mean that you can have a better validation of your data.


Here is a similar example from the XML Convert and XFlat by Unidex Inc.



the binary data
[contact]
name=Nancy Magill
email=lil.magill@blackmountainhills.com
phone=(100) 555-9328
[contact]
email=molly.jones@oblada.com
name=Molly Jones
[contact]
phone=(200) 555-3249
name=Penny Lane
email=plane@bluesuburbanskies.com
Schema used in our converter:
<xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">

 <xs:annotation>
  <xs:appinfo>
    <data:format dataCounter="\r\n"/>
  </xs:appinfo>
 </xs:annotation>

 <xs:element name="contacts">
  <xs:complexType>
   <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF">
     <xs:element name="contact" data:choiceTag="[contact]\r\n">
      <xs:complexType>
       <xs:all>
        <xs:element name="name" type="xs:string" data:choiceTag="name="/>
        <xs:element name="phone" minOccurs="0" type="xs:string" data:choiceTag="phone="/>
        <xs:element name="email" minOccurs="0" type="xs:string" data:choiceTag="email="/>
       </xs:all>
      </xs:complexType>
     </xs:element>
    </xs:choice>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>
Generated XML
<?xml version="1.0"?>
<contacts>
 <contact>
  <name>Nancy Magill</name>
  <email>lil.magill@blackmountainhills.com</email>
  <phone>(100) 555-9328</phone>
 </contact>
 <contact>
  <email>molly.jones@oblada.com</email>
  <name>Molly Jones</name>
 </contact>
 <contact>
  <phone>(200) 555-3249</phone>
  <name>Penny Lane</name>
  <email>plane@bluesuburbanskies.com</email>
 </contact>
</contacts>

Here we do some cheating because we are using choice with a single choice. The reason is that we do not have a item initiator, which I am still thinking about and would like to avoid.

We are using the compositor all instead of choice. This is better because you can avoid the problem of two name fields, although this also rules out two phone fields.


Here is a another example of Xflat from Generating XML Instances from Flat Files in the XML Journal. It is for comma delimited value file. Actually csv is used twice because the name field is then separated into first name and last name using space as the delimiter.



the binary data
123456789,Ram Singh,100000.00
444556666,Barr Clark,87000.00
777227878,Simi? D Roy,123000.00
998877665,Charr Lee,92000.00
Schema used in our converter:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">
 
 <xs:element name="employees">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="employee" type="employee" minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:complexType name="employee">
  <xs:sequence data:csv="true" >
   <xs:element name="ssn" type="xs:string"/>
   <xs:element name="name" type="name"/>
   <xs:element name="salary" type="xs:decimal" data:printf="%.2f"/>
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name="name">
  <xs:sequence data:csvSeparateChar=" " data:csvEscapeChar="?">
   <xs:element name="fName" type="xs:string"/>
   <xs:element name="lName" type="xs:string"/>
  </xs:sequence>
 </xs:complexType>

</xs:schema>
Generated XML
<employees>
  <employee>
    <ssn>123456789</ssn>
    <name>
      <fName>Ram</fName>
      <lName>Singh</lName>
    </name>
    <salary>100000</salary>
  </employee>
  <employee>
    <ssn>444556666</ssn>
    <name>
      <fName>Barr</fName>
      <lName>Clark</lName>
    </name>
    <salary>87000</salary>
  </employee>
  <employee>
    <ssn>777227878</ssn>
    <name>
      <fName>Simi D</fName>
      <lName>Roy</lName>
    </name>
    <salary>123000</salary>
  </employee>
  <employee>
    <ssn>998877665</ssn>
    <name>
      <fName>Charr</fName>
      <lName>Lee</lName>
    </name>
    <salary>92000</salary>
  </employee>
</employees>
Convert the above XML back to binary data again
123456789,Ram Singh,100000.00
444556666,Barr Clark,87000.00
777227878,"""Simi D"" Roy",123000.00
998877665,Charr Lee,92000.00

Here the employee sequence is represented by a csv record. The name field is in turn separated into first and last name using space as the separator. However when you convert from XML back to binary, you do not get back the original binary data. At first sight the newly converted is wrong. The name in the third row looks like garbage. However, they are really logically equivalent. You can convert the new binary data back to the same XML. At first I thought that this is a bug, but now I am convinced that this is the right thing to do. Let us look at how the data would look like in a spreadsheet program.
123456789	Ram Singh	100000
444556666	Barr Clark	87000
777227878	Simi? D Roy	123000
998877665	Charr Lee	92000

123456789	Ram Singh	100000
444556666	Barr Clark	87000
777227878	"Simi D" Roy	123000
998877665	Charr Lee	92000
These two set of data are equivalent to the same XML data. Yet the second set is nicer when we read it from other csv aware application. We shall talk more about this in the discussion about the commands.


We can also use csv on record with variable number of fields. The problem is that one may not know which field belongs to which element. However, this is not a problem if only one single element may have variable occurrence. In fact the most common case is that the only last element has variable occurrence. This is a very common scenario. I often store data in spreadsheet in this manner. Yet I have not seen other converters deal with this problem. This is what we implement now.

Consider a families file, each family consists of a father, a mother and children. So the only variable is number of children.



the binary data
Smith,John,Mary,Peter
Chan,Joseph,Yung,Chris,Jane
Clark,Bob,Patricia
Kane,Bill,Judi
Schema used in our converter:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:data="http://www.datamech.com/storage">
 
 <xs:element name="families">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="family" type="family" minOccurs="0" maxOccurs="unbounded" data:itemCounter="EOF"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:complexType name="family">
  <xs:sequence data:csv="true" >
   <xs:element name="familyName" type="xs:string"/>
   <xs:element name="father" type="xs:string"/>
   <xs:element name="mother" type="xs:string"/>
   <xs:element name="child" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
 </xs:complexType>

</xs:schema>
Generated XML
<?xml version="1.0"?>
<families>
  <family>
    <familyName>Smith</familyName>
    <father>John</father>
    <mother>Mary</mother>
    <child>Peter</child>
  </family>
  <family>
    <familyName>Chan</familyName>
    <father>Joseph</father>
    <mother>Yung</mother>
    <child>Chris</child>
    <child>Jane</child>
  </family>
  <family>
    <familyName>Clark</familyName>
    <father>Bob</father>
    <mother>Patricia</mother>
    </family>
  <family>
    <familyName>Kane</familyName>
    <father>Bill</father>
    <mother>Judi</mother>
    <child>Jerry</child>
  </family>
</families>
So here we have families with none, one or two children, all handled without any problem.



Here we have gone through a number of examples found on the web from various projects. We were able to convert the binary file to XML in each case. Granted that examples given in tutorial are usually fairly simple, we can still say that our converter has fairly good expressive power. There are still scenario that the converter cannot handle, but we are only about 70% feature complete. So we are hopeful that we can have a very flexible converter.