| Viewpoint | Concept | Characteristics |
|---|---|---|
| data | XML is a data format | No mixed content Lots of attributes Often a memory dump of internal objects Often inflexible |
| document | XML is a document format | Mixed content Favors elements over attributes High-level view of mixed data Very flexible to additional elements and attributes |
| Part | Example |
|---|---|
| Element | |
| Element Start Tag | |
| Element End Tag | |
| Empty Element |
| Content Type | Example | Value |
|---|---|---|
| Text | "cin" is the text content of the element name | |
| Nested elements | Element "name" is nested inside of element expr | |
| Element | The start tag, the end tag, and all content in between |
| Example | Nested Text | Nested Elements | Purpose | |
|---|---|---|---|---|
| Attributes | Yes | No | metadata | |
| Subelements | Yes | Yes | data |
<students>...</students>| Unescaped | Escaped | Requirements |
|---|---|---|
< |
< |
escape required |
& |
& |
escape required |
> |
> |
escape optional |
' |
' |
escape depends on context |
" |
" |
escape depends on context |
| Unescaped | |
| Escaped |
| Namespace Declaration | xmlns:s="https://mlcollard.net/Student" |
| Prefix | s |
| URI | https://mlcollard.net/Student |
| Element in the namespace | <s:grade> |
| Default Namespace Declaration | xmlns="https://mlcollard.net/Student" |
xmllint - Tool for checking if XML is well-formed| XML Comment | <!-- <s:student> --> |
| XML Comment Start | <!-- |
| XML Comment End | --> |
| Term | Expansion | Example | Relation to Namespaces |
|---|---|---|---|
| qName | qualified name | s:student |
Unique |
| prefix | prefix | s |
Shared |
| localName | local name | student |
May exist in multiple |
| URI | Uniform Resource Identifier | https://mlcollard.net/Student |
URLs are a subset of URIs |
| Concept | Attributes | Notes |
|---|---|---|
| Start Document | Occurs before parsing | |
| XML Declaration | version, encoding, standalone | Occurs once before the root |
| Element Start Tag | qName, prefix, localName | |
| Element End Tag | qName, prefix, localName | |
| Characters | characters | Includes entity references |
| Attribute | qName, prefix, localName, value | |
| XML Namespace | prefix, uri | |
| XML Comment | value | |
| CDATA | characters | Somewhat rare, and not in our data |
| Processing Instruction | target, data | Rare, and not in our data |
| End Document | Occurs after parsing |