| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Copyright (c) 2015 Tresys Technology, LLC. All rights reserved. |
| |
| Developed by: Tresys Technology, LLC |
| http://www.tresys.com |
| |
| Permission is hereby granted, free of charge, to any person obtaining a copy of |
| this software and associated documentation files (the "Software"), to deal with |
| the Software without restriction, including without limitation the rights to |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| of the Software, and to permit persons to whom the Software is furnished to do |
| so, subject to the following conditions: |
| |
| 1. Redistributions of source code must retain the above copyright notice, |
| this list of conditions and the following disclaimers. |
| |
| 2. Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimers in the |
| documentation and/or other materials provided with the distribution. |
| |
| 3. Neither the names of Tresys Technology, nor the names of its contributors |
| may be used to endorse or promote products derived from this Software |
| without specific prior written permission. |
| |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE |
| SOFTWARE. |
| --> |
| <tdml:testSuite 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:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.com" |
| suiteName="escapeSchemeUnparse"> |
| |
| <tdml:defineSchema name="delimitedStringsEscapeScheme"> |
| <dfdl:format ref="ex:daffodilTest1" encoding="ascii" lengthUnits="bytes" outputNewLine="%CR;%LF;"/> |
| <dfdl:defineEscapeScheme name="pound"> |
| <dfdl:escapeScheme escapeCharacter='#' |
| escapeKind="escapeCharacter" escapeEscapeCharacter="" extraEscapedCharacters="" generateEscapeBlock="whenNeeded" /> |
| </dfdl:defineEscapeScheme> |
| <dfdl:defineEscapeScheme name='cStyleComment'> |
| <dfdl:escapeScheme escapeBlockStart='/*' |
| escapeBlockEnd='*/' escapeKind="escapeBlock" |
| escapeEscapeCharacter="#" generateEscapeBlock="whenNeeded" extraEscapedCharacters="" /> |
| </dfdl:defineEscapeScheme> |
| |
| <dfdl:defineEscapeScheme name="slashes"> |
| <dfdl:escapeScheme escapeCharacter='/' |
| escapeKind="escapeCharacter" escapeEscapeCharacter="\" extraEscapedCharacters="" generateEscapeBlock="whenNeeded" /> |
| </dfdl:defineEscapeScheme> |
| |
| <xs:element name="e1" dfdl:lengthKind="implicit"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="," > |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound" /> |
| <xs:element name="s2" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="cStyleComment" /> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e2"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator=","> |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound"/> |
| <xs:element name="s2" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e3"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator=","> |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound"/> |
| <xs:element name="s2" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="slashes"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e4" dfdl:lengthKind="implicit"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="," > |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="cStyleComment" /> |
| <xs:element name="s2" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound" /> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e5"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="#"> |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound"/> |
| <xs:element name="s2" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e6"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="," > |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="cStyleComment" minOccurs="0" maxOccurs="5" dfdl:occursCountKind="parsed"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e7"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="," > |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="pound" minOccurs="0" maxOccurs="5" dfdl:occursCountKind="parsed"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:element name="e8"> |
| <xs:complexType> |
| <xs:sequence dfdl:separator="," > |
| <xs:element name="s1" type="xs:string" dfdl:lengthKind="delimited" dfdl:escapeSchemeRef="slashes" minOccurs="0" maxOccurs="5" dfdl:occursCountKind="parsed"/> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| </tdml:defineSchema> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString01 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString01" model="delimitedStringsEscapeScheme" root="e1"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e1 xmlns:ex="http://example.com"> |
| <ex:s1>one, two</ex:s1> |
| <ex:s2>, three and four*/</ex:s2> |
| </ex:e1> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one#, two,/*, three and four#*/*/</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <tdml:parserTestCase name="parseDelimitedEscapedString01" model="delimitedStringsEscapeScheme" root="e1"> |
| <tdml:document>one#, two,/*, three and four#*/*/</tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e1 xmlns:ex="http://example.com"> |
| <ex:s1>one, two</ex:s1> |
| <ex:s2>, three and four*/</ex:s2> |
| </ex:e1> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString02 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString02" model="delimitedStringsEscapeScheme" root="e2"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e2 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s2>three</ex:s2> |
| </ex:e2> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one#,two,three</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString03 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString03" model="delimitedStringsEscapeScheme" root="e3" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e3 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s2>three,four/five</ex:s2> |
| </ex:e3> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one#,two,three/,four\/five</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <tdml:parserTestCase name="parseDelimitedEscapedString03" model="delimitedStringsEscapeScheme" root="e3"> |
| <tdml:document>one#,two,three/,four\/five</tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e3 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s2>three,four/five</ex:s2> |
| </ex:e3> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString04 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString04" model="delimitedStringsEscapeScheme" root="e4" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e4 xmlns:ex="http://example.com"> |
| <ex:s1>/*three</ex:s1> |
| <ex:s2>*/four</ex:s2> |
| </ex:e4> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>/*/*three*/,*/four</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: parseDelimitedEscapedString04 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test was previously failing with memory issues. The test would spin and eventually fail with a Java heap space error (DFDL-1315). This test will remain to demonstrate that the issue has been fixed. The intended functionality of this test is now covered by unparseDelimitedEscapedString04 with roundTrip="true" |
| --> |
| <tdml:parserTestCase name="parseDelimitedEscapedString04" model="delimitedStringsEscapeScheme" root="e4"> |
| <tdml:document>/*three,#*/four</tdml:document> |
| <tdml:errors> |
| <tdml:error>Parse Error</tdml:error> |
| </tdml:errors> |
| </tdml:parserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString05 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString05" model="delimitedStringsEscapeScheme" root="e5"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e5 xmlns:ex="http://example.com"> |
| <ex:s1>test</ex:s1> |
| <ex:s2>double te#st</ex:s2> |
| </ex:e5> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>test#double te##st</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <tdml:parserTestCase name="parseDelimitedEscapedString05" model="delimitedStringsEscapeScheme" root="e5"> |
| <tdml:document>test#double te##st</tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e5 xmlns:ex="http://example.com"> |
| <ex:s1>test</ex:s1> |
| <ex:s2>double te#st</ex:s2> |
| </ex:e5> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString06 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString06" model="delimitedStringsEscapeScheme" root="e6" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e6 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s1>/*three*/</ex:s1> |
| </ex:e6> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>/*one,two*/,/*/*three#*/*/</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString07 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString07" model="delimitedStringsEscapeScheme" root="e6" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e6 xmlns:ex="http://example.com"> |
| <ex:s1>one,</ex:s1> |
| <ex:s1>two</ex:s1> |
| </ex:e6> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>/*one,*/,two</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString08 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString08" model="delimitedStringsEscapeScheme" root="e7" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e7 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s1>three</ex:s1> |
| <ex:s1>fou,,,,r</ex:s1> |
| </ex:e7> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one#,two,three,fou#,#,#,#,r</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString09 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString09" model="delimitedStringsEscapeScheme" root="e8" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e8 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s1>three</ex:s1> |
| <ex:s1>fou/,r</ex:s1> |
| </ex:e8> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one/,two,three,fou\//,r</tdml:document> |
| </tdml:unparserTestCase> |
| |
| <!-- |
| Test Name: unparseDelimitedEscapedString10 |
| Schema: delimitedStringsEscapeScheme |
| Purpose: This test demonstrates unparsing a sequence of delimited strings with escape schemes |
| --> |
| <tdml:unparserTestCase name="unparseDelimitedEscapedString10" model="delimitedStringsEscapeScheme" root="e8" roundTrip="true"> |
| <tdml:infoset> |
| <tdml:dfdlInfoset> |
| <ex:e8 xmlns:ex="http://example.com"> |
| <ex:s1>one,two</ex:s1> |
| <ex:s1>three</ex:s1> |
| <ex:s1>four/</ex:s1> |
| <ex:s1>five</ex:s1> |
| </ex:e8> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| <tdml:document>one/,two,three,four\/,five</tdml:document> |
| </tdml:unparserTestCase> |
| |
| </tdml:testSuite> |