Skip to content

Specialist format guide

XML Namespaces and Entity Policy Review: Preserve QNames and External Boundaries

Review XML namespace bindings, expanded names, entity declarations, external references, and parser policy before processing an export.

XML can be well-formed while a consumer still resolves names or external resources differently from the producer. Review the document element, namespace declarations, prefix-to-URI bindings, qualified names, DTD and entity declarations, external identifiers, and parser policy as separate evidence. W3C specifications define XML and namespace syntax, but parser settings and operational boundaries remain implementation decisions. This guide is a static structure worksheet, not a parser security guarantee, privacy decision, or permission claim.

Updated

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.

Record the document element and namespace declarations (table)
Namespace fieldRecordStop if
Document elementPrefix, local name, expanded nameQName is resolved differently by readers
Prefix declarationPrefix, URI, element scopeSame prefix is assumed global
Default namespaceURI and element scopeUnprefixed attributes are treated as namespaced
Attribute QNamePrefix, local name, expanded nameAttribute namespace is inferred from element scope
URI spellingExact source stringCase or trailing text is silently changed
Undeclared prefixLocation and error stateParser repairs or drops it silently

Synthetic namespace fixture

Record the document element and namespace declarations code example, Plain text
<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.

Compare QNames, local names, and URI scope (table)
ComparisonSafe observationOpen question
Same prefix, same URILikely same expanded namespaceIs the scope the same at both elements?
Different prefixes, same URIExpanded names can matchWhich prefix should a derivative preserve?
Same local name, different URIDifferent expanded namesIs this an intentional version or collision?
Unprefixed attributeNo default namespace assumptionDoes the consumer expect a namespace?
Relative namespace URINon-conforming or unresolved boundaryHold for producer correction
QName in text contentString only until schema or application ruleDo 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.

Inventory DTD, entities, and external references (table)
Entity boundaryRecordStop if
DOCTYPEPresent, absent, or unknownParser strips declaration before inventory
Internal subsetDeclarations and bounded namesSubset is not retained for review
External identifierSystem or public identifier, no fetched contentResolution target is followed automatically
General entityName, replacement state, usage countExpansion is unbounded or unknown
Parameter entityDeclaration and scopeDTD behavior is not recorded
XInclude or application referencePresence and policyExternal 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.

Make parser policy visible with text fixtures (table)
Fixture findingDispositionNext action
Prefix expands to expected URIConditionalCheck nested scope and attributes
URI differs only by caseDifferent nameHold for producer contract
External identifier presentHoldRequire explicit resolution boundary
Entity text is expandedRecord policyBound expansion and preserve declaration
Malformed XML is repairedHoldUse a strict parser or preserve failure
Schema or include resolver is activeRestrictedRecord 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.

Sources

  1. World Wide Web Consortium: Extensible Markup Language (XML) 1.0, Fifth Edition (opens in a new tab)
  2. World Wide Web Consortium: Namespaces in XML 1.0, Third Edition (opens in a new tab)

Use the appraisal path after the XML policy packet is organized.

It does not parse XML, resolve entities, assess parser security, create a quote, match a buyer, or grant a license.