XML Schema PB138 What is XML Schema ● XML document How to validate ● Create people.xsd and validate people.xml with it xmllint --schema mySchema.xsd neco.xml Basic XML Schema Basic builtin types ● xs:string ● xs:anyType ● xs:any Element with Elements Defining Own Data Types Defining Data Types ● Nodes in XML have data types ● Attrs or Elements may be of Simple Type ● may contain sequence of elements (all, choice....) ○ minOccurs ○ maxOccurs ● After the sequence, all, choice you can declare attrs: Simple Types ● We may specify precisely by inheritance ○ name is special type of string ○ date is special type of string ○ positive integer is special type of string Enrich People XML and write XSD ● Add attribute BirthDate with regex format “MM-DD-YYYY” ● Write XSD schema for people.xml Elements just with Attributes ● Complex type, simple content ! ... xs:unique Must be inside ! ... xs:key xs:keyref ... What else is XML schema? ● Defining uniqueness (we need XPath) ● Element/Attribute groups ● Unions ● References ● Includes/Imports ● Annotations