INST0089 Chap.5 XML Structure and Validation
XML Structure and Validation
XML Structure and Validation presents XML as a metalanguage for making document and data structure explicit. Elements create named containers and hierarchy, attributes qualify elements and values carry content. A well-formed document has one root, matched tags, proper nesting and quoted attributes. A schema can add rules about allowed elements, order, repetition and data types.
Those technical checks remain distinct from semantic review. An XML record may validate while assigning the digitising institution as the original creator or attaching a date to the wrong resource. The chapter therefore uses a layered validation process: well-formedness, schema validation, semantic checking against the metadata rules and scenario testing against the intended operation.
Granularity is treated as an editorial choice. Detailed markup can preserve roles and relationships for transformation and analysis, but every additional distinction increases creation and maintenance cost.
What this chapter covers
- 01
XML as extensible markup
- 02
Root and child element structure
- 03
Attributes and qualified values
- 04
Proper nesting and well-formedness
- 05
Schema rules and validation evidence
- 06
Semantic and scenario testing
Worked example · free
Encode an interview record in XML
- 2Use one interview root because the XML document describes one interview record.
- 2Add title and recorded-date children with documented meanings.
- 2Repeat the subject element so the two values remain independently searchable.
- 2Nest the agent name and attach the interviewer role and local identifier consistently.
Key terms
- Document element
- The single root element containing the rest of an XML document.
- Proper nesting
- A structure in which each child element closes before its parent closes.
- XML schema
- A declared set of structural and datatype rules for XML documents.
- Semantic review
- A check that encoded properties and values assert the intended meanings.
XML Structure and Validation FAQ
What is the difference between an element and an attribute?
An element can contain text, repeated child elements and richer structure. An attribute adds a concise named qualifier to one element. Projects should choose consistently. Information that needs repetition, nesting or further context usually works better as an element, while a short role or identifier type may fit an attribute.
What does well formed XML prove?
Well-formedness proves compliance with basic XML syntax, including one root, matched tags, correct nesting and quoted attribute values. It does not prove compliance with a project schema and it cannot decide whether a Creator, Date or Relation has the right meaning for the resource.
How much XML detail should I encode?
Encode the distinctions required by the user tasks and future transformations. More tags can preserve hierarchy, roles and relationships, but they increase authoring, review and maintenance cost. State which operation needs each level of detail, then test that the chosen structure actually supports it.
Assessment move
Study XML by moving repeatedly between a conceptual tree and a text file. Begin with a small metadata record and draw the root, child elements, repeated values and nested agents. Then write the XML and trace every opening tag to its closing tag. Use indentation as a reading aid, not as a substitute for correct nesting.
Create deliberate syntax failures: an unclosed tag, overlapping elements, an unquoted attribute and a second root. Predict the parser message before running the check. Next, add a simple schema or project rules and create structurally valid records that violate order, cardinality or datatype constraints. Record the file, rule set, result and correction in a concise validation log.
Separate technical success from semantic fitness. Build one document that validates but uses the wrong agent role or date property, then explain why a human or rule-based semantic review must catch it. Test a downstream operation such as extracting repeated subjects, displaying a qualified agent or transforming a record. This proves whether the structure serves the scenario rather than merely satisfying a parser.
Compare XML with a flat table while keeping the conceptual metadata constant. Identify exactly which nesting or repetition is flattened and whether the internal task can tolerate that loss. Finish by assessing cost. Markup granularity should be justified by a query, transformation, preservation or exchange need.
Remove distinctions that have no supported use, but retain the evidence and relationships whose loss would make the representation misleading. Add one edge-case suite to your notes. Include multiple agents, an optional blank, a repeated value, a typed relation and a non-ASCII character. Predict how the schema and transformation should handle each case before running them.
When a test fails, classify the fault as syntax, schema design, semantic assignment or scenario mismatch. That diagnosis is more valuable than repeatedly editing tags until the validator turns green without understanding the cause. Save the smallest failing fragment so the correction can be reproduced later.