<?xml version="1.0" encoding="UTF-8"?> | |
<tdml:testSuite 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:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ct="http://w3.ibm.com/xmlns/dfdl/ctInfoset" | |
xmlns:ex="http://example.com"> | |
<tdml:defineSchema name="v"> | |
<dfdl:defineVariable name="v_no_default" type="xsd:int" | |
external="true" /> | |
<dfdl:defineVariable name="v_with_default" type="xsd:int" | |
defaultValue="42" external="true" /> | |
<dfdl:defineVariable name="myVar1" type="xs:int" | |
defaultValue="6" external="true" /> | |
<dfdl:format ref="ex:daffodilTest1" /> | |
<xs:element name="c"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name="d" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_with_default }"> | |
</xs:element> | |
<xs:element name="e" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_no_default }" /> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</tdml:defineSchema> | |
<!-- Overrides define variables --> | |
<tdml:parserTestCase name="override_define_vars_01" | |
root="c" model="v" description="Use of defineVariable and extVariable - DFDL-7-091R"> | |
<tdml:externalVariableBindings xmlns="http://www.w3.org/2001/XMLSchema" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.com"> | |
<tdml:bind name="ex:v_no_default">1</tdml:bind> | |
<tdml:bind name="ex:v_with_default">2</tdml:bind> | |
</tdml:externalVariableBindings> | |
<tdml:document /> | |
<tdml:infoset> | |
<tdml:dfdlInfoset> | |
<c xmlns="http://www.example.org/example1/"> | |
<d type="xsd:int">2</d> | |
<e type="xsd:int">1</e> | |
</c> | |
</tdml:dfdlInfoset> | |
</tdml:infoset> | |
</tdml:parserTestCase> | |
<tdml:defineSchema name="v2"> | |
<dfdl:defineVariable name="v_no_default" type="xsd:int" | |
external="true" /> | |
<dfdl:defineVariable name="v_with_default" type="xsd:int" | |
defaultValue="42" external="true" /> | |
<dfdl:defineVariable name="myVar1" type="xs:int" | |
defaultValue="6" /> | |
<dfdl:format ref="ex:daffodilTest1" /> | |
<xs:element name="c"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name="d" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_with_default }"> | |
<xs:annotation> | |
<xs:appinfo source="http://www.ogf.org/dfdl/"> | |
<dfdl:setVariable ref="ex:v_no_default">{ . }</dfdl:setVariable> | |
</xs:appinfo> | |
</xs:annotation> | |
</xs:element> | |
<xs:element name="e" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_no_default }" /> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</tdml:defineSchema> | |
<!-- Overrides define variables and sets one --> | |
<tdml:parserTestCase name="override_define_vars_02" | |
root="c" model="v2" | |
description="Use of defineVariable, extVariable, and setVariable - DFDL-7-091R"> | |
<tdml:externalVariableBindings xmlns="http://www.w3.org/2001/XMLSchema" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.com"> | |
<tdml:bind name="ex:v_no_default">1</tdml:bind> | |
<tdml:bind name="ex:v_with_default">2</tdml:bind> | |
</tdml:externalVariableBindings> | |
<tdml:document /> | |
<tdml:infoset> | |
<tdml:dfdlInfoset> | |
<c xmlns="http://www.example.org/example1/"> | |
<d type="xsd:int">2</d> | |
<e type="xsd:int">2</e> | |
</c> | |
</tdml:dfdlInfoset> | |
</tdml:infoset> | |
</tdml:parserTestCase> | |
<tdml:defineSchema name="v3"> | |
<dfdl:defineVariable name="v_no_default" type="xsd:int" /> | |
<dfdl:defineVariable name="v_with_default" type="xsd:int" | |
defaultValue="42" external="true" /> | |
<dfdl:defineVariable name="myVar1" type="xs:int" | |
defaultValue="6" /> | |
<dfdl:format ref="ex:daffodilTest1" /> | |
<xs:element name="c"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name="d" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_with_default }"> | |
<xs:annotation> | |
<xs:appinfo source="http://www.ogf.org/dfdl/"> | |
<dfdl:setVariable ref="ex:v_no_default">{ . }</dfdl:setVariable> | |
</xs:appinfo> | |
</xs:annotation> | |
</xs:element> | |
<xs:element name="e" type="xsd:int" dfdl:inputValueCalc="{ $ex:v_no_default }" /> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</tdml:defineSchema> | |
<!-- Should error. One of the variables is not set to external, yet we attempt | |
to set it externally. --> | |
<tdml:parserTestCase name="override_define_vars_03" | |
root="c" model="v3" | |
description="Use of defineVariable, extVariable, and setVariable - DFDL-7-091R"> | |
<tdml:externalVariableBindings xmlns="http://www.w3.org/2001/XMLSchema" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://example.com"> | |
<tdml:bind name="ex:v_no_default">1</tdml:bind> | |
<tdml:bind name="ex:v_with_default">2</tdml:bind> | |
</tdml:externalVariableBindings> | |
<tdml:document /> | |
<tdml:errors> | |
<tdml:error>Cannot set variable</tdml:error> | |
<tdml:error>v_no_default</tdml:error> | |
<tdml:error>externally</tdml:error> | |
</tdml:errors> | |
</tdml:parserTestCase> | |
</tdml:testSuite> |