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:element ref="make" dfdl:nilValue="-">
    <xs:annotation>
        <xs:appinfo source="http://www.ogf.org/dfdl/";>
            <dfdl:assert test="{ dfdl:checkConstraints(.) }"
                message="Validation of make failed" />
        </xs:appinfo>
    </xs:annotation>
</xs:element>

<xs:element name="make">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Ford" />
            <xs:enumeration value="Chevy" />
            <xs:enumeration value="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:element name="row" maxOccurs="unbounded">
    <xs:complexType>
        <xs:sequence dfdl:separator="," dfdl:separatorPosition="infix">
            <xs:element name="year" type="xs:string" />
            <xs:element ref="make" dfdl:nilValue="-">
                <xs:annotation>
                    <xs:appinfo source="http://www.ogf.org/dfdl/";>
                        <dfdl:assert test="{ dfdl:checkConstraints(.) }"
                            message="Validation of make failed" />
                    </xs:appinfo>
                </xs:annotation>
            </xs:element>
            <xs:element name="model" type="xs:string" />
            <xs:element name="description" type="xs:string" 
dfdl:escapeSchemeRef="Quotes" />
            <xs:element name="price" type="xs:decimal" 
dfdl:textStandardDecimalSeparator="." />
        </xs:sequence>
    </xs:complexType>
</xs:element>





Reply via email to