XML Elements vs Attributes o Attributes can be replaced by elements e When to use elements and when attributes is a matter of taste o But attributes cannot be nested 21 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 21 XML Elements vs Attributes ⚫ Attributes can be replaced by elements ⚫ When to use elements and when attributes is a matter of taste ⚫ But attributes cannot be nested
Further Components of XML Docs Comments a piece of text that is to be ignored by parser <!- This is a comment -- Processing Instructions(PIs Define procedural attachments <?stylesheet type="text/css href="mystyle. css"?> 22 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 22 Further Components of XML Docs ⚫ Comments – A piece of text that is to be ignored by parser – <!-- This is a comment --> ⚫ Processing Instructions (PIs) – Define procedural attachments – <?stylesheet type="text/css" href="mystyle.css"?>
Well-Formed XMl documents e Syntactically correct documents ● Some syntactic rules Only one outermost element (called root element) Each element contains an opening and a corresponding closing tag Tags may not overlap e <author<name>Lee Hong</author</name> Attributes within an element have unique names Element and tag names must be permissible 23 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 23 Well-Formed XML Documents ⚫ Syntactically correct documents ⚫ Some syntactic rules: – Only one outermost element (called root element) – Each element contains an opening and a corresponding closing tag – Tags may not overlap ⚫ <author><name>Lee Hong</author></name> – Attributes within an element have unique names – Element and tag names must be permissible
The Tree model of xml documents An Example <email> <head> <from name="Michael maher address="michaelmaher@cs. gu. edu. au"> <to name="Grigoris Antoniou address="grigoris@cs. unibremen de"S <subject Where is your draft? </subject> </head> <body> Grigoris, where is the draft of the paper you promised me last week? </bod </email> 24 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 24 The Tree Model of XML Documents: An Example <email> <head> <from name="Michael Maher" address="michaelmaher@cs.gu.edu.au"/> <to name="Grigoris Antoniou" address="grigoris@cs.unibremen.de"/> <subject>Where is your draft?</subject> </head> <body> Grigoris, where is the draft of the paper you promised me last week? </body> </email>
The Tree model of xml documents An Example(2) body befre adJres artoria. att。th =[[小 o:;1 your dratt ast wes 25 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 25 The Tree Model of XML Documents: An Example (2)