DFDL only supports a limited subset of XPath. In particular, it does not support any looping construct like you are using in your XPath.
What I would do instead is put an assertion on each record, checking that it has the same number of fields as the first record. ________________________________ From: Costello, Roger L. <[email protected]> Sent: Sunday, November 10, 2019 9:27 AM To: [email protected] <[email protected]> Subject: How to check that every record in a CSV file has the same number of fields? Hi Folks, The RFC for CSV says that every record in a CSV file should have the same number of fields. That check is easily expressed in XPath: every $i in *[position() gt 1] satisfies count($i/*) eq count($i/preceding-sibling::*[1]/*) So I added that XPath expression in an assert for the root element (csv): <xs:element name="csv"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:assert test="{ every $i in *[position() gt 1] satisfies fn:count($i/*) eq fn:count($i/preceding-sibling::*[1]/*) }" message="{'Each record should contain the same number of fields.'}" /> </xs:appinfo> </xs:annotation> ... But that yields this error message: [error] Schema Definition Error: Unable to parse expression. Message: '}' expected but '$' found What is the correct way to implement the check that all records have the same number of fields? /Roger
