Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.

Similar presentations


Presentation on theme: "1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but."— Presentation transcript:

1 1 Introduction to XML Babak Esfandiari

2 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but simpler than SGML it is used to to describe metadata you can define your own set of tags! – an XML document does not “do” anything on its own

3 3 XML example Paris

4 4 XML - what for? content is independent from rendering meta-data makes search easier standard tags enable data interchange across tools format for data and object persistence, human readable and editable no need for a custom parser anymore

5 5 XML concepts and syntax Elements – can be nested – must have a closing tag Attributes XML declaration Comments

6 6 XML concepts (2) An XML document that follows the syntax rules is considered well-formed But there is no restriction on the nature, order and number of tags in a well-formed XML document! – in order to impose some restrictions, you need to define validity criteria in a separate document…

7 7 DTD Document Type Definition Describes the XML tagset <!DOCTYPE Museum [ ]> An XML document that is compliant to its DTD is valid

8 8 DTD Syntax Defining elements: <!ELEMENT Museum (city?, genre+) Character data types: – #PCDATA (is parsed) – #CDATA (is not parsed)

9 9 DTD DTDs are hard to read DTD has its own syntax DTD has very limited support for data types

10 10 XML Schema a 2001 W3C recommendation allows the definition of elements and attributes using the XML syntax supports many primitive types allows the creation of complex types uses namespaces to: – allow reuse of types and schemas – avoid naming clashes

11 11 XML Schema Example http://chat.carleton.ca/~narthorn/project/community.xsd

12 12 Some XML-based standards MathML CML MusicXML XMI

13 13 XMI Example Museum name

14 14 XML Parsing Many XML parsers are available: JAXP, XERCES… Two “standardized” parsing methods: – SAX event-driven serial-access element-by-element processing – DOM creates a tree structure of objects stores it in memory easier to navigate, but more memory needed

15 15 SAX good to use if you are “consuming” XML data from a stream see Echo.java example (from JAXP)

16 16 DOM use it if you need “random access” to various elements of the document see EchoDom.java example

17 17 XSLT eXtensible Stylesheet Language Templates allows the transformation of one XML document into another by specifying transformation rules

18 18 XSLT example blah

19 19 Semantic Web Tim Berners-Lee’s idea of the future of the Web The goal is to make information accessible to non-humans(ie agents) Therefore information should be structured and use metadata – RDF is proposed as such structure

20 20 RDF Example See Software Agents course example

21 21 Refs W3C specs: http://www.w3.org/TR/REC-xml


Download ppt "1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but."

Similar presentations


Ads by Google