You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2019/10/15 18:06:27 UTC

Need help please in creating a TDML file

Hello DFDL community,

I am learning how to create and run TDML files. Below is the TDML file that I created. I ran it like this:

daffodil test -iii test-5.tdml.xml parse-test-5

That produced the following error. But it should not have produced an error (the bug is in unparsing, not parsing). There must be something wrong in my TDML file. What is wrong in it, please?  /Roger

Creating DFDL Test Suite for test-5.tdml.xml
[Fail] parse-test-5
  Failure Information:
    Model 'test-5' was not passed, found embedded in the TDML file, nor as a schema file.
  Logs:
    None
  Backtrace:
    org.apache.daffodil.tdml.TDMLException$.apply(TDMLException.scala:31)
    org.apache.daffodil.tdml.TestCase.getSuppliedSchema(TDMLRunner.scala:624)
    org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:706)
    org.apache.daffodil.Main$.$anonfun$run$28(Main.scala:1256)
    org.apache.daffodil.Main$.$anonfun$run$28$adapted(Main.scala:1252)
    scala.collection.immutable.List.foreach(List.scala:389)
    org.apache.daffodil.Main$.run(Main.scala:1252)
    org.apache.daffodil.Main$.main(Main.scala:1363)
    org.apache.daffodil.Main.main(Main.scala)

Total: 1, Pass: 0, Fail: 1, Not Found: 0

--------------------
TDML File
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<tdml:testSuite
    suiteName="Bug Report test-5.dfdl.xsd"
    description="Bug in everything-you-ever-wanted-to-know-about/separator/test-5.dfdl.xsd"
    xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:gpf="http://www.ibm.com/dfdl/GeneralPurposeFormat"
    xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
    xsi:schemaLocation="http://www.ibm.com/xmlns/dfdl/testData tdml.xsd"
    defaultRoundTrip="none">

    <tdml:defineSchema name="test-5-Schema" elementFormDefault="unqualified">

        <dfdl:defineFormat name="default-dfdl-properties">
            <dfdl:format
                alignment="1"
                alignmentUnits="bytes"
                binaryFloatRep="ieee"
                binaryNumberRep="binary"
                bitOrder="mostSignificantBitFirst"
                byteOrder="bigEndian"
                calendarPatternKind="implicit"
                choiceLengthKind="implicit"
                documentFinalTerminatorCanBeMissing="yes"
                emptyValueDelimiterPolicy="none"
                encoding="ISO-8859-1"
                encodingErrorPolicy="replace"
                escapeSchemeRef=""
                fillByte="f"
                floating="no"
                ignoreCase="no"
                initiator=""
                initiatedContent="no"
                leadingSkip="0"
                lengthKind="delimited"
                lengthUnits="characters"
                nilKind="literalValue"
                nilValueDelimiterPolicy="none"
                occursCountKind="implicit"
                outputNewLine="%CR;%LF;"
                representation="text"
                separator=""
                separatorPosition="infix"
                separatorSuppressionPolicy="anyEmpty"
                sequenceKind="ordered"
                terminator=""
                textBidi="no"
                textNumberCheckPolicy="strict"
                textNumberPattern="#,##0.###;-#,##0.###"
                textNumberRep="standard"
                textNumberRounding="explicit"
                textNumberRoundingIncrement="0"
                textNumberRoundingMode="roundUnnecessary"
                textOutputMinLength="0"
                textPadKind="none"
                textStandardBase="10"
                textStandardDecimalSeparator="."
                textStandardExponentRep="E"
                textStandardInfinityRep="Inf"
                textStandardNaNRep="NaN"
                textStandardZeroRep="0"
                textStandardGroupingSeparator=","
                textTrimKind="none"
                trailingSkip="0"
                truncateSpecifiedLengthString="no"
                utf16Width="fixed"
            />
        </dfdl:defineFormat>

        <dfdl:format ref="default-dfdl-properties" />

        <xs:element name="input">
            <xs:complexType>
                <xs:sequence dfdl:sequenceKind="ordered"
                    dfdl:separator="%NL;" dfdl:separatorPosition="infix"
                    dfdl:separatorSuppressionPolicy="never">
                    <xs:element name="A" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                    <xs:element name="B" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                    <xs:element name="C" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>

    </tdml:defineSchema>

    <tdml:parserTestCase name="parse-test-5" root="input" model="test-5"
        description="Test test-5.dfdl.xsd, in the parsing direction">

        <tdml:document>
            <tdml:documentPart type="text"
                replaceDFDLEntities="true"><![CDATA[Hello
world
]]></tdml:documentPart>
        </tdml:document>

        <tdml:infoset>
            <tdml:dfdlInfoset>
                <input>
                    <A>Hello</A>
                    <B>world</B>
                    <C></C>
                </input>
            </tdml:dfdlInfoset>
        </tdml:infoset>

    </tdml:parserTestCase>

    <tdml:unparserTestCase name="unparse-test-5" root="input" model="test-5"
        description="Test test-5.dfdl.xsd, this time in the unparsing direction.">

        <tdml:infoset>
            <tdml:dfdlInfoset>
                <input>
                    <A>Hello</A>
                    <B>world</B>
                    <C></C>
                </input>
            </tdml:dfdlInfoset>
        </tdml:infoset>

        <tdml:document>
            <tdml:documentPart type="text"
                replaceDFDLEntities="true"><![CDATA[Hello
world
]]></tdml:documentPart>
        </tdml:document>

    </tdml:unparserTestCase>

</tdml:testSuite>



Re: Need help please in creating a TDML file

Posted by "Beckerle, Mike" <mb...@tresys.com>.
I really appreciate you working through the TDML thing.

I spotted that your model attribute on the parser test case is "test-5" but needs to be test-5-Schema

The term "model" is IBM-speak for "schema".

When you define a schema inside a TDML file, it actually has a target namespace and when you create test cases (particularly unparser test cases), you need to have the correct namespace prefix on global elements.

So you need to add:

    xmlns:tns="http://example.com"

To the root tdml:testSuite element. Then put tns: as a prefix on your <input> and </input> infoset elements inside your parser test case, and unparser test case.

(I use "tns" to mean "this schema's namespace" or "target namespace" but of course you can choose whatever naming convention for this prefix you wish.)


________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Tuesday, October 15, 2019 2:06 PM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: Need help please in creating a TDML file


Hello DFDL community,



I am learning how to create and run TDML files. Below is the TDML file that I created. I ran it like this:



daffodil test -iii test-5.tdml.xml parse-test-5



That produced the following error. But it should not have produced an error (the bug is in unparsing, not parsing). There must be something wrong in my TDML file. What is wrong in it, please?  /Roger



Creating DFDL Test Suite for test-5.tdml.xml

[Fail] parse-test-5

  Failure Information:

    Model 'test-5' was not passed, found embedded in the TDML file, nor as a schema file.

  Logs:

    None

  Backtrace:

    org.apache.daffodil.tdml.TDMLException$.apply(TDMLException.scala:31)

    org.apache.daffodil.tdml.TestCase.getSuppliedSchema(TDMLRunner.scala:624)

    org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:706)

    org.apache.daffodil.Main$.$anonfun$run$28(Main.scala:1256)

    org.apache.daffodil.Main$.$anonfun$run$28$adapted(Main.scala:1252)

    scala.collection.immutable.List.foreach(List.scala:389)

    org.apache.daffodil.Main$.run(Main.scala:1252)

    org.apache.daffodil.Main$.main(Main.scala:1363)

    org.apache.daffodil.Main.main(Main.scala)



Total: 1, Pass: 0, Fail: 1, Not Found: 0



--------------------

TDML File

--------------------

<?xml version="1.0" encoding="UTF-8"?>
<tdml:testSuite
    suiteName="Bug Report test-5.dfdl.xsd"
    description="Bug in everything-you-ever-wanted-to-know-about/separator/test-5.dfdl.xsd"
    xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:gpf="http://www.ibm.com/dfdl/GeneralPurposeFormat"
    xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
    xsi:schemaLocation="http://www.ibm.com/xmlns/dfdl/testData tdml.xsd"
    defaultRoundTrip="none">

    <tdml:defineSchema name="test-5-Schema" elementFormDefault="unqualified">

        <dfdl:defineFormat name="default-dfdl-properties">
            <dfdl:format
                alignment="1"
                alignmentUnits="bytes"
                binaryFloatRep="ieee"
                binaryNumberRep="binary"
                bitOrder="mostSignificantBitFirst"
                byteOrder="bigEndian"
                calendarPatternKind="implicit"
                choiceLengthKind="implicit"
                documentFinalTerminatorCanBeMissing="yes"
                emptyValueDelimiterPolicy="none"
                encoding="ISO-8859-1"
                encodingErrorPolicy="replace"
                escapeSchemeRef=""
                fillByte="f"
                floating="no"
                ignoreCase="no"
                initiator=""
                initiatedContent="no"
                leadingSkip="0"
                lengthKind="delimited"
                lengthUnits="characters"
                nilKind="literalValue"
                nilValueDelimiterPolicy="none"
                occursCountKind="implicit"
                outputNewLine="%CR;%LF;"
                representation="text"
                separator=""
                separatorPosition="infix"
                separatorSuppressionPolicy="anyEmpty"
                sequenceKind="ordered"
                terminator=""
                textBidi="no"
                textNumberCheckPolicy="strict"
                textNumberPattern="#,##0.###;-#,##0.###"
                textNumberRep="standard"
                textNumberRounding="explicit"
                textNumberRoundingIncrement="0"
                textNumberRoundingMode="roundUnnecessary"
                textOutputMinLength="0"
                textPadKind="none"
                textStandardBase="10"
                textStandardDecimalSeparator="."
                textStandardExponentRep="E"
                textStandardInfinityRep="Inf"
                textStandardNaNRep="NaN"
                textStandardZeroRep="0"
                textStandardGroupingSeparator=","
                textTrimKind="none"
                trailingSkip="0"
                truncateSpecifiedLengthString="no"
                utf16Width="fixed"
            />
        </dfdl:defineFormat>

        <dfdl:format ref="default-dfdl-properties" />

        <xs:element name="input">
            <xs:complexType>
                <xs:sequence dfdl:sequenceKind="ordered"
                    dfdl:separator="%NL;" dfdl:separatorPosition="infix"
                    dfdl:separatorSuppressionPolicy="never">
                    <xs:element name="A" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                    <xs:element name="B" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                    <xs:element name="C" type="xs:string" minOccurs="0" dfdl:occursCountKind="implicit" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>

    </tdml:defineSchema>

    <tdml:parserTestCase name="parse-test-5" root="input" model="test-5"
        description="Test test-5.dfdl.xsd, in the parsing direction">

        <tdml:document>
            <tdml:documentPart type="text"
                replaceDFDLEntities="true"><![CDATA[Hello
world
]]></tdml:documentPart>
        </tdml:document>

        <tdml:infoset>
            <tdml:dfdlInfoset>
                <input>
                    <A>Hello</A>
                    <B>world</B>
                    <C></C>
                </input>
            </tdml:dfdlInfoset>
        </tdml:infoset>

    </tdml:parserTestCase>

    <tdml:unparserTestCase name="unparse-test-5" root="input" model="test-5"
        description="Test test-5.dfdl.xsd, this time in the unparsing direction.">

        <tdml:infoset>
            <tdml:dfdlInfoset>
                <input>
                    <A>Hello</A>
                    <B>world</B>
                    <C></C>
                </input>
            </tdml:dfdlInfoset>
        </tdml:infoset>

        <tdml:document>
            <tdml:documentPart type="text"
                replaceDFDLEntities="true"><![CDATA[Hello
world
]]></tdml:documentPart>
        </tdml:document>

    </tdml:unparserTestCase>

</tdml:testSuite>