Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

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 b
  • The same character written as a reference survives — here shown by replacing it with T.

    document.xml
    <x a="a&#9;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 &#10; 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.

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.