XML Elements(2) Tag names can be chosen almost freely o The first character must be a letter. an underscore, or a colon o No name may begin with the string xml in any combination of cases Eg.×m",“xML” 16 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 16 XML Elements (2) ⚫ Tag names can be chosen almost freely. ⚫ The first character must be a letter, an underscore, or a colon ⚫ No name may begin with the string “xml” in any combination of cases – E.g. “Xml”, “xML
Content of Xml elements o Content may be text, or other elements, or nothing <lecturer> <name> David Billington </name> phone>+61-7-3875507</ phone> ∥ ecture> If there is no content then the element is called empty; it is abbreviated as follows <lecturer/> for <lecturer></lecturer 17 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 17 Content of XML Elements ⚫ Content may be text, or other elements, or nothing <lecturer> <name>David Billington</name> <phone> +61 − 7 − 3875 507 </phone> </lecturer> ⚫ If there is no content, then the element is called empty; it is abbreviated as follows: <lecturer/> for <lecturer></lecturer>
XML Attributes e An empty element is not necessarily meaningless It may have some properties in terms of attributes e An attribute is a name-value pair inside the opening tag of an element <lecturer name="David Billington hone="+61-7-3875507" 18 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 18 XML Attributes ⚫ An empty element is not necessarily meaningless – It may have some properties in terms of attributes ⚫ An attribute is a name-value pair inside the opening tag of an element <lecturer name="David Billington" phone="+61 − 7 − 3875 507"/>
XML Attributes: An Example <order ordernos23456 customer John smith date=October 15. 2002> <item itemNo=a528 quantity=1"I> <item itemNo="c817 quantity=3> </order> 19 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 19 XML Attributes: An Example <order orderNo="23456" customer="John Smith" date="October 15, 2002"> <item itemNo="a528" quantity="1"/> <item itemNo="c817" quantity="3"/> </order>
The Same Example without Attributes <order> <orderno>23456</orderno> <customer John smith</customer <date>october 15. 2002</date> <item> <item No>a528</itemNo> <quantity >1/quantity> </item> <item> <item No>c817</itemNo> ≤ quantity3/ quantity> </item> </order 20 Chapter 2 A Semantic Web primer
Chapter 2 A Semantic Web Primer 20 The Same Example without Attributes <order> <orderNo>23456</orderNo> <customer>John Smith</customer> <date>October 15, 2002</date> <item> <itemNo>a528</itemNo> <quantity>1</quantity> </item> <item> <itemNo>c817</itemNo> <quantity>3</quantity> </item> </order>