Document structure
Attribute-value normalization
The parser's rewriting of attribute values before anything sees them: literal tabs, newlines and carriage returns become spaces.
Every attribute value goes through this, in every document, whether or not a DTD is present. A literal tab inside quotes is delivered as a space; a newline inside quotes is delivered as a space. The document you wrote and the value your code receives are not the same string.
Character references are the exception, and it is a deliberate one: `	` survives as a tab. That is the only way to put a real tab in an attribute value, and it is why the two spellings of the same character behave differently in exactly this one place.
- Defined in
- XML 1.0 §3.3.3
- Category
- Document structure
- Also written
- attribute normalization
Shown, not asserted
All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.
A literal tab in an attribute value arrives as a space.
document.xml <x a="a b"/>expression string(/x/@a)What the engine returns
a bThe same character written as a reference survives — here shown by replacing it with T.
document.xml <x a="a	b"/>expression translate(string(/x/@a), " ", "T")What the engine returns
aTb
What catches people out
- Multi-line attribute values are flattened to spaces. If you need line breaks in a value, use or move the content into an element.
- This happens before validation, so a pattern facet sees the normalized value.
- It is not the same as the whiteSpace facet: normalization always happens, the facet is schema-driven and happens later.
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- DatatypeswhiteSpaceThe schema-level processing that happens after this, and is often confused with it.
- XPathtranslate()Used above to make an invisible character visible.
- Parse errorsUnescaped '<' in an attribute valueThe one character normalization will not save you from.
Related terms
- AttributeA name–value pair on an element's start tag, whose value is always a quoted string.
- Character referenceA &#nnn; or &#xhhhh; escape naming a Unicode code point directly, rather than by an entity name.
- Significant whitespaceWhitespace that is part of a document's content, as opposed to indentation a processor may drop.
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.