XML Schema (XSD) Validator API

Validate XML against an XML Schema (XSD 1.0, libxml2): errors with line, XPath and message; multi-file schemas with xs:include / xs:import in a ZIP.

POSThttps://apibox.io.vn/v1/xsd-validate

Send the XML and its schema and get every validation error with line, col, xpath and the libxml2 message, plus a bilingual summary. The stage tells where it failed: xsd_parse (the schema is not well-formed), xsd_compile (the schema itself is wrong, e.g. an unknown type or a missing include), xml_parse (the document is not well-formed) or validate.

Schemas split over several files (xs:include, xs:import, e.g. UBL 2.1, ISO 20022, Vietnamese e-invoice and tax XSD packages) are supported: upload them as a ZIP in schema_zip and name the entry point with schema_main, or pass schemas as a { "file.xsd": "<xs:schema…>" } object. Files are resolved by their name or path inside the ZIP; nothing is fetched from the network.

Engine: libxml2 (MIT) compiled to WebAssembly, running in a separate APIBox Worker. XML Schema 1.0 only (no XSD 1.1 assertions); Schematron rules are not evaluated. External entities are never loaded. XML and schema up to 10 MB each (less on the free plan).

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
xmlbodystringyesThe XML document (or a multipart xml / file upload, xml_base64, xml_url).
xsdbodystringnoThe schema (text, multipart xsd, xsd_base64 or xsd_url).
schema_zipbodyfilenoZIP with several .xsd files (multipart, schema_zip_base64 or schema_zip_url).
schema_mainbodystringnoName of the main schema inside the ZIP.
schemasbodyobjectnoExtra schema files { "name.xsd": "<xs:schema…>" } for includes / imports.

Example

curl -X POST "https://apibox.io.vn/v1/xsd-validate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<invoice><no>A1</no><total>100</total></invoice>","xsd":"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><xs:element name=\"invoice\"><xs:complexType><xs:sequence><xs:element name=\"no\" type=\"xs:int\"/><xs:element name=\"total\" type=\"xs:decimal\"/></xs:sequence></xs:complexType></xs:element></xs:schema>"}'

Response

{
  "valid": false,
  "stage": "validate",
  "summary": "1 problem(s) at stage validate",
  "summary_vi": "XML không khớp XSD (1 lỗi)",
  "error_count": 1,
  "errors": [
    {
      "line": 1,
      "col": 0,
      "level": "error",
      "message": "Element 'no': 'A1' is not a valid value of the atomic type 'xs:int'.",
      "xpath": "/invoice/no",
      "file": "document.xml"
    }
  ],
  "schema_files": 1,
  "ms": 57,
  "engine": "libxml2 (XML Schema 1.0)"
}

Use cases

  • Check e-invoice, tax or bank XML before sending it to the authority
  • Validate UBL / ISO 20022 / SEPA files in an n8n or Make scenario
  • Give users precise error lines when importing XML into your app
  • Test schema changes against sample documents in CI

FAQ

Which XSD version is supported?

XML Schema 1.0 (libxml2). XSD 1.1 features such as xs:assert are refused with a clear error.

My schema imports other files. What do I send?

A ZIP with all .xsd files in schema_zip and the main file name in schema_main; includes are resolved by name or relative path.

Is there a built-in schema library?

Not yet: send the schema you were given. Official schemas change often and their licences differ, so APIBox does not redistribute them.

Related APIs

Start with 1,000 free requests every month. Get free API key →