XML: elements and attributes
Health Data Formats: XML, JSON and Turtle: XML: elements and attributes.
XML wraps every value in tags
X M L writes a value between two tags. A start tag opens it and an end tag closes it. Put those pieces inside each other, and you can describe a whole record.
A form, as XML
Here is a made up person form. Turn it over, and this is the same record in X M L. The whole record sits inside one outer element, called person. Inside it, each item is an element: a start tag, the value, and an end tag. An element can also carry an attribute. Here, the use of the email address is written inside the start tag, as a name and a quoted value. One form, written as nested elements.
Three rules for well-formed XML
Before anything else, X M L must be well formed. That means three things. There is one root element, and nothing outside it. Elements nest properly: an element that starts inside another must also end inside it. And every element is closed: it has a start tag and an end tag, or it is an empty element, written with a single empty element tag.
- Rule 1 · One root element · Everything sits inside it. · box
- Rule 2 · Proper nesting · Inner elements end inside outer ones. · layers
- Rule 3 · Every element closed · End tag, or an empty-element tag. · check
A mistake, and the rule it breaks
Match the mistake to the rule it breaks. Two outer elements side by side break the one root rule. Tags that overlap instead of nesting break the nesting rule. A start tag with no end tag breaks the closed element rule. And an attribute value without quotes breaks the attribute syntax, because values must be quoted. When a processor finds a fatal error like these, the standard says it must report it, and must not carry on as normal.
- Two outer elements, side by side · No single root element · box · navy
- Tags that overlap · Breaks proper nesting · layers · navy
- A start tag with no end tag · Element not closed · cross · amber
- An attribute value with no quotes · Breaks attribute syntax · warning · slate
Check yourself
Pause and think. How does X M L mark the start and end of an element? The answer: a start tag and an end tag, or one empty element tag.
- A start tag and an end tag, or one empty-element tag
- Curly brackets around the value
- A blank line before and after
- A comma after each value
Keep these in mind
An element is a start tag, a value and an end tag. Elements nest inside one root element. An attribute sits inside the start tag, in quotes. And a document that is not well formed is an error, not a warning.
- An element is a start tag, a value and an end tag
- Elements nest inside one root element
- An attribute sits inside the start tag, in quotes
- Not well-formed is an error, not a warning
SNOMED CT®, LOINC®, ICD और अन्य terminologies अपने-अपने स्वामियों की संपत्ति हैं और लाइसेंस के अंतर्गत केवल शिक्षा के लिए दिखाई गई हैं। लाइसेंस और attributions