1 / 23

XML

XML. e X tensible M arkup L anguage. http://www.w3schools.com/xml http://www.cafeconleche.org. 1/23. What is XML. stands for e X tensible M arkup L anguage a markup language much like HTML designed to describe data tags not predefined you must describe your own tags

Download Presentation

XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML eXtensibleMarkupLanguage http://www.w3schools.com/xml http://www.cafeconleche.org 1/23

  2. What is XML • stands foreXtensibleMarkupLanguage • amarkup languagemuch like HTML • designed todescribe data • tags not predefined • you mustdescribe your own tags • uses aDocument Type Definition(DTD) or anXML Schemato describe data 2/23

  3. XML and HTML • different goals • HTML designed todisplay data • how data looks • about displaying information • XML designed todescribe data • what data is • about describing information • structuring, storing & sending information 3/23

  4. XML doesn’t do anything 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) 4/23

  5. a cross-platform, software & hardware independent tool for transmitting information XML 5/23 5/23

  6. 9 XML example <?xml version=“1.0” encoding=“ISO-8859-1”?> <car make=“Honda Jazz”> <model>Vti </model> <engine capacity>1.3 litres</engine capacity> <max power>81kW @ 6000 rpm</max power> <fuel tank capacity> <quantity> 42 </quantity> <units>litres</units> </fuel tank capacity> </car> 6/23

  7. XML syntax • XML declaration • root element • XML elements 7/23

  8. XML elements • everything from (including) start tag to (including) end tag • tags are case sensitive • <LETTER> != <letter> • can have sub elements <root> <child> <subchild> … </subchild> </child> </root> 8/23

  9. 7 XML attributes • XML elements can have attributes • in the start tag • <student SID= “123456”> • <polygon name= “square” colour= “red” > • additional information about elements • not part of data • elements or attributes? 9/23

  10. elements or attributes • example 1 – date attribute • <letter date=‘1/9/05’> • <contents> ….. </contents> • </letter> • example 2 - date element • <letter> • <date> 1/9/05 </date> • <contents> ….. </contents> • </letter> • example 3 – expanded date element • <letter> • <date> • <day> 1 </day> • <month> 9 </month> • <year> 05 </year> • </date> • <contents> ….. </contents> • </letter> 10/23

  11. avoid attributes • cannot contain multiple values • not easily expandable – future • cannot describe structures • more difficult to read 11/23

  12. metadata should be stored as attributes the data should be stored as elements rule of thumb 12/23

  13. 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

  14. XML schemas • ability to specify data types for content and attribute values • ability to validate complex structures • namespace awareness 14/23

  15. 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

  16. 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

  17. schema example <?xml version=“1.0”?> <?xml version=“1.0”?> <GREETING> <GREETING> Hello XML! How are you? </GREETING> </GREETING> <?xml version=“1.0”?> <xsd:schema xmlns:xsd=“http://www.w3.org/2001/XML Schema”> <xsd:element name=“GREETING” type=“xsd:string”> </xsd:schema> <?xml version=“1.0”?> <GREETING xsi:noNamespaceSchemaLocation=“Greeting.xsd” xmlns:xsi=“http://www.w3.org/2001/XML Schema - instance”> Hello XML! </GREETING> 17/23

  18. schema structure • root element-schema • usually namespace bound to prefix xsd or xs • elements declared usingxsd:element • name attribute specifies which element declared • type attribute declares data type • attach schema to XML document by adding xsi:noNamespaceSchemaLocationattribute to the document’s root element 18/23

  19. 20 XML example <?xml version=“1.0” encoding=“ISO-8859-1”?> <car make=“Honda Jazz”> <model>Vti</model> <engine capacity>1.3 litres</engine capacity> <max power>81kW @ 6000 rpm</max power> <fuel tank capacity> <quantity>42 </quantity> <units>litres</units> </fuel tank capacity> </car> 19/23

  20. 19 schema example <?xml version=“1.0”?> <xsd:schema xmnls:xsd=“http://www.w3.org/2001/XML Schema”> <xsd:element name=“car” type=“vehicletype” /> <xsd:complexType name=“vehicletype”> <xsd:attribute name=“make” type=“xsd:string/> <xsd:sequence> <xsd:element name=“model” type=“xsd:string”/> <xsd:element name=“engine capacity” type=“xsd:string”/> <xsd:element name=“max power ” type=“xsd:string”/> <xsd:element name=“fuel tank capacity”> <xsd:complexType> <xsd:sequence> <xsd:element name=“quantity” type=“xsd:positiveInteger”/> <xsd:element name=“units” type=“xsd:string”/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:schema> 20/23

  21. 22 XML example <?xml version=“1.0” encoding=“ISO-8859-1”?> <building id=“myHouse”> <type>house</type> <no. of storeys>3</no. of storeys> <area>180</area> <component>storey1</component <component>storey2</component> <component>storey3</component> </building> 21/23

  22. 21 schema example <?xml version=“1.0”?> <xsd:schema xmnls:xsd=“http://www.w3.org/2001/XML Schema”> <xsd:element name=“building”> <xsd:complexType> <xsd:attribute name=“id” type=“xsd:string/> <xsd:sequence> <xsd:element name=“type” type=“xsd:string”/> <xsd:element name=“no.of storeys” type=“xsd:positiveInteger” maxInclusive=“4”/> <xsd:element name=“area ” type=“xsd:float”/> <xsd:element name=“component” type=“xsd:string maxOccurs=“unbounded”/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> 22/23

  23. aecXML • working group – 1999 • for exchange of AEC specific information • http://xml.coverpages.org/aecXML.html • XML schemas for communication • designing, specifying, estimating, sourcing, installing & maintaining products & materials over the Internet • AISC steel information in XML • Bentley -2001 • aecXML & IFC • http://www.cadinfo.net/editorial/aecxml.htm 23/23

More Related