XML Verification Well-formed XML document conforms to basic XML syntax contains only built-in character entities Validated XML document conforms to the grammar of a specific data type uses any predeclared entities specified by Document Type Declaration
XML: Type Declaration (DTD) A DTD specifies the grammar for a simple data structure ordering repeatability labelling vocabulary / schema / ontology DTD defined in an external entity overridden by local definitions
DTD: elements (text) Element declarations just text Here is some text. No italics allowed.
DTD: elements (sequences) just a sequence of elements... Les
DTD: elements (alternatives) just a choice of elements... Les
DTD: elements (repetition) element repetition can be controlled ?optional +required and repeatable *optional and repeatable element can be grouped with ( ) <!ELEMENT customer ( ((surname, initials) | custid), purchases*, visits+ )>
DTD: elements (mixed) mixed content (text interspersed with elements) <!ELEMENT para (#PCDATA | italic | bold | link | image)* -- optional repeatable choice group with #PCDATA as first item -- >
DTD: elements (misc) no content any content
DTD: attribute declarations Attribute declarations <!ATTLIST para security…security attribute info… author…author attribute info… id …id attribute info… > Each attribute has a type and default <!ATTLIST para security (private|public) public author CDATA #IMPLIED id ID #REQUIRED >
DTD: attribute types Attribute types CDATA, NMTOKEN(S), ENTITY(-IES), ID, IDREF(S), enumeration Default values string token #IMPLIED #REQUIRED #FIXED (must precede default)
DTD: declaring entities Entities can be strings Entities can be external files Entities can be binary data formats <!ENTITY disc PUBLIC "-//CC//Standard Disclaimer//EN" "/lib/stddisc.xml">
DTD: using entities Entities must be declared in a DTD <!DOCTYPE Book [ ]> Entities can be used in text or attributes &chap1; &chap2; &chap3;
DTD: entities for DTDs Parameter entities provide macro expansion within a DTD use '%' instead of '&' prefix name by '%' in declaration <!ELEMENT stuff ( %common; | )
Namespaces Namespaces allow different designers to create different elements and attribute names for different purposes. e.g. M&S catalogue element for screen layout element for describing furniture
Namespaces (2) Namespace is identified with a URL Namespace is referred to by a prefix Any name from that namespace is referred to by a qualified name prefix:name e.g. or
Namespaces (3) Namespace is defined at the document root by the xmlns: attribute prefix …