You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2019/07/23 18:08:18 UTC
Can't have an array of arrays?
Hello DFDL community,
My input contains an array of fruit values, separator, array of wood values, separator, and an array of color values:
Apple
Banana
Orange
Watermelon
Grapes
Cantaloupe
----
Oak
Pine
Maple
----
Red
Green
Purple
Blue
I thought this DFDL schema would do the trick:
<xs:element name="input">
<xs:complexType>
<xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="infix">
<xs:element name="fruit" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
<xs:sequence dfdl:hiddenGroupRef="separatorGroup" />
<xs:element name="wood" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
<xs:sequence dfdl:hiddenGroupRef="separatorGroup" />
<xs:element name="color" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="separatorGroup">
<xs:sequence>
<xs:element name="separator" type="xs:string">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert test="{. eq '----'}" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:group>
Sadly, that produces this error:
[error] Schema Definition Error: occursCountKind='implicit' with unbounded maxOccurs only allowed for last element of a positional sequence
What is the correct way to express an array of arrays?
/Roger
Re: Can't have an array of arrays?
Posted by "Sloane, Brandon" <bs...@tresys.com>.
In your case, I believe you want to use dfdl:occursCountKind="stopValue".
I am not 100% sure this feature is implemented in Daffodil yet. If not, you would want to use dfdl:occursCountKind="parsed", and put an assert on each of your types that they are not the value "----"
________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Tuesday, July 23, 2019 2:08:18 PM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: Can't have an array of arrays?
Hello DFDL community,
My input contains an array of fruit values, separator, array of wood values, separator, and an array of color values:
Apple
Banana
Orange
Watermelon
Grapes
Cantaloupe
----
Oak
Pine
Maple
----
Red
Green
Purple
Blue
I thought this DFDL schema would do the trick:
<xs:element name="input">
<xs:complexType>
<xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="infix">
<xs:element name="fruit" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
<xs:sequence dfdl:hiddenGroupRef="separatorGroup" />
<xs:element name="wood" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
<xs:sequence dfdl:hiddenGroupRef="separatorGroup" />
<xs:element name="color" type="xs:string" maxOccurs="unbounded"
dfdl:occursCountKind="implicit" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="separatorGroup">
<xs:sequence>
<xs:element name="separator" type="xs:string">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert test="{. eq '----'}" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:group>
Sadly, that produces this error:
[error] Schema Definition Error: occursCountKind='implicit' with unbounded maxOccurs only allowed for last element of a positional sequence
What is the correct way to express an array of arrays?
/Roger