Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.

Similar presentations


Presentation on theme: "COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week."— Presentation transcript:

1 COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411

2 Extensible Markup Language (XML) 2COMP9321, 15s2, Week 4 XML is a markup language much like HTML HTML: display HTML was designed to display data. HTML tags are not predefined. XML: describe XML was designed to describe data. XML tags are not predefined. XML is designed to be self-descriptive XML is a W3C Recommendation XML is derived from SGML (ISO 8879). (Standard Generalized Markup Language) is a standard for how to specify a document markup language or tag set.

3 Extensible Markup Language (XML) 3COMP9321, 15s2, Week 4 XML originally designed to meet the challenges of large-scale electronic publishing. XML separates presentation issues from the actual data. XML plays an increasingly important role in the exchange of a wide variety of data on the Web and elsewhere. Needs a communication protocol? e.g. SOAP stands for Simple Object Access Protocol SOAP is based on XML SOAP is a W3C recommendation SOAP uses XML Information Set for its message format.

4 Extensible Markup Language (XML) 4COMP9321, 15s2, Week 4

5 XML: Tags, tags 5COMP9321, 15s2, Week 4 Consider the following snippet of information from a staff list:

6 Why XML? 6COMP9321, 15s2, Week 4

7 Why XML? 7COMP9321, 15s2, Week 4

8 Separating the Content from Presentation 8COMP9321, 15s2, Week 4 display HTML was designed to display data. describe XML was designed to describe data. CSS: Cascading Style Sheets CSS defines how HTML elements are to be displayed All formatting could be removed from the HTML document, and stored in a separate CSS file.

9 Separating the Content from Presentation 9COMP9321, 15s2, Week 4

10 XML Applications 10COMP9321, 15s2, Week 4

11 XML Applications 11COMP9321, 15s2, Week 4 RSS : Really Simple Syndication With RSS it is possible to distribute up-to-date web content from one web site to thousands of other web sites around the world. RSS is written in XML RSS allows you to syndicate your site content RSS defines an easy way to share and view headlines and content RSS files can be automatically updated RSS allows personalized views for different sites RSS is useful for web sites that are updated frequently, like: e.g. News sites, Companies, and Calendars. Without RSS, users will have to check your site daily for new updates.

12 XML Applications 12COMP9321, 15s2, Week 4 RSS : Really Simple Syndication With RSS it is possible to distribute up-to-date web content from one web site to thousands of other web sites around the world. RSS is written in XML RSS allows you to syndicate your site content RSS defines an easy way to share and view headlines and content RSS files can be automatically updated RSS allows personalized views for different sites RSS is useful for web sites that are updated frequently, like: e.g. News sites, Companies, and Calendars. Without RSS, users will have to check your site daily for new updates.

13 XML is … 13COMP9321, 15s2, Week 4

14 Quick XML syntax 14COMP9321, 15s2, Week 4

15 The XML Family 15COMP9321, 15s2, Week 4 XML: a markup language used to describe information.

16 The XML Family 16COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: XML DOM defines a standard for accessing and manipulating XML documents. The DOM presents an XML document as a tree-structure. The DOM is a W3C standard. The DOM is separated into 3 different parts / levels: Core DOM - standard model for any structured document XML DOM - standard model for XML documents A standard object model for XML A standard programming interface for XML Platform- and language-independent HTML DOM - standard model for HTML documents

17 The XML Family 17COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: XML DOM defines a standard for accessing and manipulating XML documents. The DOM presents an XML document as a tree-structure. The DOM is a W3C standard. The DOM is separated into 3 different parts / levels: Core DOM - standard model for any structured document XML DOM - standard model for XML documents A standard object model for XML A standard programming interface for XML Platform- and language-independent HTML DOM - standard model for HTML documents

18 The XML Family 18COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD: A Document Type Definition (DTD) defines the structure and the legal elements and attributes of an XML document. from a DTD point of view, all XML documents are made up by the following building blocks: Elements Elements: … Attributes Attributes: … Entity References Entity References: < > & " &apos; The character data inside an element must not contain certain characters with special meanings (e.g., < means start of a tag). You must escape the characters using entity references <image source='koala.gif' width='122' height='66' alt = 'Powered by O&apos;Reilly Books' />

19 The XML Family 19COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD: A Document Type Definition (DTD) defines the structure and the legal elements and attributes of an XML document. from a DTD point of view, all XML documents are made up by the following building blocks: Elements Elements: … Attributes Attributes: … Entities Entities: < > & " &apos; PCDATA PCDATA (Parsed Character DATA): is the text that WILL be parsed by a parser. CDATA CDATA (character data) is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.

20 Phonebook.xml with Internal DTD 20COMP9321, 15s2, Week 4

21 Phonebook.xml with External DTD. Phonebook.dtd 21COMP9321, 15s2, Week 4

22 CDATA Section 22COMP9321, 15s2, Week 4

23 Defining XML Content: Elements 23COMP9321, 15s2, Week 4

24 Defining XML Content: Modifiers 24COMP9321, 15s2, Week 4

25 Defining XML Content: Choices, Empty 25COMP9321, 15s2, Week 4

26 Defining XML Content: Mixed content, Any 26COMP9321, 15s2, Week 4

27 Defining XML Content: Creating Attributes 27COMP9321, 15s2, Week 4

28 Defining XML Content: Creating Attributes 28COMP9321, 15s2, Week 4

29 XML Custom Entities 29COMP9321, 15s2, Week 4

30 Parameter Entities 30COMP9321, 15s2, Week 4

31 Well-formedness and Validity of XML 31COMP9321, 15s2, Week 4

32 Limitations of DTD 32COMP9321, 15s2, Week 4

33 The XML Family 33COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. XML Schema: is an XML-based alternative to DTD. describes the structure of an XML document. defines elements and attributes that can appear in a document defines data types for elements and attributes defines default and fixed values for elements and attributes defines the child elements, their orders, etc. XML Schemas are much more powerful than DTDs. The XML Schema language is also referred to as XML Schema Definition (XSD).

34 The XML Family 34COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. XML Schema: XML Schema - W3C's recommendation for replacing DTD with features such as: Simple and complex data types Type derivation and inheritance Namespace-aware element and attributes Limits on number of appearances by an element Combining with regular expressions for finer control over document structure Most importantly, XML Schemas are well-formed XML documents what is a namespace themselves. But first, what is a namespace ?

35 XML Namespaces 35COMP9321, 15s2, Week 4

36 XML Namespaces (example) 36COMP9321, 15s2, Week 4

37 XML Namespaces 37COMP9321, 15s2, Week 4

38 Previous examples can now be... 38COMP9321, 15s2, Week 4

39 XML Namespace Syntax 39COMP9321, 15s2, Week 4

40 XML Schema Definition (XSD) 40COMP9321, 15s2, Week 4 a recommendation of the World Wide Web Consortium (W3C) specifies how to formally describe the elements in an Extensible Markup Language (XML) document.

41 Simple Types 41COMP9321, 15s2, Week 4

42 Attributes 42COMP9321, 15s2, Week 4

43 Type Restrictions 43COMP9321, 15s2, Week 4

44 Complex Types 44COMP9321, 15s2, Week 4

45 Complex Types 45COMP9321, 15s2, Week 4

46 The XML Family 46COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD and XML Schema: describes the structure and content of XML documents. XSLT: XSL stands for eXtensible Stylesheet Language, and is a style sheet language for XML documents. CSS = Style Sheets for HTML XSL = Style Sheets for XML XSL describes how the XML document should be displayed! XSLT (XSL Transformations) a language for transforming XML documents.

47 The XML Family 47COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD and XML Schema: describes the structure and content of XML documents. XSLT: a language for transforming XML documents

48 The XML Family 48COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD and XML Schema: describes the structure and content of XML documents. XSLT: a language for transforming XML documents XPath: XPath (XML Path language) is a language for finding information in an XML document. XPath contains a library of standard functions XPath is a major element in XSLT XPath is also used in XQuery, XPointer and XLink XPath is a W3C recommendation

49 The XML Family 49COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD and XML Schema: describes the structure and content of XML documents. XSLT: a language for transforming XML documents XPath: XPath (XML Path language) is a language for finding information in an XML document. XPath contains a library of standard functions XPath is a major element in XSLT XPath is also used in XQuery, XPointer and XLink XPath is a W3C recommendation 50001 Adam B. 8543 1 50002 Alex C. 3978 3 50001 Adam B. 8543 1 50002 Alex C. 3978 3 some XPath expressions: /comp9321_student/student[1] Selects the first “student” element that is the child of the “comp9321_student” element /comp9321_student/student[last()] Selects the last “student” element that is the child of the “comp9321_student” element /comp9321_student/student[position()<3] Selects the first two “student” element that is the child of the “comp9321_student” element /comp9321_student/student[stage>2] Selects all the “student” elements of the “comp9321_student” element that have a “stage” element with a value greater than 2. … some XPath expressions: /comp9321_student/student[1] Selects the first “student” element that is the child of the “comp9321_student” element /comp9321_student/student[last()] Selects the last “student” element that is the child of the “comp9321_student” element /comp9321_student/student[position()<3] Selects the first two “student” element that is the child of the “comp9321_student” element /comp9321_student/student[stage>2] Selects all the “student” elements of the “comp9321_student” element that have a “stage” element with a value greater than 2. …

50 The XML Family 50COMP9321, 15s2, Week 4 XML: a markup language used to describe information. DOM: a programming interface for accessing and updating documents. DTD and XML Schema: describes the structure and content of XML documents. XSLT: a language for transforming XML documents XPath: a query language for navigating XML documents. XPointer: for identifying fragments of a document. XLink: generalises the concept of a hypertext link. XInclude: for merging documents. XQuery: a language for making queries across documents. RDF: a language for describing resources.

51 An XML document is a tree... 51COMP9321, 15s2, Week 4

52 Attributes in XML tags 52COMP9321, 15s2, Week 4

53 Attributes in XML tags 53COMP9321, 15s2, Week 4

54 Parsing XML documents with Java 54COMP9321, 15s2, Week 4

55 Parsing XML documents with Java 55COMP9321, 15s2, Week 4

56 SAX and DOM as the Standard Interfaces 56COMP9321, 15s2, Week 4

57 Document Object Model (DOM) 57COMP9321, 15s2, Week 4

58 Dealing with Nodes in DOM 58COMP9321, 15s2, Week 4

59 An example XML here... 59COMP9321, 15s2, Week 4

60 DOM for XML 60COMP9321, 15s2, Week 4

61 Using a DOM Parser (eg., Apache Xerces) 61COMP9321, 15s2, Week 4

62 Document Interface Methods 62COMP9321, 15s2, Week 4

63 Examples of Node Properties (XML), p.9.25 63COMP9321, 15s2, Week 4

64 Count/Print the number of 'book' elements 64COMP9321, 15s2, Week 4

65 Dealing with Nodes in DOM 65COMP9321, 15s2, Week 4

66 Dealing with Nodes 66COMP9321, 15s2, Week 4

67 The Element interface 67COMP9321, 15s2, Week 4

68 More with DOM... 68COMP9321, 15s2, Week 4

69 References 69COMP9321, 15s2, Week 4 http://www.w3.org/XML/ XML in a nutshell, Chapters 9 and 10 http://www.ibm.com/developerworks/library/xml-schema/ http://www.w3schools.com/xml/ Some examples in these notes are originated from Dr. David Edmond from QUT, Brisbane

70 70COMP9321, 15s2, Week 4


Download ppt "COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week."

Similar presentations


Ads by Google