XMLSchema, RelaxNG T. Pitner, L. Bártek, A. Rambousek. L Grolig FI MU Brno 2020 XMLSchema - Motivation Stronger tool for XML data model specification than DTD, it allows: ● Separate type (e.g. element type) from its occurrence (i.e. element with particular name) ● More primitive data types. ● Allows to use namespaces. ● Allows to specify content model (elements) more accurate way. ● Allows new type inheritance. ● Allows modular schema design and schema reuse. ● XML Schema has an XML syntax. XMLSchema XMLSchema - Element type XMLSchema - Element type (short) XMLSchema - Simple type ... e.g. XMLSchema - Union Union of two simple types - string restricted by regular expression and enumeration XMLSchema - inheritance isbnTypes - basic type, isbnTypes10 - derived type restriction with XMLSchema - Complex type complex type ... typically defines elements applies to elements sequence of child XMLSchema - Group of elements ... group type - reusable sequence of child elements and choice or all type - may be used instead of sequence XMLSchema - Attribute group ... attribute group - reusable set of attributes XMLSchema - Namespaces .../... XMLSchema - reference or RelaxNG - Alternative to Schema John Smith js@example.com Fred Bloggs fb@example.net RelaxNG vs DTD addressBook [ addressBook (card*)> card (name, email)> name (#PCDATA)> email (#PCDATA)> Do you like this or that? element addressBook { element card { element name { text }, element email { text } }* } RelaxNG - Cardinality indication element addressBook { element card { element name { text }, element email { text } }* } could be + or ? or * or nothing RelaxNG - Options element addressBook { element card { # here is the option (element name { text } | (element givenName { text }, element familyName { text })), element email { text }, element note { text }? }* } RelaxNG - Options with attributes element addressBook { element card { (element name { text } | attribute name { text }), (element email { text } | attribute email { text }) }* } RelaxNG - Grammar grammar { start = AddressBook AddressBook = element Card = element card { Name = element name { Email = element email } addressBook { Card* } Name, Email } text } { text } RelaxNG - Enumerations element card attribute attribute attribute } { name { text }, email { text }, preferredFormat { "html" | "text" } element card { element name { text }, element email { text }, element preferredFormat { "html" | "text" } }