COS 381 Day 17. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML: Extensible Markup Language
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
Chapter 10 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 10 Sebesta: Programming the World Wide Web.
COS 381 Day 15. Agenda Assignment 3 Corrected 3 A’s, 1 B, 1 C and 2 D’s Assignment 4 posted Due March 28 Those that wanted to resubmit Assignment 2 must.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
COS 381 Day 16. Agenda Assignment 4 posted Due April 1 There was no resubmits of Assignment Capstone Progress report Due March 24 Today we will discuss.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Copyright © 2002 ProsoftTraining. All rights reserved. XML Document Design.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Chapter 8 Introduction to XML. © 2006 Pearson Addison-Wesley. All rights reserved Introduction - SGML is a meta-markup language - Developed in.
Chapter 7 © 2013 by Pearson Introduction - SGML is a meta-markup language - HTML was developed using SGML in the early 1990s - specifically for.
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.
Chapter 8 © 2003 by Addison-Wesley, Inc. 1 Chapter 8 Introduction to XML.
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.
Chapter 7 © 2010 by Addison Wesley Longman, Inc Introduction - SGML is a meta-markup language - Developed in the early 1980s; ISO std. In
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.
Dr. Azeddine Chikh IS446: Internet Software Development.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
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.
WORKING WITH XSLT AND XPATH
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
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.
Session IV Chapter 9 – XML Schemas
1 Introduction to Web Application Introduction to XML.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Dr. Ahmet Cengizhan Dirican BIL 374 Internet Technologies 7. XML.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter X IXXXXXXXXXX XXXXXX.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
New Perspectives on XML, 2nd Edition
Chapter 7 © 2014 by Pearson Education Introduction - SGML is a meta-markup language - Developed in the early 1980s; ISO std. In HTML was developed.
Chapter 8 Introduction to XML. © 2006 Pearson Addison-Wesley. All rights reserved Introduction - SGML is a meta-markup language - Developed in.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
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
EXtensible Markup Language (XML). Definition XML is a cross-platform, software and hardware independent tool for transmitting information. “XMl is going.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
CS3101: Internet Programming Chapter 06: XML and RSS.
Martin Kruliš by Martin Kruliš (v1.1)1.
Dr. Ahmet Cengizhan Dirican BIL 374 Internet Technologies 7. XML.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
Chapter 8 Introduction to XML.
Unit 4 Representing Web Data: XML
XML QUESTIONS AND ANSWERS
XSLT 1.0.
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
CHAPTER 5 EXTENSIBLE MARKUP LANGUAGE (XML)
Chapter 7 Representing Web Data: XML
Chapter X IXXXXXXXXXXXXXXXX.
7.1 Introduction - SGML is a meta-markup language
More XML XML schema, XPATH, XSLT
New Perspectives on XML
Presentation transcript:

COS 381 Day 17

Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard Html and XHTML examples In Class Work Assignment 3 Not corrected Assignment 4 is posted Due April 4 Quiz 2 is not corrected One student has yet to take quiz Finish Discussion on XML

XML Schemas - Problems with DTDs: 1. Syntax is different from XML - cannot be parsed with an XML parser 2. It is confusing to deal with two different syntactic forms 3. DTDs do not allow specification of particular kinds of data XML Schemas is one of the alternatives to DTD - Two purposes: 1. Specify the structure of its instance XML documents 2. Specify the data type of every element and attribute of its instance XML documents DTD can be converted to schemas Resource

- Schemas are written using a namespace: Every XML schema has a single root, schema - The schema element must specify the namespace for schemas as its xmlns:xsd attribute - Every XML schema itself defines a tag set, which must be named targetNamespace = For this class “home directory” If we want to include nested elements, we must set the elementFormDefault attribute to qualified - The default namespace must also be specified xmlns = " XML Schemas (continued)

- - A complete example of a schema element: <xsd:schema <xmlns:xsd = " <targetNamespace =" xmlns = " elementFormDefault = "qualified"> XML Schemas (continued)

- - A complete example of a schema element: <schema <xmlns = " <targetNamespace =" xmlns:planes = " elementFormDefault = "qualified"> XML Schemas (continued)

- Defining an instance document - The root element must specify the namespaces it uses 1. The default namespace 2. The standard namespace for instances ( XMLSchema-instance ) 3. The location where the default namespace is defined, using the schemaLocation attribute, which is assigned two values <planes xmlns = " xmlns:xsi = xsi:schemaLocation = " planes.xsd" > Data Type Categories 1. Simple (strings only, no attributes and no nested elements) 2. Complex (can have attributes and nested elements) XML Schemas (continued)

- XMLS defines over 40 data types - Primitive: string, Boolean, float, … - Derived: byte, decimal, positiveInteger, … - User-defined (derived) data types – specify constraints on an existing type (the base type) - Constraints are given in terms of facets ( totalDigits, maxInclusive, etc.) - Both simple and complex types can be either named or anonymous - DTDs define global elements (context is irrelevant) - With XMLS, context is essential, and elementscan be either: 1. Local, which appears inside an element that is a child of schema, or 2. Global, which appears as a child of schema XML Schemas (continued)

- Defining a simple type: - Use the element tag and set the name and type attributes <xsd:element name = "bird" type = "xsd:string" /> - An instance could have: Yellow-bellied sap sucker - Element values can be constant, specified with the fixed attribute fixed = "three-toed" - User-Defined Types - Defined in a simpleType element, using facets specified in the content of a restriction element - Facet values are specified with the value attribute XML Schemas (continued)

- Categories of Complex Types 1. Element-only elements (elements no text) 2. Text-only elements (text no elements) 3. Mixed-content elements (both text and elements 4. Empty elements - Element-only elements - Defined with the complexType element - Use the sequence tag for nested elements that must be in a particular order - Use the all tag if the order is not important XML Schemas (continued)

- Nested elements can include attributes that give the allowed number of occurrences ( minOccurs, maxOccurs, unbounded ) - We can define nested elements elsewhere XML Schemas (continued)

- The global element can be referenced in the complex type with the ref attribute - Validating Instances of XML Schemas - Can be done with several different tools - One of them is xsv, which is available from: - Note: If the schema is incorrect (bad format), xsv reports that it can find the schema planes.xsd Plane.xml XML Schemas (continued)

Modified Plane example from text <!-- plane.xml A simple XML document for illustrating a schema The schema is in planes.xsd --> <plane xmlns = " xmlns:xsi = " xsi:schemaLocation = " planes.xsd"> Cessna Piper Beechcraft

Con’t <!-- planes.xsd A simple schema for plane.xml --> <xsd:schema xmlns:xsd = " targetNamespace = " xmlns = " elementFormDefault = "qualified"> <xsd:element name = "make" type = "xsd:string" minOccurs = "1" maxOccurs = "unbounded" />

Validating Instances of Schemas Various systems for validating instances against schemas Online XML support libraries include validation: Xerces from Apache, Saxon, Altova XML tools Some IDE’s have automatic validation: Altova Spy, Eclipse with Oxygen, Eclipse with XML Buddy Pro Certain IDE’s will use schemas to provide support for XML file creation

Displaying Raw XML Documents - There is no presentation information in an XML document - An XML browser should have a default style sheet for an XML document that does not specify one - You get a stylized listing of the XML

- A CSS style sheet for an XML document is just a list of its tags and associated styles - The connection of an XML document and its style sheet is made through an xml-stylesheet processing instruction <?xml-stylesheet type = "text/css" href = "mydoc.css"?> --> SHOW planescss.xml and planes.css planescss.xmlplanes.css Displaying XML Documents with CSS

7.9 Overview of XSLT A functional style programming language Basic syntax is XML There is some similarity to LISP and Scheme An XSLT processor takes an XML document as input and produces output based on the specifications of an XSLT document

8.9 XSLT Style Sheets Resources An XSLT processor merges an XML document into an XSLT style sheet - This merging is a template-driven process - An XSLT style sheet can specify page layout, page orientation, writing direction, margins, page numbering, etc.

7.9 XSLT Style Sheets A family of specifications for transforming XML documents XSLT: specifies how to transform documents XPath: specifies how to select parts of a document and compute values XSL-FO: specifies a target XML language describing the printed page XSLT describes how to transform XML documents into other XML documents such as XHTML XSLT can be used to transform to non-XML documents as well

Figure 7.5 XSLT processing

7.9 XSLT Structure An XSLT document contains templates XPath is used to specify patterns of elements to which the templates should apply The content of a template specifies how the matched element should be processed The XSLT processor will look for parts of the input document that match a template and apply the content of the template when a match is found Two models Template-driven works with highly regular data Data-driven works with more loosely structured data with a recursive structure (like XHTML documents)

- The processing instruction we used for connecting a CSS style sheet to an XML document is used to connect an XSLT style sheet to an XML document - An example: <?xml-stylesheet type = "text/xsl" href = "xslplane.xsl" ?> 1977 Cessna Skyhawk Light blue and white XSLT Style Sheets (continued)

- An XSLT style sheet is an XML document with a single element, stylesheet, which defines namespaces <xsl:stylesheet xmlns:xsl = xmlns = “ - If a style sheet matches the root element of the XML document, it is matched with the template: - A template can match any element, just by naming it (in place of / ) - XSLT elements include two different kinds of elements, those with content and those for which the content will be merged from the XML doc - Elements with content often represent xHTML elements Happy Easter! XSLT Style Sheets (continued)

- XSLT elements that represent xHTML elements are simply copied to the merged document - The XSLT value-of element - Has no content - Uses a select attribute to specify part of the XML data to be merged into the XSLT document - The value of select can be any branch of the document tree  SHOW xslplane.xml xslplane.xslxslplane.xml xslplane.xsl - The XSLT for-each element - Used when an XML document has a sequence of the same elements --> SHOW xslplanes.xml xslplanes.xml --> SHOW xslplanes.xsl xslplanes.xsl XML Transformations and Style Sheets (continued)

7.9 Producing Transformation Output Elements not belonging to XSLT and other text will be copied to the output when the containing template is applied The value-of tag causes the select attribute value to be evaluated and the result is put into the output The value of an element is the text contained in it and in sub- elements The value of an attribute is the value Example xslplane1.xsl transforms the xslplane.xml file into XHTML for display purposesxslplane1.xsl xslplane.xml If the style sheet is in the same directory as the XML file, some browsers will pick up the transformation and apply it This works with Firefox and Internet Explorer but not Opera

7.9 Processing Repeated Elements File xslplanes.xml contains data about multiple airplanesxslplanes.xml The style sheet xslplanes.xsl uses a for-each element to process each plane element in the source documentxslplanes.xsl A sort element could be included to sort output The element Specifies sorting by year

Overview

7.10 XML Processors XML processors provide tools in programming languages to read in XML documents, manipulate them and to write them out

7.10 Purposes of XML Processors Four purposes Check the basic syntax of the input document Replace entities Insert default values specified by schemas or DTD’s If the parser is able and it is requested, validate the input document against the specified schemas or DTD’s The basic structure of XML is simple and repetitive, so providing library support is reasonable Examples Xerces-J from the Apache foundation provides library support for Java Command line utilities are provided for checking well-formedness and validity Two different standards/models for processing SAX DOM

7.10 Parsing The process of reading in a document and analyzing its structure is called parsing The parser provides as output a structured view of the input document

7.10 The SAX Approach In the SAX approach, an XML document is read in serially As certain conditions, called events, are recognized, event handlers are called The program using this approach only sees part of the document at a time

7.10 The DOM Approach In the DOM approach, the parser produces an in- memory representation of the input document Because of the well-formedness rules of XML, the structure is a tree Advantages over SAX Parts of the document can be accessed more than once The document can be restructured Access can be made to any part of the document at any time Processing is delayed until the entire document is checked for proper structure and, perhaps, validity One major disadvantage is that a very large document may not fit in memory entirely

7.11 Web Services Allow interoperation of software components on different systems written in different languages Servers that provide software services rather than documents Remote Procedure Call DCOM and CORBA provide implementations DCOM is Microsoft specific CORBA is cross-platform

7.11 Web Service Protocols Three roles in web services Service providers Service requestors Service registry The Web Services Definition Language provides a standard way to describe services The Universal Description, Discovery and Integration service provides a standard way to provide information about services in response to a query SOAP is used to specify requests and responses