Underlying Technologies XML Is the Glue Program the Web XML Browse the Web HTML T C P/IP Connect the Web Technology Innovation ConnectivityPresentation.

Slides:



Advertisements
Similar presentations
An Introduction to XML Based on the W3C XML Recommendations.
Advertisements

XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
1 XML DTD & XML Schema Monica Farrow G30
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
Document Type Definitions
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
1 Week5 – Schema Why Schema? Schemas vs. DTDs Introduction – W3C vs. Microsoft XDR Schema, How To? Element Types – Simple vs. Complex Attributes Restrictions/Facets.
Tutorial 11 Creating XML Document
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Introduction to XML This material is based heavily on the tutorial by the same name at
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
Validating DOCUMENTS with DTDs
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.
WPF chapter 15 Dr. John Abraham Professor UTPA. WPF –an introduction WPF provides a single platform capable of handling graphics, audio and video. WPF.
E X TENSIBLE M ARKUP L ANGUAGE (XML). What is XML?  XML stands for EXtensible Markup Language  XML is mainly designed to carry (or transmit) data, not.
XML Schema Vinod Kumar Kayartaya. What is XML Schema?  XML Schema is an XML based alternative to DTD  An XML schema describes the structure of an XML.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Li Tak Sing COMPS311F. XML Schemas XML Schema is a more powerful alternative to DTD to describe XML document structures. The XML Schema language is also.
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.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
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.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
1 Dr Alexiei Dingli XML Technologies X-Schema. 2 XML-based alternative to DTD Describes the structure of an XML document Also referred to as XML Schema.
XML. 2 Microsoft The Extensible Markup Language (XML) is a general-purpose markup language. markup language It is classified as an extensible language.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
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.
How do I use HTML and XML to present information?.
XML eXtensible Markup Language. Topics  What is XML  An XML example  Why is XML important  XML introduction  XML applications  XML support CSEB.
XML Extensible Markup Language
E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language  XML is a markup language for creating documents containing structured information.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
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
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… XML Syntax v2.0.
Chapter 15: XML TP2543 Web Programming Mohammad Faidzul Nasrudin.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Introduction to XML Extensible Markup Language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
XML intro. 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.
Unit 4 Representing Web Data: XML
Chapter 7 Representing Web Data: XML
14 XML.
Presentation transcript:

Underlying Technologies XML Is the Glue Program the Web XML Browse the Web HTML T C P/IP Connect the Web Technology Innovation ConnectivityPresentation Connecting Applications FTP, , Gopher Web Pages Web Services

Introducing XML XML = Extensible Markup Language In information technology, extensible describes something, such as a program, programming language, or protocol, that is designed so that users or developers can expand or add to its capabilities Because XML is extensible, it can be used to create a wide variety of document types. XML enables document authors to create entirely new markup languages for describing specific types of data, including mathematical formulas, chemical molecular structures, music, recipes, etc.

Markup is a text-based notation for describing data Some XML-based markup languages include XHTML,MathML (for mathematics), VoiceXML™ (for speech), SMIL™ (the Synchronous Multimedia Integration Language—for multimedia presentations), CML (Chemical Markup Language—for chemistry) and XBRL (Extensible Business Reporting Language— for financial data exchange

Welcome to XML! 8 Line numbers are not part of XML document. We include them for clarity. Document begins with declaration that specifies XML version 1.0 Element message is child element of root element myMessage

XML documents contain text that represents content (i.e. data) such as welcome to xml !! It contains element that specify the document’s structure, such as mymessage XML documents delimit elements with start tags and end tags Start tag the element name in angle brackets End tag consists of the element name preceded by a forward slash (/)

Every XML document must have exactly one root element that contains all the other elements such as mymessage

VIEWING AND MODIFIFYING XML documents XML documents are highly portable. Viewing or modifying an XML document—which typically ends with the.xml filename extension—does not require special software. Any text editor that supports ASCII/Unicode characters can open XML documents for viewing and editing. One important characteristic of XML is that it is both human readable and machine readable.

Processing XML documents Processing an XML document requires a software program called an XML parser (or an XML processor) Parsers check an XML document’s syntax and enable software programs to process marked-up data XML syntax requires:  a single root element,  a start tag, and an end tag for each element  properly nested tags (i.e. the end tag for a nested element must appear before the end tag of the enclosing element)

 XML is case sensitive. A document that conforms to this syntax is a well- formed XML document and is syntactically correct. Parser is built in IE7 and FF2

Validating XML Documents An XML document optionally can reference a document that defines that XML document’s structure. This document is either a Document Type Definition (DTD) or a schema. When an XML document references a DTD or schema, some parsers (called validating parsers) can read the DTD/schema and check that the XML document follows the structure that the DTD/schema defines. If the XML document conforms to the DTD/schema (i.e., the document has the appropriate structure), the XML document is valid.

Parsers that cannot check for document conformity against DTDs/schemas are non-validating parsers. If an XML parser (validating or non-validating) can process an XML document successfully, that XML document is well formed (i.e., it is syntactically correct). By definition, a valid XML document also is well-formed.

Elements title, date, author, summary and content are child elements of article Simple XML 9 10 September 19, Tem 14 Nieto XML is pretty easy Once you have mastered XHTML, XML is easily 20 learned. You must remember that XML is not for 21 displaying information but for managing information Optional XML declaration. Element article is the root element.

We begin with the optional XML declaration on line 1. Value version indicates the XML version to which the document conforms. The current XML standard is version 1.0. Blank lines (line 2), white spaces and indentation help improve readability Comments (lines 3-4) begin with, can be placed anywhere Placing any characters including white spaces before the XML declaration is an error Line2(1-4) is the XML prolog lines(6-24) are the root element XML element and attribute names can be of any length and may contain letters, digits, underscores, hyphens and periods. However, XML names must begin with either a letter or an underscore.

Using either a space or a tab in an XML element or attribute name is an error using xml in any combination of uppercase or lower case letter at the beginning is error Parent(container)/ child relationship (all children at the same nesting level are siblings)

Viewing an xml Document Note that the XML document is simply a text file does not contain formatting information for the article. This is because XML is a technology only for structuring data. Formatting and displaying data from an XML document are application specific issues. For example, when Internet Explorer 7 loads an XML document, IE7’s parser msxml (Microsoft XML Core Services) parses and displays the document data.the firefox has a similar capability. Each browser has a built-in style sheet to format the data

Notice the minus sign (–) and plus sign (+). IE7 places these symbols next to all container elements. A minus sign indicates that IE7 is displaying that container element’s child elements. Clicking the minus sign next to an element causes IE7 to hide that container element’s children and replaces the minus sign with a plus sign. Clicking the plus sign next to an element causes IE7 to display that container element’s children and replaces the plus sign with a minus sign. The same can be found in FF2

Document Type Definitions A DTD enables an XML parser to verify whether an XML document is valid (i.e., its elements contain the proper attributes, are in the proper sequence, etc.)..

XML Markup for a Business letter Jane Doe Box Any Ave. Othertown Otherstate This xml document references a DTD

John Doe 123 Main St. Anytown Anystate

Dear Sir: It is our privilege to inform you about our new database managed with XML. This new system allows you to reduce the load on your inventory list server by having the client machine perform the work of sorting and filtering the data. Please visit our website for availability and pricing. Sincerely, Ms. Jane Doe

: root element line(7-43) Root element letter contains child elements contact, salutation, paragraph, closing and signature.. Element with attribute ( type = ) (“sender”) Notes 1.Case sensitive 2.“ “ not ‘ ‘ 3. Attribute name Attribute value

Jane Doe Element with data between element’s tags

letter.dtd

To reference the DTD file we use : referenceRoot nameExternal file Name & location We have : ELEMENTEMPTY ATTLIST#RQUIRED CDATA#FIXED #IMPLIED#PCDATA

ELEMENT element type declaration defines the rules for element letter. In this case, letter contains one or more contact elements, one salutation element, one or more paragraph elements, one closing element and one signature element, in that sequence. The plus sign (+) occurrence indicator specifies that the DTD allows one or more occurrences of an element. asterisk (*), which indicates an optional element that can occur any number of times (zero or more) the question mark (?), which indicates an optional element that can occur at most once (zero or one occurrence)

If an element does not have an occurrence indicator, the DTD allows exactly one occurrence. The contact element definition (line 7) specifies that element contact contains child elements name, address1, address2, city, state, zip, phone and flag— in that order. The DTD requires exactly one occurrence of each element.

ATTLIST element type declaration to define an attribute (i.e., type) for the contact element. KEYWORD #IMPLIED specifies that if the parser finds a contact element without a type attribute, the parser can choose an arbitrary value for the attribute or ignore the attribute and the document will be valid.

KEYWORD #REQUIRED specifies that the attribute must be present in the element, and keyword KEYWORD #FIXED specifies that the attribute (if present) must have the given fixed value. For example, indicates that attribute zip must have the value for the document to be valid KEYWORD# DEFAULTThe attribute has a default value

CDATA CDATA specifies that attribute type contains character data (i.e.,a string) which indicates that the parser will not process the data, but will pass the data to the application without modification. #PCDATA specifies that the element can contain parsed character data (i.e., text). Parsable character data should not contain markup characters, such as less than ( ) and ampersand (&). The document author should replace any markup character with its corresponding entity (i.e., <, > or &). Appendix A contains special character

Entity ReferencesCharacter << >> && "" &apos;' Apos to denote the apostrophe

KEYWORD EMPTY specifies that the element does not contain any data. Attributes commonly contain data that the empty element describes FOR EXAMPLE the gender attribute value must be one of the enumerated values (M or F) and the default value is M

Wrapping If the DTD is to be included in your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax: example: <!DOCTYPE note [ ]>

Tove Jani Reminder Don't forget me this weekend

This XML document has a reference to a DTD: Tove Jani Reminder Don't forget me this weekend! A Reference to a DTD

A DTD File

XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD). An XML SCHEMA

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. An XML Schema: defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements defines the order of child elements What is an XML Schema?

defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes

We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces XML Schemas are much more powerful than DTDs. XML Schemas are the Successors of DTDs

Tove Jani Reminder Don't forget me this weekend! A Simple XML Document

An XML Schema

Tove Jani Reminder Don't forget me this weekend! A Reference to an XML Schema

The element is the root element of every XML Schema: The Element

The element may contain some attributes. A schema declaration often looks something like this:......

xmlns:xs= indicates that the elements and data types used in the schema come from the " namespace. It also specifies that the elements and data types that come from the " namespace should be prefixed with xs:

targetNamespace= indicates that the elements defined by this schema (note, to, from, heading, body.) come from the " namespace.

xmlns= indicates that the default namespace is " elementFormDefault="qualified“ indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified.

Referencing a Schema in an XML Document <note xmlns= specifies the default namespace declaration. This declaration tells the schema-validator that all the elements used in this XML document are declared in the " namespace.

xmlns:xsi= Another very important way in which namespaces are used in conjunction with XML Schema is through the XML Instance namespace. There are a number of elements described by the XML Schema: Structures recommendation which are designed to link with a Schema to a specific XML instance document. Those elements have actually been given their own namespace: The XML Instance namespace is a very important one, even though it does not contain many elements. It is so important because it is how you associate an XML Schema with a document. xsi

Once you have the XML Schema Instance namespace available: You can use attributes defined in the XML Schema: xsi:schemaLocation xsi:noNamespaceSchemaLocation

xsi:schemaLocation The XML instance schemaLocation attribute is used to specify the location of an XML Schema associated with an XML document. The attribute value is a pair of URIs, the first of which is the targetNamespace for the XML Schema, and the second is the URI that points to the location of the Schema. xsi:schemaLocation=" note.xsd"> Example

noNamespaceSchemaLocation attribute is very similar to the schemaLocation attribute, in that it allows you to specify the location of a Schema for use with your document. However, since a Schema is not required to have a targetNamespace, this attribute can be used for Schema that do not have a namespace xsi:noNamespaceSchemaLocation

This is family.xsd file in the same folder with xml file … Xml file : Example Root element

This is note.xsd file in the same folder with xml file: Example

Xml file Root element Target name space

Hello From XML This is an XML document! We can use also UTF-16 or ISO Character Encodings:

The structures that make up an XML Schema are called components, and every XML Schema is essentially a set of components which outline the constraints placed on the content of an XML document. Documents which contain XML elements and attributes are XML instance documents, and Schema can constrain those instances The Components of XML Schema

A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes. However, the "only text" restriction is quite misleading. The text can be of many different types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc.), or it can be a custom type that you can define yourself. You can also add restrictions (facets) to a data type in order to limit its content, or you can require the data to match a specific pattern. A Simple Element

The syntax for defining a simple element is: where xxx is the name of the element and yyy is the data type of the element. XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time Defining a Simple Element

Here are some XML elements : Refsnes And here are the corresponding simple element definitions: Example

Simple elements may have a default value OR a fixed value specified. A default value is automatically assigned to the element when no other value is specified. In the following example the default value is "red": A fixed value is also automatically assigned to the element, and you cannot specify another value. In the following example the fixed value is "red": Default and Fixed Values for Simple Elements

What is an Attribute? Simple elements cannot have attributes. If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type. The syntax for defining an attribute is: where xxx is the name of the attribute and yyy specifies the data type of the attribute. XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time An Attribute

Here is an XML element with an attribute: Smith And here is the corresponding attribute definition: Example

Attributes may have a default value OR a fixed value specified. A default value is automatically assigned to the attribute when no other value is specified. In the following example the default value is "EN": A fixed value is also automatically assigned to the attribute, and you cannot specify another value. In the following example the fixed value is "EN": Default and Fixed Values for Attributes

Attributes are optional by default. To specify that the attribute is required, use the "use" attribute: Optional and Required Attributes

When an XML element or attribute has a data type defined, it puts restrictions on the element's or attribute's content. If an XML element is of type "xs:date" and contains a string like "Hello World", the element will not validate. With XML Schemas, you can also add your own restrictions to your XML elements and attributes. These restrictions are called facets Restrictions on Content

The following example defines an element called "age" with a restriction. The value of age cannot be lower than 0 or greater than 120: Restrictions on Values

To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint. The example below defines an element called "car" with a restriction. The only acceptable values are: Audi, Golf, BMW: Restrictions on a Set of Values

The example above could also have been written like this: Note: In this case the type "carType" can be used by other elements because it is not a part of the "car" element.

To limit the content of an XML element to define a series of numbers or letters that can be used, we would use the pattern constraint. The example below defines an element called "letter" with a restriction. The only acceptable value is ONE of the LOWERCASE letters from a to z: Restrictions on a Series of Values

The next example defines an element called "initials" with a restriction. The only acceptable value is THREE of the UPPERCASE letters from a to z:

The next example also defines an element called "initials" with a restriction. The only acceptable value is THREE of the LOWERCASE OR UPPERCASE letters from a to z:

The next example defines an element called "choice" with a restriction. The only acceptable value is ONE of the following letters: x, y, OR z:

The next example defines an element called "prodid" with a restriction. The only acceptable value is FIVE digits in a sequence, and each digit must be in a range from 0 to 9:

The example below defines an element called "letter" with a restriction. The acceptable value is zero or more occurrences of lowercase letters from a to z:

The next example defines an element called "gender" with a restriction. The only acceptable value is male OR female:

The next example defines an element called "password" with a restriction. There must be exactly eight characters in a row and those characters must be lowercase or uppercase letters from a to z, or a number from 0 to 9:

The next example also defines an element called "letter" with a restriction. The acceptable value is one or more pairs of letters, each pair consisting of a lower case letter followed by an upper case letter. For example, "sToP" will be validated by this pattern, but not "Stop" or "STOP" or "stop":

To specify how whitespace characters should be handled, we would use the whiteSpace constraint. This example defines an element called "address" with a restriction. The whiteSpace constraint is set to "preserve", which means that the XML processor WILL NOT remove any white space characters: Restrictions on Whitespace Characters

This example also defines an element called "address" with a restriction. The whiteSpace constraint is set to "replace", which means that the XML processor WILL REPLACE all white space characters (line feeds, tabs, spaces, and carriage returns) with spaces:

This example also defines an element called "address" with a restriction. The whiteSpace constraint is set to "collapse", which means that the XML processor WILL REMOVE all white space characters (line feeds, tabs, spaces, carriage returns) are replaced with spaces, leading and trailing spaces are removed, and multiple spaces are reduced to a single space):

To limit the length of a value in an element, we would use the length, maxLength, and minLength constraints. This example defines an element called "password" with a restriction. The value must be exactly eight characters: Restrictions on Length

This example defines another element called "password" with a restriction. The value must be minimum five characters and maximum eight characters:

Data types Page (537)

ConstraintDescription enumerationDefines a list of acceptable values fractionDigitsSpecifies the maximum 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 equal to or greater than zero maxExclusiveSpecifies the upper bounds for numeric values (the value must be less than this value) maxInclusiveSpecifies the upper bounds for numeric values (the value must be less than or equal to this value) maxLengthSpecifies the maximum number of characters or list items allowed. Must be equal to or greater than zero Restrictions for Data types

minExclusiveSpecifies the lower bounds for numeric values (the value must be greater than this value) minInclusiveSpecifies the lower bounds for numeric values (the value must be greater than or equal to this value) minLengthSpecifies the minimum number of characters or list items allowed. Must be equal to or greater than zero patternDefines the exact sequence of characters that are acceptable totalDigitsSpecifies the exact number of digits allowed. Must be greater than zero whiteSpaceSpecifies how white space (line feeds, tabs, spaces, and carriage returns) is handled Restrictions for Data types(cont.)

1.Create a definition in XML SCHEMA for: the company_id simple type element which must be all digits and must be exactly 6 digits long. Paperback Identify and correct the error(s) in each of the following: a) This is my custom markup b) c) The next part of code defines an element called “myname" with a restriction. The acceptable value is one or more pairs of letters, each pair consisting of an upper case letter followed by an lower case letter.

3. In No.(2) part (c) Which of the following will be validated by this pattern: AsLaMa aSLaMA ASLAma aslaMa