On this page
Record the document element and namespace declarations
Start with a neutral artifact ID, digest, encoding declaration, document element expanded name, and parser version. Then list namespace declarations by element scope. The World Wide Web Consortium, (opens in a new tab) specification says a namespace declaration associates a prefix or default namespace with a URI, and namespace URI comparison is case-sensitive. Record the exact URI string, including case and trailing characters, rather than normalizing it for display.
| Namespace field | Record | Stop if |
|---|---|---|
| Document element | Prefix, local name, expanded name | QName is resolved differently by readers |
| Prefix declaration | Prefix, URI, element scope | Same prefix is assumed global |
| Default namespace | URI and element scope | Unprefixed attributes are treated as namespaced |
| Attribute QName | Prefix, local name, expanded name | Attribute namespace is inferred from element scope |
| URI spelling | Exact source string | Case or trailing text is silently changed |
| Undeclared prefix | Location and error state | Parser repairs or drops it silently |
Synthetic namespace fixture
<r:record xmlns:r="urn:fixture:records" xmlns="urn:fixture:default">
<r:id>fixture-001</r:id>
<label>fixture-label</label>
</r:record>In the fixture, r:id and the unprefixed label have different expanded-name rules. The synthetic values are not real identifiers. Keep a prefix change separate from a namespace URI change: a prefix can be renamed without changing the expanded name, while a URI change changes the name contract.
Compare QNames, local names, and URI scope
A local name alone is insufficient when documents use namespaces. Expand each element and attribute QName to a pair of namespace URI and local name, retaining the source prefix for diagnostics. Namespaces in XML says a namespace name is an IRI and that two URIs are the same only when the strings match under the specification’s comparison rule. Do not compare prefixes as if they were identities.
| Comparison | Safe observation | Open question |
|---|---|---|
| Same prefix, same URI | Likely same expanded namespace | Is the scope the same at both elements? |
| Different prefixes, same URI | Expanded names can match | Which prefix should a derivative preserve? |
| Same local name, different URI | Different expanded names | Is this an intentional version or collision? |
| Unprefixed attribute | No default namespace assumption | Does the consumer expect a namespace? |
| Relative namespace URI | Non-conforming or unresolved boundary | Hold for producer correction |
| QName in text content | String only until schema or application rule | Do not expand without a declared rule |
Namespace declarations can be shadowed in a child element. Record the scope at the QName location rather than using a root-only map. If a transformation rewrites prefixes, retain a before-and-after mapping and prove expanded-name preservation on a synthetic fixture.
Inventory DTD, entities, and external references
XML 1.0 defines document type declarations, entity declarations, parsed entities, external identifiers, and entity references. Record whether the document contains a DOCTYPE, internal subset, external subset, general entities, parameter entities, notation declarations, or entity references. A parser may expose expanded text while hiding the declaration that produced it, so retain both declaration and expansion policy as separate fields.
| Entity boundary | Record | Stop if |
|---|---|---|
| DOCTYPE | Present, absent, or unknown | Parser strips declaration before inventory |
| Internal subset | Declarations and bounded names | Subset is not retained for review |
| External identifier | System or public identifier, no fetched content | Resolution target is followed automatically |
| General entity | Name, replacement state, usage count | Expansion is unbounded or unknown |
| Parameter entity | Declaration and scope | DTD behavior is not recorded |
| XInclude or application reference | Presence and policy | External include is treated as local text |
The specifications define syntax, not a universal operational policy for network access, file access, expansion limits, or schema resolution. Record those settings from the chosen parser and environment. Do not describe a parser as safe merely because a document was well-formed.
Make parser policy visible with text fixtures
Use small text fixtures that isolate one boundary at a time: a namespace shadow, an undeclared prefix, a DOCTYPE with an internal entity, an external identifier, and a malformed end tag. Record parser name and version, external-resource setting, entity-expansion setting, maximum input or expansion bound if configured, and the observed disposition. This is a local test contract, not a claim about every parser.
| Fixture finding | Disposition | Next action |
|---|---|---|
| Prefix expands to expected URI | Conditional | Check nested scope and attributes |
| URI differs only by case | Different name | Hold for producer contract |
| External identifier present | Hold | Require explicit resolution boundary |
| Entity text is expanded | Record policy | Bound expansion and preserve declaration |
| Malformed XML is repaired | Hold | Use a strict parser or preserve failure |
| Schema or include resolver is active | Restricted | Record resolver inputs and outputs |
Stop conditions
- Stop if a prefix is undeclared, a namespace URI changes unexpectedly, or a QName scope is unresolved.
- Stop if DOCTYPE, external entities, XInclude, or schema references are present without an explicit policy.
- Stop if parser expansion, network, file, or resolver behavior cannot be bounded and recorded.
- Stop if a repair changes names or content and the original error is not preserved.
- Stop before processing private XML when the handling boundary or owner authority is unknown.
Close with a namespace packet and a qualified next step
Keep the exact source, namespace scope inventory, entity declarations, parser settings, fixture outcomes, and unresolved references together. Pair this guide with the data provenance log for source and transformation history and the data card template for collection context. W3C syntax conformance is not a parser security guarantee, data-quality score, privacy clearance, or permission statement.
For a supported non-health collection, after the owner has authority to describe the scope and a controlled XML review packet, the qualified appraisal request path may be a preparation step. It does not parse XML, resolve entities, assess parser security, create a quote, match a buyer, issue a legal opinion, or grant a license.
Takeaways
- Preserve exact prefix scope and expanded names for elements and attributes.
- Inventory DOCTYPE and entity declarations before allowing any resolution.
- Use text fixtures to document parser policy and unresolved boundaries.
- Hold processing when external references or repairs are not bounded and recorded.