How can I create an unordered list in DFDL?

921 views Asked by At

The current implementations of Data Format Description Language (DFDL) v 1.0 do not support unordered lists. Is there a workaround?

2

There are 2 answers

0
james.garriss On

Yes, there is a workaround. As a simple example, suppose the input text is simply a set of characters (a, b, and c), which can appear in any order. To create an unordered list, create an element for each of the characters. Put them in a containing element, such that the container has an unbounded max number of occurrences and the child elements are all choices.

Conceptually, it looks like this:

Container Element
  Choice
    A Element
    B Element
    C Element

Use a discriminator to test for the existence of each character.

The DFDL schema looks like this (in part)

<xsd:element name="Container" dfdl:occursCountKind="implicit"
    dfdl:terminator="" maxOccurs="unbounded" minOccurs="1" >
    <xsd:complexType>
        <xsd:choice>
            <xsd:element name="a" dfdl:length="1" dfdl:lengthKind="explicit"
                fixed="a" minOccurs="1" type="xsd:string">
                <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                        <dfdl:discriminator>{. eq 'a'}</dfdl:discriminator>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="b" dfdl:length="1" dfdl:lengthKind="explicit"
                fixed="b" minOccurs="1" type="xsd:string">
                <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                        <dfdl:discriminator>{. eq 'b'}</dfdl:discriminator>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="c" dfdl:length="1" dfdl:lengthKind="explicit"
                fixed="c" minOccurs="1" type="xsd:string">
                <xsd:annotation>
                    <xsd:appinfo source="http://www.ogf.org/dfdl/">
                        <dfdl:discriminator>{. eq 'c'}</dfdl:discriminator>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
    </xsd:complexType>
</xsd:element>

:

0
Steve Hanson On

IBM's implementation now supports dfdl:sequenceKind="unordered" as per the DFDL 1.0 spec.