COMP9321 Web Application Engineering. Extensible Markup Language (XML)

Similar documents
COMP9321 Web Application Engineering

COMP9321 Web Application Engineering

11. EXTENSIBLE MARKUP LANGUAGE (XML)

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

COMP9321 Web Application Engineering

Chapter 1: Getting Started. You will learn:

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

XML. Objectives. Duration. Audience. Pre-Requisites

Introduction to XML. XML: basic elements


CSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML

M359 Block5 - Lecture12 Eng/ Waleed Omar

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

markup language carry data define your own tags self-descriptive W3C Recommendation

COMP9321 Web Application Engineering

Markup Languages SGML, HTML, XML, XHTML. CS 431 February 13, 2006 Carl Lagoze Cornell University

What is XML? XML is designed to transport and store data.

COMP9321 Web Application Engineering

Appendix H XML Quick Reference

The concept of DTD. DTD(Document Type Definition) Why we need DTD

XML: Extensible Markup Language

The XML Metalanguage

User Interaction: XML and JSON

Java EE 7: Back-end Server Application Development 4-2

2009 Martin v. Löwis. Data-centric XML. XML Syntax

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95

XML (Extensible Markup Language)

Structured documents

XML. Jonathan Geisler. April 18, 2008

Data Exchange. Hyper-Text Markup Language. Contents: HTML Sample. HTML Motivation. Cascading Style Sheets (CSS) Problems w/html

Introduction p. 1 An XML Primer p. 5 History of XML p. 6 Benefits of XML p. 11 Components of XML p. 12 BNF Grammar p. 14 Prolog p. 15 Elements p.

Introduction to XML. An Example XML Document. The following is a very simple XML document.

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

Data Presentation and Markup Languages

CSS, Cascading Style Sheets

COMP9321 Web Application Engineering

.. Cal Poly CPE/CSC 366: Database Modeling, Design and Implementation Alexander Dekhtyar..

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

B.V.Patel Institute of Business Management, Computer & Information Technology, UTU

XML & Related Languages

PART. Oracle and the XML Standards

Extensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013

XML Metadata Standards and Topic Maps

Author: Irena Holubová Lecturer: Martin Svoboda

The main Topics in this lecture are:

SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY- VIRUDHUNAGAR

CSC Web Technologies, Spring Web Data Exchange Formats

Web Programming Paper Solution (Chapter wise)

EXtensible Markup Language XML

User Interaction: XML and JSON

COMP9321 Web Application Engineering

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

More XML Schemas, XSLT, Intro to PHP. CS174 Chris Pollett Oct 15, 2007.

W3C XML XML Overview

INTERNET PROGRAMMING XML

XML: Managing with the Java Platform

CountryData Technologies for Data Exchange. Introduction to XML

Well-formed XML Documents

XML. extensible Markup Language. Overview. Overview. Overview XML Components Document Type Definition (DTD) Attributes and Tags An XML schema

extensible Markup Language

User Interaction: XML and JSON

XML 2 APPLICATION. Chapter SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Introduction to XML Zdeněk Žabokrtský, Rudolf Rosa

Chapter 13 XML: Extensible Markup Language

B oth element and attribute declarations can use simple types

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Overview. Introduction. Introduction XML XML. Lecture 16 Introduction to XML. Boriana Koleva Room: C54

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments

Outline. XML vs. HTML and Well Formed vs. Valid. XML Overview. CSC309 Tutorial --XML 4. Edward Xia

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

x ide xml Integrated Development Environment Specifications Document 1 Project Description 2 Specifi fications

Introduction to XML. Chapter 133

Introduction to XML. University of California, Santa Cruz Extension Computer and Information Technology

Introduction to XML. M2 MIA, Grenoble Université. François Faure

Solutions. a. Yes b. No c. Cannot be determined without the DTD. d. Schema. 9. Explain the term extensible. 10. What is an attribute?

Part 2: XML and Data Management Chapter 6: Overview of XML

Computer Science E-75 Building Dynamic Websites

Intro to XML. Borrowed, with author s permission, from:

XML. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior

Introduction to Semistructured Data and XML. Overview. How the Web is Today. Based on slides by Dan Suciu University of Washington

XML. Presented by : Guerreiro João Thanh Truong Cong

Informatique de Gestion 3 èmes Bachelier Groupes 230x

Web Technologies Present and Future of XML

Chapter 2 XML, XML Schema, XSLT, and XPath

Computer Science S-75 Building Dynamic Websites

A tutorial report for SENG Agent Based Software Engineering. Course Instructor: Dr. Behrouz H. Far. XML Tutorial.

Informatics 1: Data & Analysis

Introduction Syntax and Usage XML Databases Java Tutorial XML. November 5, 2008 XML

XML, XPath, and XSLT. Jim Fawcett Software Modeling Copyright

~ Ian Hunneybell: DIA Revision Notes ~

XML Structures. Web Programming. Uta Priss ZELL, Ostfalia University. XML Introduction Syntax: well-formed Semantics: validity Issues

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4.

SDPL : XML Basics 2. SDPL : XML Basics 1. SDPL : XML Basics 4. SDPL : XML Basics 3. SDPL : XML Basics 5

The XQuery Data Model

Web Services Part I. XML Web Services. Instructor: Dr. Wei Ding Fall 2009

Bioinforma)cs Resources XML / Web Access

7.1 Introduction. 7.1 Introduction (continued) - Problem with using SGML: - SGML is a meta-markup language

Transcription:

COMP9321 Web Application Engineering Extensible Markup Language (XML) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442 1

Acknowledgement/Contributions Service Oriented Computing Group, CSE, UNSW Australia Dr. Helen Paik Prof. Boualem Bentallah Dr. Srikumar Venugopal Dr. Moshe Chai Barukh Dr. Amin Beheshti Dr. Basem Suleiman Many others from service oriented computing group COMP9321, 16s1, Week 3 2

Extensible Markup Language (XML) XML is a markup language much like HTML HTML: HTML was designed to display data. HTML tags are not predefined. XML: 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) 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) 5

XML: Tags, tags Consider the following snippet of information from a staff list: 6

Why XML? 7

Why XML? 8

Separating the Content from Presentation HTML was designed to display 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. XML was designed to describe data. 9

Separating the Content from Presentation 10

XML Applications 11

XML Applications 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 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 14

Quick XML syntax 15

The XML Family XML: a markup language used to describe information. 16

The XML Family XML: a markup language used to describe information. Document Object Model (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 XML: a markup language used to describe information. Document Object Model (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

XML Document: Bookstore Example Using xml-formatter, Web Toolkit Online http://www.webtoolkitonline.com/xml-formatter.html 19

XML Tree Structure: Bookstore Example Source: http://www.w3schools.com/xml/xml_tree.asp 20

The XML Family Basics XML documents are formed as element trees XML prolog: XML version and encoding character - <?xml version="1.0" encoding="utf-8"?> An XML tree starts at a root element <bookstore> and branches from the root to child elements (e.g., <book>) All elements can have sub elements (child elements, e.g., <author>) The terms parent, child, and sibling describes the relationships between elements Parent have children. Children have parents. Siblings are children on the same level (brothers and sisters) All elements can have text content (e.g., Everyday Italian) and attributes (e.g., <book category="cooking">) Elements has starting and closing tags (<price> </price>) 21

The XML Family Basics XML tags are case sensitive. <Student> is different from <student> All elements must be properly nested within each other Attribute values must always be quoted - <student id="3230813"> Comments <!-- XML comments --> White spaces are preserved in XML (in contrast to HTML) XML Stores New Line as LF (carriage return and line feed) Entity References Some characters are reserved and have special meaning in XML, e.g., <, >, & Must be escaped using entity references <Age> should be < 25 </Age> Character Entity reference < (less than) < > (greater than) > & (ampersand) & (apostrophe) &apos; " (quotation) " 22

XML Document Type Definition An XML document with correct syntax is called "Well Formed Errors (incorrect syntax) application processing will trigger errors Well Formed XML document it has valid XML syntax rules Well formed XML document valid XML document? A valid XML document must be: Well formed AND Conform to Document Type Definition (DTD) Document Type Definition (DTD) Defines the structure and the legal elements and attributes of an XML document DTD or XML Schema (XML alternative to DTD) Internal DTD declaration or external DTD declaration (.dtd) 23

DTD Parsing In DTD Parsed Character DATA (PCDATA) Text that WILL be parsed by a parser. - tags inside the text will be treated as markup and entities will be expanded Character Data (CDATA ) Text that will NOT be parsed by a parser tags inside the text will NOT be treated and entities will not be expanded. 24

Phonebook.xml with Internal DTD 25

Phonebook.xml with External DTD. Phonebook.dtd 26

CDATA Section 27

Defining XML Content: Elements 28

Defining XML Content: Modifiers 29

Defining XML Content: Choices, Empty 30

Defining XML Content: Mixed content, Any 31

Defining XML Content: Creating Attributes 32

Defining XML Content: Creating Attributes 33

XML Custom Entities 34

Parameter Entities 35

Well-formedness and Validity of XML 36

Limitations of DTD 37

The XML Family XML Schema XML Schema (or SML Schema Definition XSD) 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). 38

XML Schema (orxsd) The XML Family 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 themselves 39

XML Namespaces 40

XML Namespaces (example) 41

XML Namespaces 42

Previous examples can now be... 43

XML Namespace Syntax 44

XML Schema Definition (XSD) a recommendation of the World Wide Web Consortium (W3C) specifies how to formally describe the elements in an Extensible Markup Language (XML) document. 45

Simple Types 46

Attributes <attribute name= attribute-name" type= attribute-type use= uu /> Built-in data types String, decimal, integer, boolean, date, time A default value is automatically assigned to the attribute when no other value is specified A fixed value is also automatically assigned to the attribute, and you cannot specify another value Attributes are optional by default, otherwise use="required" 47

Type Restrictions More examples : http://www.w3schools.com/xml/schema_facets.asp 48

Constraint enumeration Description Type Restrictions Defines a list of acceptable values fractiondigits Specifies the maxi number of decimal places allowed. Must be equal to or greater than zero length Specifies the exact number of characters or list items allowed. Must be >= than zero maxexclusive Specifies the upper bounds for numeric values (the value must be less than this value) maxinclusive Specifies the upper bounds for numeric values (the value must be <= to this value) maxlength Specifies the Max number of characters or list items allowed. Must be >= zero minexclusive Specifies the lower bounds for numeric values (the value must be greater than this value) mininclusive Specifies the lower bounds for numeric values (the value must be>= to this value) minlength Specifies the minimum number of characters or list items allowed. Must be >= 0 pattern totaldigits whitespace Defines the exact sequence of characters that are acceptable Specifies the exact number of digits allowed. Must be greater than zero Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled More examples : http://www.w3schools.com/xml/schema_facets.asp 49

Complex Types 50

Complex Types 51

XML Example - Creating XSD Shiporder.xml Shiporder.xsd Source: http://www.w3schools.com/xml/schema_example.asp 52

The XML Family XSL and XSLT 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. 53

The XML Family 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 54

The XML Family - XPath 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 55

The XML Family XPath Examples <?xml version="1.0".> XML: a markup language used to describe information. <comp9321_students> DOM: a programming interface for accessing and updating documents. <student> /comp9321_student/student[1] DTD <id>50001</id> and XML Schema: describes the Selects structure the first and student content element of XML that documents. is the child XSLT: <name>adam a language B.</name> for transforming XML of the documents comp9321_student element XPath: <program>8543</program> XPath <stage>1</stage> (XML Path language) is a language /comp9321_student/student[last()] for finding information in an XML </student> document. Selects the last student element that is the child of the comp9321_student element <student> XPath contains a library of standard functions XPath <id>50002</id> is a major element in XSLT /comp9321_student/student[position()<3] XPath <name>alex is also C.</name> used in XQuery, XPointer Selects the and first XLink two student element that is the <program>3978</program> XPath is a W3C recommendation child of the comp9321_student element <stage>3</stage> </student> </comp9321_students> some XPath expressions: /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. 56

The XML Family 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. 57

An XML document is a tree... 58

Attributes in XML tags 59

Attributes in XML tags 60

Parsing XML documents with Java 61

Parsing XML documents with Java 62

SAX and DOM as the Standard Interfaces 63

Document Object Model (DOM) 64

Dealing with Nodes in DOM 65

An example XML here... 66

DOM for XML 67

Using a DOM Parser (eg., Apache Xerces) 68

Document Interface Methods 69

Examples of Node Properties (XML), p.9.25 70

Count/Print the number of 'book' elements 71

Dealing with Nodes in DOM Node interface documentationhttps://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/node.html 72

Dealing with Nodes 73

The Element interface Element Interface documentation full list of methods and operations https://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/element.html 74

More with DOM... 75

References 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 76

77