| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <tdml:testSuite suiteName="ProcessingErrorTests" |
| description="Section 2.3 - Processing Errors" xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" |
| xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:ex="http://example.com" xmlns:fn="http://www.w3.org/2005/xpath-functions" |
| > |
| |
| <!-- ===================================================================== |
| Schemas ======================================================================= --> |
| |
| <!-- DFDL-782: User test exposed an non-exhaustive match case due to using |
| A custom TraceRunner as the Debugger. Last element (Subject) must not possess |
| a CRLF terminating it in the data. --> |
| <tdml:defineSchema name="dfdl782"> |
| |
| <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/> |
| <dfdl:format ref="ex:GeneralFormat" initiator="" |
| terminator="" textBidi="no" floating="no" encoding="utf-8" byteOrder="bigEndian" |
| alignment="1" alignmentUnits="bytes" fillByte="f" occursCountKind="implicit" |
| truncateSpecifiedLengthString="no" ignoreCase="no" representation="text" |
| lengthKind="delimited" nilValueDelimiterPolicy="both" |
| emptyValueDelimiterPolicy="none" documentFinalTerminatorCanBeMissing="yes" |
| initiatedContent="no" separatorSuppressionPolicy="never" |
| separatorPosition="infix" /> |
| |
| <xsd:element name="Root"> |
| <xsd:annotation> |
| <xsd:appinfo source="http://www.ogf.org/dfdl/"> |
| <!-- use asserts to make sure each header appears the correct number |
| of times --> |
| <dfdl:assert message="Date must appear 1 time." |
| test="{ (fn:count(ex:RootArray/ex:Date) eq 1) }" /> |
| <dfdl:assert message="From must appear 1 time." |
| test="{ (fn:count(ex:RootArray/ex:From) eq 1) }" /> |
| <dfdl:assert message="To must appear 0 or 1 times." |
| test="{ (fn:count(ex:RootArray/ex:To) lt 2) }" /> |
| <dfdl:assert message="Subject must appear 1 time." |
| test="{ (fn:count(ex:RootArray/ex:Subject) eq 1) }" /> |
| </xsd:appinfo> |
| </xsd:annotation> |
| <xsd:complexType> |
| <xsd:sequence> |
| <xsd:element name="RootArray" dfdl:occursCountKind="implicit" |
| minOccurs="1" maxOccurs="unbounded"> |
| <xsd:complexType> |
| <xsd:choice dfdl:initiatedContent="yes"> |
| <xsd:element name="Date" dfdl:initiator="Date:%SP;" |
| dfdl:terminator="%CR;%LF;" type="xsd:string" /> |
| <xsd:element name="From" dfdl:initiator="From:%SP;" |
| dfdl:terminator="%CR;%LF;" type="xsd:string" /> |
| <xsd:element name="To" dfdl:initiator="To:%SP;" |
| dfdl:terminator="%CR;%LF;" type="xsd:string" /> |
| <xsd:element name="Subject" dfdl:initiator="Subject:%SP;" |
| dfdl:terminator="%CR;%LF;" type="xsd:string" /> |
| </xsd:choice> |
| </xsd:complexType> |
| </xsd:element> |
| </xsd:sequence> |
| </xsd:complexType> |
| </xsd:element> |
| |
| </tdml:defineSchema> |
| |
| <!-- ===================================================================== |
| Tests ======================================================================== --> |
| |
| <!-- DFDL-782: User test exposed an non-exhaustive match case due to using |
| A custom TraceRunner as the Debugger. Last element (Subject) must not possess |
| a CRLF terminating it in the data. --> |
| |
| <tdml:parserTestCase name="test_DFDL_782" root="Root" |
| model="dfdl782" description="Section 2 - Schema Component Constraint - DFDL-2-005R5-1"> |
| |
| <tdml:document> |
| <tdml:documentPart type="text"><![CDATA[Date: SomeDate]]></tdml:documentPart> |
| <tdml:documentPart type="byte">0D0A</tdml:documentPart> |
| <tdml:documentPart type="text"><![CDATA[From: john@doe.com]]></tdml:documentPart> |
| <tdml:documentPart type="byte">0D0A</tdml:documentPart> |
| <tdml:documentPart type="text"><![CDATA[To: jane@doe.com]]></tdml:documentPart> |
| <tdml:documentPart type="byte">0D0A</tdml:documentPart> |
| <tdml:documentPart type="text"><![CDATA[Subject: Hello World!]]></tdml:documentPart> |
| </tdml:document> |
| |
| <tdml:errors> |
| <tdml:error>Subject must appear 1 time.</tdml:error> |
| </tdml:errors> |
| |
| </tdml:parserTestCase> |
| |
| <!-- User submitted test DFDL-791: Dynamic Separator using variables broken --> |
| <tdml:parserTestCase name="test_prefix_separator_as_variable" root="MultipartBody" |
| model="MultipartBody.dfdl.xsd" description="Use of variable in separator - DFDL-7-091R"> |
| <tdml:document> |
| <tdml:documentPart type="file">test_prefix_separator_as_variable</tdml:documentPart> |
| </tdml:document> |
| |
| <tdml:infoset> |
| <tdml:dfdlInfoset type="file">test_prefix_separator_as_variable.expected.xml |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <!-- DFDL-2262: User test exposed in separator suppression when |
| occursCountKind="expression". Separators and empty elements should never be supressed |
| in this case. --> |
| <tdml:parserTestCase name="test_DFDL_2262" root="CSV" model="Book2.dfdl.xsd" roundTrip="twoPass" |
| description="Demonstrates that separators are not suppressed when OCK='expression'"> |
| <tdml:document> |
| <tdml:documentPart type="file">Book2.csv</tdml:documentPart> |
| </tdml:document> |
| |
| <tdml:infoset> |
| <tdml:dfdlInfoset type="file">test_Book2.expected.xml</tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <!-- Schema for DFDL-2399 test--> |
| <tdml:defineSchema name="dfdl2399"> |
| <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" /> |
| |
| <dfdl:format ref="GeneralFormat" |
| lengthKind="delimited" |
| separatorSuppressionPolicy="trailingEmpty" /> |
| |
| <xs:element name="message"> |
| <xs:complexType> |
| <xs:sequence> |
| <xs:element ref="record"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="record" dfdl:initiator="record" dfdl:terminator="%NL;"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="|" dfdl:separatorPosition="prefix"> |
| <xs:sequence dfdl:separator="~" dfdl:separatorPosition="infix"> |
| <xs:element name="field1" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> |
| </xs:sequence> |
| <xs:sequence dfdl:separator="~" dfdl:separatorPosition="infix"> |
| <xs:element name="field2" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> |
| </xs:sequence> |
| <xs:sequence dfdl:separator="~" dfdl:separatorPosition="infix"> |
| <xs:element name="field3" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> |
| </xs:sequence> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| </tdml:defineSchema> |
| |
| <tdml:parserTestCase name="test_DFDL_2399" |
| root="record" model="dfdl2399" |
| description="Demonstrate that a sequence which contains minOccurs=0, delimited sequences |
| which are empty do not return both a succesful parse and errors."> |
| <tdml:document> |
| <tdml:documentPart type="text" replaceDFDLEntities="true">record|field1%CR;%LF;</tdml:documentPart> |
| </tdml:document> |
| |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:record xmlns:ex="http://example.com"><ex:field1>field1</ex:field1></ex:record> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| |
| </tdml:parserTestCase> |
| |
| <tdml:defineSchema name="dfdlwg1" elementFormDefault="unqualified"> |
| <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/> |
| |
| <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited"/> |
| |
| <!-- wrong way to get zero-extended 9-digit numbers --> |
| <xs:element name="r" dfdl:textNumberPattern="#0" type="ex:numeric9_custom1"/> |
| |
| <!-- right way to get zero-extended 9-digit numbers --> |
| <xs:element name="r2" dfdl:textNumberPattern="#00000000" type="ex:numeric9_custom1"/> |
| |
| <xs:simpleType name="numeric9_custom1" |
| dfdl:textOutputMinLength="9" |
| dfdl:textPadKind="padChar" |
| dfdl:textTrimKind="padChar" |
| dfdl:textNumberPadCharacter="0"> |
| <xs:restriction base="xsd:decimal"> |
| <xs:totalDigits value="9"/><!-- note totalDigits for an integer does NOT include any sign. --> |
| </xs:restriction> |
| </xs:simpleType> |
| |
| </tdml:defineSchema> |
| |
| <tdml:unparserTestCase name="textNumberPattern1" model="dfdlwg1" |
| description="illustrates that text number padding on left |
| (right justified numbers) does not go between the sign and the |
| value digits but before the entire number representation. This is |
| the right behavior per the DFDL spec."> |
| <tdml:document><![CDATA[0000000-1]]></tdml:document> |
| <tdml:infoset><tdml:dfdlInfoset> |
| <ex:r>-1</ex:r> |
| </tdml:dfdlInfoset></tdml:infoset> |
| </tdml:unparserTestCase> |
| |
| <tdml:unparserTestCase name="textNumberPattern2" model="dfdlwg1" |
| description="illustrates the proper technique for getting the sign to appear |
| before the digits of a right-justified number. Negative sign case."> |
| <tdml:document><![CDATA[-00000001]]></tdml:document> |
| <tdml:infoset><tdml:dfdlInfoset> |
| <ex:r2>-1</ex:r2> |
| </tdml:dfdlInfoset></tdml:infoset> |
| </tdml:unparserTestCase> |
| |
| <tdml:unparserTestCase name="textNumberPattern3" model="dfdlwg1" |
| description="illustrates the proper technique for getting the sign to appear |
| before the digits of a right-justified number. Positive (without sign) case."> |
| <tdml:document><![CDATA[000000001]]></tdml:document> |
| <tdml:infoset><tdml:dfdlInfoset> |
| <ex:r2>1</ex:r2> |
| </tdml:dfdlInfoset></tdml:infoset> |
| </tdml:unparserTestCase> |
| </tdml:testSuite> |