I feel I am so close to the solution and the tip on the DAFFODIL_CLASSPATH 
environment variable was the last missing step. But unfortunately I am still 
getting the following error:

[error] Schema Definition Error: The dfdlx:layer 
'{urn:com.owlcyberdefense.dfdl.IPv4Checksum}IPv4Checksum' was not found. 
Available choices are: 
{urn:org.apache.daffodil.layers.lineFolded}lineFolded_IMF, 
{urn:org.apache.daffodil.layers.lineFolded}lineFolded_iCalendar, 
{urn:org.apache.daffodil.layers.base64_MIME}base64_MIME, 
{urn:org.apache.daffodil.layers.gzip}gzip, 
{urn:org.apache.daffodil.layers.fixedLength}fixedLength, 
{urn:org.apache.daffodil.layers.byteSwap}twobyteswap, 
{urn:org.apache.daffodil.layers.byteSwap}fourbyteswap, 
{urn:org.apache.daffodil.layers.boundaryMark}boundaryMark

Here is what've done so far:

1 - packaged the scala code for IPv4Checksum as a jar file named 
ipv4checksumlayer_2.12-1.0.jar.  Using this code just to see if I can get 
daffodil to see the class
2 - Verified the jar file contains the class named IPv4ChecksumLayer.class in 
the path com\owlcyberdefense\dfdl\
3 - set the DAFFODIL_CLASSPATH environment variable to the location of the jar 
file.
4 - pasted the following lines into my schema file:

        xmlns:chksum="urn:com.owlcyberdefense.dfdl.IPv4Checksum"
  <xs:import namespace="urn:com.owlcyberdefense.dfdl.IPv4Checksum" 
schemaLocation="IPv4ChecksumLayer.dfdl.xsd"/>

        <sequence  >
          <xs:annotation>
              <xs:appinfo source="http://www.ogf.org/dfdl/";>
                <dfdl:newVariableInstance ref="chksum:IPv4Checksum"/>
              </xs:appinfo>
          </xs:annotation>
              <xs:sequence dfdl:ref="chksum:IPv4ChecksumLayer">
                <xs:sequence>
                  <xs:element name="Checksum" type="chksum:IPv4Checksum"/>
                </xs:sequence>
              </xs:sequence>
        </sequence>




-----Original Message-----
From: Steve Lawrence <slawre...@apache.org>
Sent: Friday, October 25, 2024 1:30 PM
To: users@daffodil.apache.org
Subject: Re: Where to put custom checksum for use as a layer?

You need to build your layer into a .jar file and then put that on Daffodil's 
classpath.

If you're use the Daffodil CLI, you can add jars to the CLI classpath by 
setting the DAFFODIL_CLASSPATH environment variable, for example:

   export DAFFODIL_CLASSPATH="/path/to/custom/checksum/layer.jar"
   daffodil parse -s schema.dfdl.xsd ...

If instead you're running TDML tests using SBT, a common technique is to 
publish the layer jar to a local repository, then add it as a dependency to 
the schema project that uses it. For example, you could do this to publish 
locally:

   cd /layer-project
   sbt publishLocal

And add this to your schema project build.sbt file:

   libraryDependencies ++= Seq(
     "org.example" % "layer-project" % "1.0.0"
   )

And then just run "sbt test" from the schema project. SBT will find the 
locally published layer and automatically add it to the classpath when running 
tests.



On 2024-10-25 12:51 PM, Mark Kozak wrote:
> Hello folks,
>
> I have a custom checksum calculator I need to run on an entity. I have been
> studying the ethernetIP example <https://github.com/DFDLSchemas/ethernetIP> 
> and
> the layers documentation <https://daffodil.apache.org/layers>, but am unable 
> to
> figure out where to place my scala implementation for it to be found. Is 
> there
> some documentation I am missing?
>
> Thanks as always for the support,
>
> Mark
>
> Mark Kozak
>
> Director of Engineering
>
> Adeptus Cyber Solutions
>
> Adeptus-CS.com
>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to