XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://www.zvon.org/index.php?nav_id=tutorials&mi.

Slides:



Advertisements
Similar presentations
Defining XML The Document Type Definition. Document Type Definition text syntax for defining –elements of XML –attributes (and possibly default values)
Advertisements

History Leading to XHTML
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
Introduction to XML: DTD
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
1 XML: Document Type Definitions 2 Road Map  Introduction to DTDs  What’s a DTD?  Why are they important?  What will we cover?  Our First DTD 
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
1 XML and QUERY Shilpi Ahuja CSE Data Mining 4 th April 2002.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Introduction to XML This material is based heavily on the tutorial by the same name at
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
4/20/2017.
Tutorial 3: XML Creating a Valid XML Document. 2 Creating a Valid Document You validate documents to make certain necessary elements are never omitted.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
XML – Extensible Markup Language Sivakumar Kuttuva & Janusz Zalewski.
Validating DOCUMENTS with DTDs
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Document Type Definition.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 XML Taken from Chapter 7.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
©Silberschatz, Korth and Sudarshan10.1Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium (W3C) Originally.
XML By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Chapter 10: XML.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML Syntax - Writing XML and Designing DTD's
XMLI Structure of XML Data Structure of XML Data XML Document Schema XML Document Schema XPATH XPATH.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
FIGIS’ML Hands-on training - © FAO/FIGIS An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 6 – Document Type Definition (DTD) Outline 6.1Introduction 6.2Parsers, Well-formed and Valid XML.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
Chapter 23 XML. 2 Introduction  XML: eXtensible Markup Language (What is a Markup language?)  Defined by the WWW Consortium (W3C)  Originally intended.
Tutorial 13 Validating Documents with Schemas
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
ADT 2010 Introduction to XML, XPath (& XQuery) Chapter 10 in Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Document Type Definition (DTD) Eugenia Fernandez IUPUI.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
Extensible Markup Language (XML) Pat Morin COMP 2405.
CS 480: Database Systems Lecture 26 March 18, 2013.
XML QUESTIONS AND ANSWERS
XML and Databases.
New Perspectives on XML
Presentation transcript:

XML

2 XML- Some Links XML Tutorials – Some Links me=htmlhttp:// me=html

Introduction XML: Extensible Markup Language Defined by the WWW Consortium (W3C) Originally intended as a document markup language but not a database language –Derived from SGML (Standard Generalized Markup Language), but simpler to use than SGML –Extensible, unlike HTML Users can add new tags, and separately specify how the tag should be handled for display

4 XML: Application Areas XML can be effectively used in the following areas: Use XML to describe meta-content regarding documents or on-line resources. –Meta-content is information about a document’s content – title, author, file size, creation date, keywords and so on. –Meta-content can be used for example, for searching, information filtering and document management. –A meta-content description that is external to a file (and not inside an HTML file), improves search performance.

5 XML: Application Areas Use XML to publish and exchange database contents –Many applications extract data from backend database systems, transform the results using the tag of HTML and display it on the screen. –If data is delivered as an XML document that preserves the original information, such as column names and data types, the information can be used by the client for purposes other than displaying it on the screen.

6 XML: Application Areas Use XML as a messaging format for communication between application programs. –Messaging is an exchange of messages between organizations or between application systems within an organization. – Traditionally, messaging among companies has traditionally been done by Electronic Data Exchange (EDI). But many small companies cannot participate in EDI because of the cost of building and operating an EDI system. The other problem is agreeing on a standard message format to use. Among the skills needed to build an EDI system is a good understanding of the X12 or EDIFACT message format. –It is easier to learn XML syntax for messaging.

7 Data interchange is critical in today’s networked world –Examples: Banking: funds transfer Order processing (especially inter-company orders) Scientific data –Chemistry: ChemML, … –Genetics: BSML (Bio-Sequence Markup Language), … –Paper flow of information between organizations is being replaced by electronic flow of information Each application area has its own set of standards for representing information XML has become the basis for all new generation data interchange formats

8 Why Use XML? Simplicity –XML’s character-based format is simpler and human- readable than binary formats. –XML messages can be easily created, read and modified using common text editors. –XML’s ability to represent tree-structured data Richness Of Data structures –Can express complex data structures using a rooted tree structure. For many applications, a tree structure is general and powerful enough to express fairly complex data. International Character Handling –XML’s ability to handle international character set is especially handy for Web applications and business transactions that may cross national boundaries. –XML 1.0 Recommendation is defined based on the ISO (Unicode) character set.

XML The ability to specify new tags, and to create nested tag structures made XML a great way to exchange data, not just documents. –Much of the use of XML has been in data exchange applications, not as a replacement for HTML

10 Example Tags make data (relatively) self-documenting Example: Cosmos Carl Sagan War And Peace Leo Tolstoy

11 Structure Of an XML Document Tag: label for a section of data Element: section of data beginning with and ending with matching Elements must be properly nested –Proper nesting … …. –Improper nesting … …. –Formally: every start tag must have a unique matching end tag, that is in the context of the same parent element. Every document must have a single top-level element

12 Nesting Of Data Nesting of data is useful in data transfer –Example: elements representing customer-id, customer name, and address nested within an order element Nesting is not supported, or discouraged, in relational databases –With multiple orders, customer name and address are stored redundantly –normalization replaces nested structures in each order by foreign key into table storing customer name and address information –Nesting is supported in object-relational databases But nesting is appropriate when transferring data –External application does not have direct access to data referenced by a foreign key

13 XML For Text and XML For Data XML For Text (Document-centric): is used for marking up documents. The order of the information in the text is important to understand its meaning – Cannot reorder the segments of text. XML For Data (Data-centric): Data can be represented in a number of different ways and still have the same meaning.

14 Creating XML Documents Structure Of XML Documents Well-Formed XML Documents –Obey the rules defined in the XML standard. –XML elements must have a closing tag –If there is no element content (usually is the case when the element has an attribute) an abbreviation can be used. – –Items must nest completely (cannot be partially nested) –XML Documents can have only one root element.

15 Creating XML Documents Structure Of XML Documents Valid XML Documents: A valid XML document obeys the rules defined in the Document Type Definition (DTD). The structure of an XML document can be pre- defined with a DTD. An application can then compare the definition of a DTD with an actual XML document and check whether the document conforms to the rules defined in the DTD. If so, it is a valid XML document.

16 An XML-based System XML Document XML DTD XML Processor XML Application

17 Some XML Processors msxml XP nsgmls saxon Well-formed XML Documents: –An XML processor can build a tree structure. Valid XML Documents –Obey the rules specified in the DTD –msxml parser is a validating processor.

18 XML Document Type Definitions (DTD) A DTD defines the structure of an XML document. The type of an XML document can be specified using a DTD DTD constrains structure of XML data –What elements can occur –What attributes can/must an element have –What sub-elements can/must occur inside each element, and how many times. DTD does not constrain data types –All values represented as strings in XML

19 XML Document Type Definitions (DTD) A DTD defines the structure of an XML document. Internal DTD: A DTD can be placed inside an XML document, with a declaration shown below: External DTD: A DTD can be stored in an external file and the location of the file is given in the declaration:

20 Anatomy Of an XML Document And Its Definition in DTD Structuring Elements: Elements are the items that make up the structure of the document. Elements can contain either data content or a mixture of data content and other elements.

21 Element-only Content: Elements may only contain other elements. This is the way elements are nested within one another. Example: A DTD entry: An XML entry: A plus (+) means an element can occur one or more times

22 Mixed Content: Elements may contain zero or more instances of a list of elements, along with any amount of text in any position. Example: A DTD entry: An XML entry: This is a Book Order For Mary Jones A plus (*) means an element can occur zero or more times A vertical bar (|) is used to separate elements in a list where any one of the listed elements can appear.

23 Text-OnlyContent: Elements may contain text strings. Example: A DTD entry: An XML entry: Mary Jones #PCData (parsed character data) indicates that element’ contents contain text characters and cannot contain any characters that are part of the mark up, such as delimiter, &.

24 Empty Content: Elements cannot contain anything at all. Any data can be expressed as attributes. Example: A DTD entry: An XML entry:

25 ANY Content: Elements may contain any type of content - element or text. Example: A DTD entry: Two XML entries: Mary Jones Or Mary Jones

26 Attributes Elements can have attributes. This is another way of representing data points is to use attributes attached to elements. An element can be broken down into smaller chunks of data (Example: name into firstName and lastName) and the data is attached to the element itself. Attributes are specified by name=value pairs inside the starting tag of an element An element may have several attributes, but each attribute name can only occur once. Example:

27 Using Attributes Attributes represent information about an element (meta information) and different from the content. Attributes are often used with empty elements Suggestion: use attributes for identifiers of elements, and use elements for contents Note: More discussion on elements and attributes later.

28 Attributes Attribute specification : for each attribute –Name –Type of attribute CDATA ID (identifier) or IDREF (ID reference) or IDREFS (multiple IDREFs)

29 Attributes An element can have at most one attribute of type ID The ID attribute value of each element in an XML document must be distinct –Thus the ID attribute value is an object identifier An attribute of type IDREF must contain the ID value of an element in the same document An attribute of type IDREFS contains a set of (0 or more) ID values. Each ID value must contain the ID value of an element in the same document

30 Using Attributes Example: A DTD entry: <!ATTLIST Customer element name in which the attributes appear FirstName CDATA #REQUIRED the attribute must contain some value LastNameCDATA #REQUIRED> An XML entry: <Customer FirstName=“Mary” LastName=“Jones” />

31 Using Attributes CDATA section contains content that is treated as plain text. No parsing actions are performed on the content and can also contain the special characters that are not permitted in #PCDATA. #REQUIRED: Attribute must appear in the element. #FIXED “default”: Attribute value is a constant and must appear as such in an XML document. #IMPLIED: If the attribute does not appear in the element, then an application using the XML document may supply any value.

32 Elements vs Attributes Representing BookOrder using Elements BookOrder1.dtd

33 BookOrders.xml based on BookOrder1.dtd Mary Jones San Jose

34 Elements Vs Attributes BookOrder2.dtd using attributes <!ATTLIST BookOrder CustomerFirstName CDATA #REQUIRED CustomerLastName CDATA #REQUIRED CustomerCity CDATA #REQUIRED CustomerZip CDATA #REQUIRED > <!ATTLIST OrderLineItem itemNo CDATA #REQUIRED quantity CDATA #REQUIRED priceCDATA #REQUIRED >

35 BookOrders.xml based on BookOrder2.dtd <BookOrder CustomerFirstName=“Mary” CustomerLastName=“Jones” CustomerCity=“San Jose” CustomerZip=“95053” > <OrderLineItem itemNo=“1234” quantity=”10” price=“100.00”/> itemNo=“1444” quantity=”5” price=“50.00”/>

36 Limitations of DTDs No typing of text elements and attributes –All values are strings, no integers, reals, etc. Difficult to specify unordered sets of subelements –Order is usually irrelevant in databases –(A | B)* allows specification of an unordered set, but Cannot ensure that each of A and B occurs only once IDs and IDREFs are untyped –The owners attribute of an account may contain a reference to another account, which is meaningless owners attribute should ideally be constrained to refer to customer elements