Skip to content

Validate customs XML against an XSD before you send it

Customs portals and TMS interfaces often take strict XML, and a rejection can come back long after the message was sent, with little to go on. Validate XML checks a message against the schema files you already have, in the run, and lists every error by line and path.

Use this templateNeeds an AI connection.

Nothing leaves until the message matches the schema.

Most customs schemas import or include other files, so a single file rarely works. In Schema files, give a .zip of the whole set, or several .xsd files, and set Main schema to the one that defines the message. For one standalone schema, paste it in Schema instead (up to 64,000 characters).

Imports and includes resolve only to relative paths inside the files you supply. Nothing is fetched from the network, so a schema that imports from a URL has to be rewritten to a relative path, with that file added to the set.

Set XML document to the text, or XML file to a file, for example from Read object or an upload. Files must be UTF-8, and the XML file can be at most 8 MiB.

By default an invalid message doesn’t fail the step. It continues on Invalid with Error count, Summary and Errors, each error giving its line, column, path, element and message. So connect both exits:

If an invalid message should never get past this point, set When invalid to fail the run instead.

If your automation builds the XML itself, you may not need this block. Upload XSD on HTTP Request builds the body from the portal’s schema files, and a body that doesn’t match isn’t sent. Use Validate XML for XML that comes from elsewhere, such as your TMS or a partner.

  • A broken schema set fails the step. It doesn’t give an invalid verdict, so a run that fails here points at your schema files, not the message.
  • Valid is not the same as accepted. A schema checks structure and formats. It can’t know whether an EORI is enrolled or a code applies to these goods, so the portal can still reject a valid message.
  • Long error lists are cut. Errors lists 20 by default, up to 200. Error count counts them all, and More errors than listed says when some are left out.

Validation runs inside Lainstack with no outside system, so a draft run gives you the real verdict. Try it on a message your portal has already rejected.

Last updated: