This appendix provides a quick summary of XML terms and concepts, as a refresher for users working with the InterSystems IRIS %XML classes. It is assumed that the reader is familiar with the basic syntax of XML, so this appendix is not intended as a primer on XML. It does not, for example, describe the syntax or list reserved characters. However, it does provide a list of the terms with short definitions, as a reference.
A name-value pair of the following form:
Attributes reside within elements, as shown below, and an element can have any number of attributes.
<Patient ID="QD5690">Cromley,Marcia N.</Patient>
Denotes text that should not be validated, as follows:
Non-validated data goes here.
You can even have stray "<" or ">" symbols in it.
A CDATA (character data) section cannot contain the string ]]>
because this string marks the end of the section. This also means that CDATA sections cannot be nested.
Note that the contents of a CDATA section must conform to the encoding specified for the XML document, as does the rest of the XML document.
The namespace to which any unqualified elements belong, in a given context. A default namespace is added without a prefix. For example:
Because this namespace declaration does not use a prefix, the <Person>
, and <DOB>
elements all belong to this namespace.
Note that the following XML, which does not use a default namespace, is effectively equivalent to the preceding example:
DTD (document type definition)
An element typically consists of two tags (a start tag and an end tag), possibly surrounding text and other elements. The content of the element is everything between these two tags, including text and any child elements. The following is a complete XML element, with start tag, text content, and end tag:
An element can have any number of attributes and any number of child elements.
An empty element can either include a start tag and an end tag, or just a single tag. The following examples are equivalent:
In practice, elements are likely to refer to different parts of data records, such as:
The concepts of global and local elements apply to documents that use namespaces. The names of global elements are placed in a separate symbol space from those of local elements. A global element is an element whose type has global scope, that is, an element whose type is defined at the top level in the corresponding XML schema. Element declarations that appear as children of the <xs:schema>
element are considered to be global declarations. Any other element declaration is a local element, unless it references a global declaration through the ref
attribute, which effectively makes it a global element.
Attributes are global or local in the same way.
A namespace is a unique string that defines a domain for identifiers so that XML-based applications do not confuse one type of document with another. It is typically given as a URI (uniform resource indicator) in the form of a URL (uniform resource location), which may or may not correspond to an actual web address. For example, "http://www.w3.org"
is a namespace.
You include a namespace declaration with one of the following syntaxes:
In either case, the namespace is used only within the context where you inserted the namespace declaration. In the latter case, the namespace is associated with the given prefix (pre
). Then an element or attribute belongs to this namespace if and only if the element or attribute also has this prefix. For example:
The namespace declaration uses the s01
prefix. The <Person>
element uses this prefix as well, so this element belongs to this namespace. The <Name>
elements, however, do not explicitly belong to any namespace.
processing instructions (PI)
root, root element, document element
An element or attribute is qualified if it is explicitly assigned to a namespace. Consider the following example, in which the elements and attribute of <Person>
are not qualified:
<?xml version="1.0" encoding="UTF-8"?>
<s01:Person xmlns:s01="http://www.person.com" GroupID="J1151">
Here, the namespace declaration uses the s01
prefix. There is no default namespace. The <Person>
element uses this prefix as well, so that element belongs to this namespace. There is no prefix for the <Name>
elements or the <GroupID>
attribute, so these do not explicitly belong to any namespace.
In contrast, consider the following case where the elements and attribute of <Person>
<?xml version="1.0" encoding="UTF-8"?>
<Person xmlns="http://www.person.com" GroupID="J1151">
In this case, the <Person>
element defines a default namespace, which applies to the child elements and the attribute.
The XML schema attributes elementFormDefault
attribute and attributeFormDefault
attribute control whether elements and attributes are qualified in a given schema. In InterSystems IRIS XML support, you use a class parameter to specify whether elements are qualified.
A document that specifies meta-information for a set of XML documents, as an alternative to a DTD. As with a DTD, you can use a schema to validate the contents of specific XML documents. XML schemas offer several advantages over DTDs for certain applications, including these:
An XML schema is a valid XML document, making it easier to develop tools that operate on schemas.
An XML schema can specify a richer set of features and includes type information for values.
Formally, a schema document is a XML document that complies with the W3 XML Schema specification (http://www.w3.org/XML/Schema
). It obeys the rules of XML and uses some additional syntax. Typically the extension of the file is .xsd
A constraint placed upon the interpretation of data. In an XML schema, the definition of each element and attribute corresponds to a type.
Each attribute has a simple type. Simple types also represent elements that have no attributes and no child elements (only text nodes). Complex types represent other elements.
The following fragment of a schema shows some type definitions:
<s:element name="Name" type="s:string" minOccurs="0" />
<s:element name="DOB" type="s:date" minOccurs="0" />
<s:element name="Address" type="s_Address" minOccurs="0" />
<s:attribute name="GroupID" type="s:string" />
<s:element name="City" type="s:string" minOccurs="0" />
<s:element name="Zip" type="s:string" minOccurs="0" />