Skip to content
Snippets Groups Projects
Commit d782be99 authored by Terry D. Norbraten's avatar Terry D. Norbraten
Browse files

[Terry N.] add hello world CLI test to complete the low, med, high level

DFDL parse examples
parent 32aa7f80
No related branches found
No related tags found
No related merge requests found
ant -f /Users/terry/javaapis/robodata/DFDL tests
daffodil.parse.examples.helloWorld:
xmlvalidate well-formed original schema examples/helloWorld/src/main/resources/helloWorld.dfdl.xsd
1 file(s) have been successfully validated.
schemavalidate original schema examples/helloWorld/src/main/resources/helloWorld.dfdl.xsd
... schemavalidate passed
daffodil parse csv
... (note that apache daffodil warnings about dfdl:encodingErrorPolicy can be ignored)
[info] Time (compiling): 1293ms
[info] Time (parsing): 67ms
============================================
parsed result examples/helloWorld/helloWorld.parse.xml
<?xml version="1.0" encoding="UTF-8"?>
<tns:helloWorld xmlns:tns="http://example.com/dfdl/helloworld/">
<word>Hello</word>
<word>world!</word>
</tns:helloWorld>
============================================
Check well-formed result examples/helloWorld/helloWorld.parse.xml
1 file(s) have been successfully validated.
Check schema-valid result examples/helloWorld/helloWorld.parse.xml using original helloWorld.dfdl.xsd
/Users/terry/javaapis/robodata/DFDL/examples/helloWorld/helloWorld.parse.xml:2:65: cvc-elt.1.a: Cannot find the declaration of element 'tns:helloWorld'.
/Users/terry/javaapis/robodata/DFDL/examples/helloWorld/src/main/resources/helloWorld.dfdl.xsd:8:75: TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://example.com/dfdl/helloworld/'.
/Users/terry/javaapis/robodata/DFDL/examples/helloWorld/src/main/resources/helloWorld.dfdl.xsd:8:75: TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://example.com/dfdl/helloworld/'.
/Users/terry/javaapis/robodata/DFDL/examples/helloWorld/helloWorld.parse.xml is not a valid XML document
TODO validation errors seem due to insufficient XML generation by Apache Daffodil
Suggested namespace declaration additions:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="csv.dfdl.xsd"
daffodil.parse.examples.csv:
xmlvalidate well-formed original schema examples/csv/src/main/resources/com/tresys/csv/xsd/csv.dfdl.xsd
1 file(s) have been successfully validated.
......@@ -6,8 +34,8 @@ schemavalidate original schema examples/csv/src/main/resources/com/tresys/csv/xs
... schemavalidate passed
daffodil parse csv
... (note that apache daffodil warnings about dfdl:encodingErrorPolicy can be ignored)
[info] Time (compiling): 1458ms
[info] Time (parsing): 101ms
[info] Time (compiling): 1282ms
[info] Time (parsing): 90ms
============================================
original result examples/csv/src/test/resources/com/tresys/csv/infosets/simpleCSV.xml
<?xml version="1.0" encoding="UTF-8"?>
......@@ -103,8 +131,8 @@ schemavalidate original schema examples/pcap/src/main/resources/com/tresys/pcap/
... schemavalidate passed
daffodil parse pcap
... (note that apache daffodil warnings about dfdl:encodingErrorPolicy can be ignored)
[info] Time (compiling): 2790ms
[info] Time (parsing): 250ms
[info] Time (compiling): 2567ms
[info] Time (parsing): 231ms
============================================
original result examples/pcap/src/test/resources/com/tresys/pcap/infosets/dns.pcap.xml
<pcap:PCAP xmlns:pcap="urn:pcap:2.4">
......@@ -5248,4 +5276,4 @@ Suggested namespace declaration additions:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="pcap.dfdl.xsd"
tests:
BUILD SUCCESSFUL (total time: 38 seconds)
BUILD SUCCESSFUL (total time: 54 seconds)
......@@ -3,11 +3,58 @@
<description>Builds, tests, and runs the project Robodata transformation usings Daffodil (DFDL)</description>
<property environment="env"/>
<property name="examples.hello.world.dir" value="examples/helloWorld"/>
<property name="examples.csv.dir" value="examples/csv"/>
<property name="examples.pcap.dir" value="examples/pcap"/>
<!-- Daffodil CLI commands at: https://daffodil.apache.org/cli/ -->
<!-- Basic example, low level -->
<target name="daffodil.parse.examples.helloWorld" description="daffodil.apache.org hello world example">
<echo message="xmlvalidate well-formed original schema ${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd"/>
<xmlvalidate file="${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd" failonerror="false" warn="true" lenient="true"/>
<!-- note that XSD schema validation using schemavalidate task requires special setup https://ant.apache.org/manual/Tasks/schemavalidate.html -->
<echo message="schemavalidate original schema ${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd"/>
<schemavalidate file="${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd" failonerror="true" warn="true" lenient="false" fullchecking="false">
<schema namespace="http://www.w3.org/2001/XMLSchema" file="lib/validation/XMLSchema.xsd"/>
</schemavalidate>
<echo message="... schemavalidate passed"/>
<echo message="daffodil parse csv"/>
<echo message="... (note that apache daffodil warnings about dfdl:encodingErrorPolicy can be ignored)"/>
<exec executable="bin/daffodil" dir="." vmlauncher="false">
<arg value="--verbose"/>
<arg value="parse"/>
<!-- Daffodil tunables to suppress warnings about dfdl:encodingErrorPolicy -->
<arg line="-T suppressSchemaDefinitionWarnings=encodingErrorPolicyError"/>
<arg value="--schema"/>
<arg value="${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd"/>
<arg value="--output"/>
<arg value="${examples.hello.world.dir}/helloWorld.parse.xml"/>
<arg value="--validate"/>
<arg value="on"/>
<arg value="${examples.hello.world.dir}/src/main/resources/helloWorld.dat"/>
</exec>
<echo message="============================================"/>
<echo message="parsed result ${examples.hello.world.dir}/helloWorld.parse.xml"/>
<concat description="show file for build log">
<filelist dir="${examples.hello.world.dir}" files="helloWorld.parse.xml"/>
</concat>
<echo message="============================================"/>
<echo message="Check well-formed result ${examples.hello.world.dir}/helloWorld.parse.xml"/>
<xmlvalidate file="${examples.hello.world.dir}/helloWorld.parse.xml" failonerror="false" warn="true" lenient="true"/>
<!-- note that XSD schema validation using schemavalidate task requires special setup https://ant.apache.org/manual/Tasks/schemavalidate.html -->
<echo message="Check schema-valid result ${examples.hello.world.dir}/helloWorld.parse.xml using original helloWorld.dfdl.xsd"/>
<!-- note failonerror="false" in order to reach follow-on TODO -->
<!-- TODO: Do we need the attrib noNamespaceFile? (tdn) -->
<schemavalidate file="${examples.hello.world.dir}/helloWorld.parse.xml" failonerror="false" warn="true" lenient="false"
disableDTD="true" fullchecking="true" noNamespaceFile="${examples.hello.world.dir}/src/main/resources/helloWorld.dfdl.xsd"/>
<echo message="TODO validation errors seem due to insufficient XML generation by Apache Daffodil"/>
<echo message="Suggested namespace declaration additions:"/>
<echo message=' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'/>
<echo message=' xsi:noNamespaceSchemaLocation="csv.dfdl.xsd"'/>
</target>
<!-- Medium example, intermediate level -->
<target name="daffodil.parse.examples.csv" description="daffodil.apache.org csv example">
<echo message="xmlvalidate well-formed original schema ${examples.csv.dir}/src/main/resources/com/tresys/csv/xsd/csv.dfdl.xsd"/>
<xmlvalidate file="${examples.csv.dir}/src/main/resources/com/tresys/csv/xsd/csv.dfdl.xsd" failonerror="false" warn="true" lenient="true"/>
......@@ -57,6 +104,7 @@
<echo message=' xsi:noNamespaceSchemaLocation="csv.dfdl.xsd"'/>
</target>
<!-- Advanced example, high level -->
<target name="daffodil.parse.examples.pcap" description="daffodil.apache.org pcap example">
<echo message="xmlvalidate well-formed original schema ${examples.pcap.dir}/src/main/resources/com/tresys/pcap/xsd/pcap.dfdl.xsd"/>
<xmlvalidate file="${examples.pcap.dir}/src/main/resources/com/tresys/pcap/xsd/pcap.dfdl.xsd" failonerror="false" warn="true" lenient="true"/>
......@@ -108,7 +156,7 @@
<!-- Add test targets to the "depends" attrib test.csv,test.pcap -->
<target name="tests"
depends="daffodil.parse.examples.csv,daffodil.parse.examples.pcap"
depends="daffodil.parse.examples.helloWorld,daffodil.parse.examples.csv,daffodil.parse.examples.pcap"
description="Tests for various input/output formats"/>
<target name="view.apache.daffodil" description="view apache daffodil online site in web browser (Netbeans only)">
......
......@@ -70,4 +70,9 @@
nbproject/build-impl.xml file.
-->
<target name="-post-clean">
<delete file="helloWorld.parse.xml"/>
</target>
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment