/xXSDHub
PRACTICAL XML NOTES

Fix an invalid xs:date value in XML

Published by XSDHub · How our guides and examples are made

Use year-month-day for ordinary modern dates

For 26 October 2026, use 2026-10-26 rather than 26/10/2026. In this example the element is typed as xs:date. The slash-separated value is well-formed XML but fails schema validation. A dateTime field is a different type and can require a time component.

TRY THE FIX

A broken example and a working correction

These examples were checked on 26 October 2026 using XSDHub’s libxml2-based engine. Other validators may phrase the same problem differently.

What XSDHub reports

Element 'deliveryDate': '26/10/2026' is not a valid value of the atomic type 'xs:date'.

Before: fails XSD validation

<deliveryDate>26/10/2026</deliveryDate>
Try the broken example →

After: passes this check

<deliveryDate>2026-10-26</deliveryDate>
Try the corrected example →
Complete XSD used for both examples
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="deliveryDate" type="xs:date"/></xs:schema>

The buttons open a new workbench page with the example loaded. Choose Validate XML to run the check. Your own files are not uploaded.

Check the calendar, not only the format

2026-02-30 has the expected visual shape but is not a valid date. Leap years matter too. Validate generated values rather than merely checking them with a format-only regular expression.

Do not guess an ambiguous date

03/04/2026 may mean March 4 or April 3. Confirm the source locale or data contract before converting it. Reordering digits without that context can produce schema-valid but factually wrong data.

Time zones and missing values

xs:date permits an optional timezone such as Z or +02:00; the receiving contract may impose narrower rules. An empty element is not automatically a valid date. Omitting an optional element and using xsi:nil on a nillable element are distinct choices that depend on the schema.

Validate after export

Keep the intended calendar date intact when your source uses timestamps and timezone conversion. Test the exported XML against the receiver’s XSD. Passing xs:date validation confirms its datatype, not a business rule such as delivery occurring after order placement.

Checking the same rule across many files?

Start with the free single-document check. Pro adds batches of up to 25 XML files and 10 saved schemas; Team adds larger batches and a shared library. Both use the same validation engine.

Compare batch-validation plans →

Primary references