The Tree model of xml docs o The tree representation of an XML document is an ordered labeled tree There is exact tly one root There are no cycles Each non-root node has exactly one parent Each node has a label The order of elements is important but the order of attributes is not important 26 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 26 The Tree Model of XML Docs ⚫ The tree representation of an XML document is an ordered labeled tree: – There is exactly one root – There are no cycles – Each non-root node has exactly one parent – Each node has a label. – The order of elements is important – … but the order of attributes is not important
Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDS b)XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT 27 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 27 Lecture Outline 1. Introduction 2. Detailed Description of XML 3. Structuring a) DTDs b) XML Schema 4. Namespaces 5. Accessing, querying XML documents: XPath 6. Transformations: XSLT
Structuring XML Documents e Define all the element and attribute names that may be used ● Define the structure what values an attribute may take which elements may or must occur within other elements. etc o If such structuring information exists, the document can be validated 28 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 28 Structuring XML Documents ⚫ Define all the element and attribute names that may be used ⚫ Define the structure – what values an attribute may take – which elements may or must occur within other elements, etc. ⚫ If such structuring information exists, the document can be validated
Structuring XML Dcuments(2) ●AnⅩ Ml document is valid if it is well-formed respects the structuring information it uses o There are two ways of defining the structure of xml documents DTDs(the older and more restricted way) XML Schema(offers extended possibilities) 29 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 29 Structuring XML Dcuments (2) ⚫ An XML document is valid if – it is well-formed – respects the structuring information it uses ⚫ There are two ways of defining the structure of XML documents: – DTDs (the older and more restricted way) – XML Schema (offers extended possibilities)
DTD: Element Type Definition <lecturer> <name>David Billington</name> phone>+61-7-3875507</ phone> </lecturer> DTD for above element(and all lecturer elements <!ELEMENT lecturer(name, phone) <!ELEMENT namePCDATA)> <!ELEMENT phone PCDATA)> 30 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 30 DTD: Element Type Definition <lecturer> <name>David Billington</name> <phone> +61 − 7 − 3875 507 </phone> </lecturer> DTD for above element (and all lecturer elements): <!ELEMENT lecturer (name,phone)> <!ELEMENT name (#PCDATA)> <!ELEMENT phone (#PCDATA)>