XSD datatype
xs:boolean
Exactly four literals: true, false, 1 and 0. Not 'yes', not 'True', not 'on'.
xs:boolean has a lexical space of precisely four strings. '1' and '0' are the numeric spellings of true and false, kept for compatibility with older data formats.
Case matters. 'True' is not a valid xs:boolean, which catches anything serialised by a language that capitalises its booleans — Python being the obvious one.
- Lexical space
- One of: true, false, 1, 0.
- Derives from
- Primitive type
- Category
- Other types
- Facets
- pattern, whiteSpace
What catches people out
- 'True' from a Python serialiser fails. So does 'YES' from a spreadsheet.
- There is no enumeration facet on xs:boolean — the value space has only two members already.
- '0' and 'false' are both false and are distinct literals, so a string comparison of the raw text is not a boolean comparison.
The schema used
This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="v" type="xs:boolean"/>
</xs:schema>Related
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.