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 12:06:09 UTC

Daffodil 2.4.0 has changed the usage of the choice element ... yikes!

Hello DFDL community,

My input is a CSV file about automobiles. A dash ( - ) in a field means "no information available." If there is a dash in a field, I want the XML to contain no element for that field. The following works perfectly:

[cid:image001.png@01D5412D.7B476D30]

If I switch the order of the items within the choice, I do not get the desired result:

[cid:image002.png@01D5412D.7B476D30]

This surprises me. Aren't the items within a choice considered unordered? Why does order matter?

Lastly, I omitted dfdl:choiceLengthKind and that produced an error:

[cid:image003.png@01D5412D.7B476D30]

Again, I am surprised. I have never used dfdl:choiceLengthKind on choice's and they have always worked perfectly. Why do I suddenly need to use dfdl:choiceLengthKind? I read the specification on this property. Truthfully, I don't understand what the spec is saying. What is the dfdl:choiceLengthKind property doing?

/Roger



Re: Daffodil 2.4.0 has changed the usage of the choice element ... yikes!

Posted by "Beckerle, Mike" <mb...@tresys.com>.
The items within a choice are not at all unordered in DFDL.


Choices have sequential semantics in DFDL. When parsing the first branch is attempted and only if it fails without discriminator being set is the second branch tried, etc.


Or you can use choiceDispatchKey to go faster and more clearly specify the criteria for branch selection.



________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Tuesday, July 23, 2019 8:06:09 AM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: Daffodil 2.4.0 has changed the usage of the choice element ... yikes!


Hello DFDL community,



My input is a CSV file about automobiles. A dash ( - ) in a field means “no information available.” If there is a dash in a field, I want the XML to contain no element for that field. The following works perfectly:



[cid:image001.png@01D5412D.7B476D30]



If I switch the order of the items within the choice, I do not get the desired result:



[cid:image002.png@01D5412D.7B476D30]



This surprises me. Aren’t the items within a choice considered unordered? Why does order matter?



Lastly, I omitted dfdl:choiceLengthKind and that produced an error:



[cid:image003.png@01D5412D.7B476D30]



Again, I am surprised. I have never used dfdl:choiceLengthKind on choice’s and they have always worked perfectly. Why do I suddenly need to use dfdl:choiceLengthKind? I read the specification on this property. Truthfully, I don’t understand what the spec is saying. What is the dfdl:choiceLengthKind property doing?



/Roger





Re: Daffodil 2.4.0 has changed the usage of the choice element ... yikes!

Posted by "Beckerle, Mike" <mb...@tresys.com>.
choiceLengthKind is a property that has been in the DFDL spec for a while now.


Daffodil hasn't implemented it until this release (2.4.0).


Its purpose is mostly to accomodate a very common situation in fixed-length data where all the branches are extended in length to the length of the longest one. That's what choiceLengthKind 'explicit' means.


The property is now required because all DFDL properties are required. It was a bug in Daffodil that this property wasn't being required.

________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Tuesday, July 23, 2019 8:06:09 AM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: Daffodil 2.4.0 has changed the usage of the choice element ... yikes!


Hello DFDL community,



My input is a CSV file about automobiles. A dash ( - ) in a field means “no information available.” If there is a dash in a field, I want the XML to contain no element for that field. The following works perfectly:



[cid:image001.png@01D5412D.7B476D30]



If I switch the order of the items within the choice, I do not get the desired result:



[cid:image002.png@01D5412D.7B476D30]



This surprises me. Aren’t the items within a choice considered unordered? Why does order matter?



Lastly, I omitted dfdl:choiceLengthKind and that produced an error:



[cid:image003.png@01D5412D.7B476D30]



Again, I am surprised. I have never used dfdl:choiceLengthKind on choice’s and they have always worked perfectly. Why do I suddenly need to use dfdl:choiceLengthKind? I read the specification on this property. Truthfully, I don’t understand what the spec is saying. What is the dfdl:choiceLengthKind property doing?



/Roger