Although you've specified the dfdl:nilValue property, that property only has an affect when an element has the "nillable" attribute set to ="true". Otherwise the value is ignored.
So since that is ignored, Daffodil will parse a make value of "-", which fails the enumeration restriction and causes the parse the stop. Adding nillabe="true" to your make element should get it to parse the way you expect. - Steve On 4/9/19 10:05 AM, Costello, Roger L. wrote: > Hello DFDL community, > > I have a CSV file containing data about automobiles. In some cases, I do not > know the make of the car, so I would like to place a dash in the field for > make. > Here is a sample CSV file: > > Year,Make,Model,Description,Price > 1997,Ford,E350,"ac, abs, moon",2999.99 > 1999,Chevy,Venture Extended Edition,,4900.00 > 1999,-,Venture Extended Edition,Very Large,5000.00 > 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00 > > Note the dash in the second field of the next-to-last row. > > I would like Daffodil to check that the Make field contains one of these > values: > Ford, Chevy, or Jeep. If there is no data for the Make, then I want to use > dash. > > Here’s how I declared the make element in my DFDL schema: > > <xs:elementref="make"dfdl:nilValue="-"> > <xs:annotation> > <xs:appinfosource="http://www.ogf.org/dfdl/"> > <dfdl:asserttest="{ dfdl:checkConstraints(.) }" > message="Validation of make failed"/> > </xs:appinfo> > </xs:annotation> > </xs:element> > > <xs:elementname="make"> > <xs:simpleType> > <xs:restrictionbase="xs:string"> > <xs:enumerationvalue="Ford"/> > <xs:enumerationvalue="Chevy"/> > <xs:enumerationvalue="Jeep"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > > When I run Daffodil on the above CSV data, Daffodil does not consume the row > with the dash, nor the following row. Why is that? Am I not understanding the > meaning of dfdl:nilValue? I thought that my schema is saying: The value of > Make > must be Ford, Chevy, or Jeep; if no data is available, then Make may be the > dash. Is that correct? > > Below is the relevant portion of my DFDL schema. /Roger > > <xs:elementname="row"maxOccurs="unbounded"> > <xs:complexType> > <xs:sequencedfdl:separator=","dfdl:separatorPosition="infix"> > <xs:elementname="year"type="xs:string"/> > <xs:elementref="make"dfdl:nilValue="-"> > <xs:annotation> > <xs:appinfosource="http://www.ogf.org/dfdl/"> > <dfdl:asserttest="{ dfdl:checkConstraints(.) }" > message="Validation of make failed"/> > </xs:appinfo> > </xs:annotation> > </xs:element> > <xs:elementname="model"type="xs:string"/> > <xs:elementname="description"type="xs:string"dfdl:escapeSchemeRef="Quotes"/> > <xs:elementname="price"type="xs:decimal"dfdl:textStandardDecimalSeparator="."/> > </xs:sequence> > </xs:complexType> > </xs:element> >
