| <?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 xmlns:ex="http://example.com" xmlns="http://example.com" |
| 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:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions" |
| xmlns:fn="http://www.w3.org/2005/xpath-functions" |
| xmlns:tns="http://example.com"> |
| |
| <tdml:defineSchema name="inputTypeCalc-Embedded.dfdl.xsd"> |
| |
| <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/> |
| <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited" |
| lengthUnits="bytes" encoding="UTF-8" separator="" initiator="" |
| terminator="" occursCountKind="parsed" ignoreCase="no" |
| textNumberRep="standard" representation="binary" /> |
| |
| <xs:simpleType name="uint8" dfdl:lengthKind="explicit" dfdl:length="1"> |
| <xs:restriction base="xs:unsignedInt"/> |
| </xs:simpleType> |
| |
| <xs:simpleType name="AbstractIntTo1" dfdlx:repType="xs:int" dfdlx:inputTypeCalc="{ 1 }"> |
| <xs:restriction base="xs:int"/> |
| </xs:simpleType> |
| |
| <xs:simpleType name="AbstractIntToXYZ" dfdlx:repType="xs:int" dfdlx:inputTypeCalc="{ 'xyz' }"> |
| <xs:restriction base="xs:string"/> |
| </xs:simpleType> |
| |
| <xs:simpleType name="Abstract1FromInt" dfdlx:repType="xs:int" dfdlx:outputTypeCalc="{ 1 }"> |
| <xs:restriction base="xs:int"/> |
| </xs:simpleType> |
| |
| <xs:simpleType name="AbstractXYZFromInt" dfdlx:repType="xs:string" dfdlx:outputTypeCalc="{ 'xyz' }"> |
| <xs:restriction base="xs:int"/> |
| </xs:simpleType> |
| |
| <xs:simpleType name="AbstractIntToStringByKeyset" dfdlx:repType="xs:int"> |
| <xs:restriction base="xs:string"> |
| <xs:enumeration value="one" dfdlx:repValues="1"/> |
| <xs:enumeration value="zero" dfdlx:repValues="0"/> |
| </xs:restriction> |
| </xs:simpleType> |
| |
| <xs:element name="inputTypeCalcInt_01" type="xs:int" dfdl:inputValueCalc="{ dfdlx:inputTypeCalc('tns:AbstractIntTo1', 7) }" /> |
| <xs:element name="inputTypeCalcString_01" type="xs:string" dfdl:inputValueCalc="{ dfdlx:inputTypeCalc('tns:AbstractIntToXYZ', 7) }" /> |
| |
| <xs:element name="outputTypeCalcInt_01" dfdlx:parseUnparsePolicy="unparseOnly"> |
| <xs:complexType> |
| <xs:sequence> |
| <xs:element name="inner" type="tns:uint8" dfdl:outputValueCalc="{ dfdlx:outputTypeCalc('tns:Abstract1FromInt', 7) }" /> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| <xs:element name="outputTypeCalcString_01" type="xs:string" dfdl:inputValueCalc="{ dfdlx:outputTypeCalc('tns:AbstractXYZFromInt', 7) }" /> |
| |
| <xs:element name="abstractIntToStringByKeyset_01" type="xs:string" dfdl:inputValueCalc="{dfdlx:inputTypeCalc('AbstractIntToStringByKeyset',0)}"/> |
| |
| <xs:element name="sparse_enum01"> |
| <xs:complexType> |
| <xs:sequence> |
| <xs:element name="byte" maxOccurs="unbounded" dfdl:occursCountKind="parsed"> |
| <xs:complexType> |
| <xs:sequence> |
| <xs:element name="raw" type="tns:uint8"/> |
| <xs:choice dfdl:choiceDispatchKey="{ xs:string(ex:raw) }"> |
| <xs:sequence dfdl:choiceBranchKey="15" dfdlx:choiceBranchKeyRanges="1 3"> |
| <xs:element name="enum" type="tns:sparse_lookup" dfdl:inputValueCalc="{ (dfdlx:inputTypeCalc('tns:sparse_lookup', (../ex:raw))) }"/> |
| </xs:sequence> |
| <xs:sequence dfdl:choiceBranchKey="0" dfdlx:choiceBranchKeyRanges="4 14 16 255"> |
| <xs:element name="undefined" type="xs:int" dfdl:inputValueCalc="{ ../ex:raw }"/> |
| </xs:sequence> |
| </xs:choice> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| </xs:sequence> |
| </xs:complexType> |
| </xs:element> |
| |
| <xs:simpleType name="sparse_lookup" dfdlx:repType="xs:integer"> |
| <xs:restriction base="xs:string"> |
| <xs:enumeration value="one" dfdlx:repValues="1"/> |
| <xs:enumeration value="two" dfdlx:repValues="2"/> |
| <xs:enumeration value="three" dfdlx:repValues="3"/> |
| <xs:enumeration value="fifteen" dfdlx:repValues="15"/> |
| </xs:restriction> |
| </xs:simpleType> |
| |
| |
| </tdml:defineSchema> |
| |
| <tdml:parserTestCase name="inputTypeCalcInt_01" |
| root="inputTypeCalcInt_01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"> |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <inputTypeCalcInt_01>1</inputTypeCalcInt_01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <tdml:parserTestCase name="inputTypeCalcString_01" |
| root="inputTypeCalcString_01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"> |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <inputTypeCalcString_01>xyz</inputTypeCalcString_01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <tdml:unparserTestCase name="outputTypeCalcInt_01" |
| root="outputTypeCalcInt_01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"> |
| 01 |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <outputTypeCalcInt_01><inner>hello</inner></outputTypeCalcInt_01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:unparserTestCase> |
| |
| <tdml:parserTestCase name="outputTypeCalcString_01" |
| root="outputTypeCalcString_01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"> |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <outputTypeCalcString_01>xyz</outputTypeCalcString_01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <tdml:parserTestCase name="abstractIntToStringByKeyset_01" |
| root="abstractIntToStringByKeyset_01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"> |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <abstractIntToStringByKeyset_01>zero</abstractIntToStringByKeyset_01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| <tdml:parserTestCase name="sparse_enum_01" |
| root="sparse_enum01" model="inputTypeCalc-Embedded.dfdl.xsd" description="Extensions - inputTypeCalc keysetValue transform"> |
| |
| <tdml:document> |
| <tdml:documentPart type="byte"><![CDATA[ |
| 00 |
| 01 |
| 02 |
| 03 |
| 04 |
| 05 |
| 0d |
| 0e |
| 0f |
| 10 |
| fe |
| ff |
| ]]> |
| </tdml:documentPart> |
| </tdml:document> |
| <tdml:infoset> |
| <tdml:dfdlInfoset xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| <sparse_enum01> |
| <byte> |
| <raw>0</raw> |
| <undefined>0</undefined> |
| </byte> |
| <byte> |
| <raw>1</raw> |
| <enum>one</enum> |
| </byte> |
| <byte> |
| <raw>2</raw> |
| <enum>two</enum> |
| </byte> |
| <byte> |
| <raw>3</raw> |
| <enum>three</enum> |
| </byte> |
| <byte> |
| <raw>4</raw> |
| <undefined>4</undefined> |
| </byte> |
| <byte> |
| <raw>5</raw> |
| <undefined>5</undefined> |
| </byte> |
| <byte> |
| <raw>13</raw> |
| <undefined>13</undefined> |
| </byte> |
| <byte> |
| <raw>14</raw> |
| <undefined>14</undefined> |
| </byte> |
| <byte> |
| <raw>15</raw> |
| <enum>fifteen</enum> |
| </byte> |
| <byte> |
| <raw>16</raw> |
| <undefined>16</undefined> |
| </byte> |
| <byte> |
| <raw>254</raw> |
| <undefined>254</undefined> |
| </byte> |
| <byte> |
| <raw>255</raw> |
| <undefined>255</undefined> |
| </byte> |
| </sparse_enum01> |
| </tdml:dfdlInfoset> |
| </tdml:infoset> |
| </tdml:parserTestCase> |
| |
| |
| </tdml:testSuite> |