help running custom DFDL schema from Smooks

493 views
Skip to first unread message

Nestor Fernandez

unread,
Dec 15, 2021, 10:49:10 AM12/15/21
to smook...@googlegroups.com
Hi team,

We created a custom dfdl transformation for an edifact file. Our dfdl schema has one import: IBM_EDI_Format.xsd.
We have tested it with Daffodil 3.1.0 and it works well both ways, it parses and unparses the edi file to/from our desired XML format. So far so good.

Now we are trying to run it from Smooks, so we are looking at repo:

https://github.com/smooks/smooks-examples (tag v1.0.1)

First we tried examples edi-to-xml and edifact-to-xml, and both work well.

However, when trying to run our own dfdl, by modifying any of these 2 examples, we can't make it work (neither with edi-to-xml nor with edifact-to-xml).



Case: edi-to-xml

We replace input-message.edi, copied the new schema and IBM_EDI_Format.xsd to src/main/resources

Updated smooks-config.xml like this

    <edi:parser schemaURI="/edifact-d93a-ifcsum-schema-v1.0.0.dfdl.xsd" />

We get this error:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project smooks-example-edi-to-xml:
An exception occured while executing the Java class.
Error invoking @PostConstruct method 'initialize' on class 'org.smooks.cartridges.dfdl.parser.DfdlParser'.:
java.lang.RuntimeException: Schema Definition Error: Cannot set variable ibmEdiFmt:CompositeSep externally.
State was: VariableDefined. Existing value: DataValue(:).

If I comment the variable declaration in IBM_EDI_Format.xsd

<!-- <dfdl:defineVariable defaultValue="'%WSP*; %NL;%WSP*;" name="SegmentTerm" type="xsd:string"/>
<dfdl:defineVariable defaultValue="+" name="FieldSep" type="xsd:string"/>
<dfdl:defineVariable defaultValue=":" name="CompositeSep" type="xsd:string"/>
<dfdl:defineVariable defaultValue="?" name="EscapeChar" type="xsd:string"/>
<dfdl:defineVariable defaultValue="*" name="RepeatSep" type="xsd:string"/>
    <dfdl:defineVariable defaultValue="." name="DecimalSep" type="xsd:string"/>
    <dfdl:defineVariable defaultValue="," name="GroupingSep" type="xsd:string"/>  -->

then it complains that the variable is not defined:

Error invoking @PostConstruct method 'initialize' on class 'org.smooks.cartridges.dfdl.parser.DfdlParser'.: java.lang.RuntimeException: Schema Definition Error: Undefined variable: $ibmEdiFmt:EscapeChar




Case: edifact to xml

After updating the Main class java code and smooks-config.xml

<edifact:parser schemaURI="edifact-d93a-ifcsum-schema-v1.0.0.dfdl.xsd">
<edifact:messageTypes>
    <edifact:messageType>IFCSUM</edifact:messageType>
</edifact:messageTypes>
</edifact:parser>

We get error:

An exception occured while executing the Java class. Error invoking @PostConstruct method 'initialize' on class 'org.smooks.cartridges.dfdl.parser.DfdlParser'.: org.smooks.cdr.SmooksConfigurationException: java.lang.RuntimeException: Schema Definition Error: Error loading schema due to org.xml.sax.SAXParseException; systemId: file:/tmp/267592235106779405/EDIFACT-Interchange-6654ae4a-a2c2-3a29-af11-a4162566510f-.dfdl.xsd; lineNumber: 25; columnNumber: 15; name cannot end in ':'
[ERROR] Schema context: file:/tmp/267592235106779405/EDIFACT-Interchange-6654ae4a-a2c2-3a29-af11-a4162566510f-.dfdl.xsd Location in file:/tmp/267592235106779405/EDIFACT-Interchange-6654ae4a-a2c2-3a29-af11-a4162566510f-.dfdl.xsd


Could you please give us some advice on how to run our custom dfdl transform from Smooks? I assume we are doing something wrong when loading our schema (or its imports and variables), since we get initialization errors.


Thanks

Claude

unread,
Dec 15, 2021, 12:52:33 PM12/15/21
to Smooks Users
Hello Nester,

Best is to use edi:parser for custom EDIFACT schemas. Does it work with the latest snapshot of the EDIFACT cartridge (i.e., 2.0.0-RC1-SNAPSHOT)?

Claude

Claude Mamo

unread,
Dec 15, 2021, 1:46:20 PM12/15/21
to smook...@googlegroups.com
Sorry, meant latest version of EDI cartridge.

Claude

--
You received this message because you are subscribed to a topic in the Google Groups "Smooks Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/smooks-user/qREFnC50fwk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to smooks-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/7189ee9d-1936-4f48-a168-913bbfe89960n%40googlegroups.com.

Nestor F

unread,
Dec 15, 2021, 3:29:52 PM12/15/21
to Smooks Users
Thank you for your response Claude. I found the issue by pure chance, and it had nothing to to with using the latest EDI cartridge version.

My dfdl schema was importing IBM_EDI_Format schema like this:

<xsd:import namespace="http://www.ibm.com/dfdl/EDI/Format" schemaLocation="IBM_EDI_Format.dfdl.xsd"/>

So I placed the IBM_EDI_Format file in the same resources folder as my dfdl schema (that had just worked for me with daffodil).

Later I noticed that the example dfdl schema file, edi-to-xml-order-mapping.dfdl.xsd, imports IBM_EDI_Format schema like this:

<xsd:import namespace="http://www.ibm.com/dfdl/EDI/Format" schemaLocation="/EDIFACT-Common/IBM_EDI_Format.dfdl.xsd"/>

Not very intuitive, and I don't see what was wrong with my schema import, but replacing that import line in my dfdl schema just worked.
Reply all
Reply to author
Forward
0 new messages