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

Reply via email to