XML e X tensible M arkup L anguage 1/23
What is XML ● stands for eXtensible Markup Language ● a markup language much like HTML ● designed to describe data ● tags not predefined ● you must describe your own tags ● uses a Document Type Definition (DTD) or an XML Schema to describe data 2/23
XML and HTML ● different goals ● HTML designed to display data ● how data looks ● about displaying information ● XML designed to describe data ● what data is ● about describing information ● structuring, storing & sending information 3/23
what does XML do? ● XML can be used to exchange data ● many different applications ● over the internet ● XML can be used to create new languages ● WAP (Wireless Application Protocol) ● WML (Wireless Markup Language) XML doesn’t do anything 4/23
XML a cross-platform, software & hardware independent tool for transmitting information 5/23
XML example Vti 1.3 litres 6000 rpm 42 litres 6/23 9
XML syntax ● XML declaration ● root element ● XML elements 7/23
XML elements ● everything from (including) start tag to (including) end tag ● tags are case sensitive ● != ● can have sub elements … 8/23
XML attributes ● XML elements can have attributes in the start tag ● ● additional information about elements ● not part of data ● elements or attributes? 9/23 7
elements or attributes ● example 1 – date attribute ….. ● example 2 - date element 1/9/05 ….. ● example 3 – expanded date element ….. 10/23
avoid attributes ● cannot contain multiple values ● not easily expandable – future ● cannot describe structures ● more difficult to read 11/23
rule of thumb metadata should be stored as attributes the data should be stored as elements 12/23
XML validation ● XML with correct syntax is Well Formed ● a DTD (Document Type Definition) defines the legal contents of an XML document ● an XML schema is an alternative to a DTD 13/23
XML schemas ● ability to specify data types for content and attribute values ● ability to validate complex structures ● namespace awareness 14/23
why not DTDs ● no data typing ability ● e.g. can’t say element must be an integer 1-12 ● non-XML syntax ● cannot be parsed by same parser ● difficult to modularize and combine ● cannot enforce order or number of child elements 15/23
what is a schema ● hypothetical outline - pattern ● document that describes permissible content of a database ● many schema languages for XML ● W3C XML Schema Language ● by convention – in.xsd extension 16/23
schema example Hello XML! How are you? <GREETING xsi:noNamespaceSchemaLocation=“Greeting.xsd” xmlns:xsi=“ Schema - instance”> Hello XML! 17/23
schema structure ● root element - schema ● usually namespace bound to prefix xsd or xs ● elements declared using xsd:element ● name attribute specifies which element declared ● type attribute declares data type ● attach schema to XML document by adding xsi:noNamespaceSchemaLocation attribute to the document’s root element 18/23
XML example Vti 1.3 litres 6000 rpm 42 litres 19/23 20
schema example 20/23 19
XML example house storey1 </component storey2 storey3 21/23 22
schema example <xsd:element name=“no.of storeys” type=“xsd:positiveInteger” maxInclusive=“4”/> <xsd:element name=“component” type=“xsd:string maxOccurs=“unbounded”/> 22/23 21
aecXML ● working group – 1999 ● for exchange of AEC specific information ● ● XML schemas for communication ● designing, specifying, estimating, sourcing, installing & maintaining products & materials over the Internet ● AISC steel information in XML ● Bentley ● aecXML & IFC ● 23/23