Chapter 10 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 10 Sebesta: Programming the World Wide Web.

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

Chapter 7 An Introduction to XML.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
Document Type Definitions
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.
Tutorial 11 Creating XML Document
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.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
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.
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 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.
XML What is XML? XML v.s. HTML XML Components Well-formed and Valid Document Type Definition (DTD) Extensible Style Language (XSL) SAX and DOM.
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.
XML Syntax - Writing XML and Designing DTD's
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
1 Introduction to Web Application Introduction to XML.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
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.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
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.
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
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.
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
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
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.
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… XML Syntax v2.0.
Well Formed XML The basics. A Simple XML Document Smith Alice.
CS3101: Internet Programming Chapter 06: XML and RSS.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
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.
Extensible Markup Language (XML) Pat Morin COMP 2405.
Chapter 8 Introduction to XML.
Unit 4 Representing Web Data: XML
XSLT 1.0.
Chapter 7 Representing Web Data: XML
Chapter X IXXXXXXXXXXXXXXXX.
7.1 Introduction - SGML is a meta-markup language
Allyson Falkner Spokane County ISD
Presentation transcript:

Chapter 10 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 10 Sebesta: Programming the World Wide Web

Chapter 10 © 2001 by Addison Wesley Longman, Inc Introduction - The Standard Generalized Markup Language (SGML) is a meta-markup language to define markup languages. - SGML was developed in the early 1980s and approved as an ISO standard in HTML was developed using SGML in the early 1990s - specifically for Web documents - Two problems with HTML: 1. Fixed set of tags and attributes - User cannot invent new tags or attributes - So, the given tags must fit every kind of document, and the tags cannot connote any particular meaning 2. There are no restrictions on arrangement or order of tag appearance in a document - One solution to the first of these problems: Let users define their own tags (with assigned meanings) (i.e., design their own “HTML”s using SGML)

Chapter 10 © 2001 by Addison Wesley Longman, Inc Introduction (continued) - Problem with using SGML: - It’s too large and complex to use, and it is very difficult to build a parser for it - A better solution: Define a simplified version of SGML - That’s what the eXtensible Markup Language is. - The World Wide Web Consortium (W3C) began work on XML in 1996 and published the XML 1.0 in XML is not a replacement for HTML - HTML is a markup language used to describe the layout of any kind of information - XML is a meta-markup language that can be used to define markup languages that can define the meaning of specific kinds of information - XML is a very simple and universal way of storing and transferring data of any kind - All documents described with an XML-derived markup language can be parsed with a single parser

Chapter 10 © 2001 by Addison Wesley Longman, Inc Introduction (continued) - We will refer to an XML-based markup language as a tag set - Strictly speaking, a tag set is an XML application, but that terminology can be confusing - IE5 has an XML parser (although it is based on an early XML standard) - NN4 does not support XML, but NN6 does 10.2 The Syntax of XML - XML documents have data elements, markup declarations (instructions for the XML parser), and processing instructions (for the application program that is processing the data in the document) - All XML documents begin with an XML declaration:

Chapter 10 © 2001 by Addison Wesley Longman, Inc The Syntax of XML (continued) - XML names: - Must begin with a letter or an underscore - They can include digits, hyphens, and periods - There is no length limitation - They are case sensitive (unlike HTML names) - Syntax rules for XML: (similar to those for XHTML) - Every element that has content must have a closing tag - Tags must be properly nested - All attribute values must be quoted - An XML document that follows all of these rules is well formed - Attributes are not used in XML the way they are in HTML - In XML, you often define a new nested tag to provide more info about the content of a tag

Chapter 10 © 2001 by Addison Wesley Longman, Inc The Syntax of XML (continued) - Nested tags are better than attributes, because attributes cannot describe structure and the structural complexity may grow... Maggie Dee Magpie... <!-- A tag with one nested tag, which contains three nested tags --> Maggie Dee Magpie...

Chapter 10 © 2001 by Addison Wesley Longman, Inc XML Document Structure - An XML document often uses two auxiliary files: - A Data Type Definition (rules about structure) - A style or presentation specification - An XML document has a single root element - An XML document consists of one or more entities - Entities range from a single special character to a book chapter - An XML document has one document entity - All other entities are referenced in the document entity - Reasons for entity structure: 1. Large documents are easier to manage 2. Repeated entities need not be literally repeated 3. Binary entities can only be referenced in the document entities (XML is all text!)

Chapter 10 © 2001 by Addison Wesley Longman, Inc XML Document Structure (continued) - When the XML parser encounters a reference to a non-binary entity, the entity is merged in - Entity names: - Do not have a length limitation - Must begin with a letter, a dash, or a colon - Can include letters, digits, periods, dashes, underscores, or colons - A reference to an entity has the form: & entity_name ; - One common use of entities is for special characters that may be used for markup delimiters - These are predefined: < < > > & & " " ' &apos; - The user can only define entities in a DTD

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions - A DTD is a set of structural rules called declarations - These rules specify how and where a set of elements can appear in a document - Not all XML documents have or need a DTD - The DTD for a document can be internal (embedded in the XML document) or external (a separate file). - All of the declarations of a DTD are enclosed in the block of a DOCTYPE markup declaration - DTD declarations have the form: - There are four possible declaration keywords: ELEMENT, ATTLIST, ENTITY, and NOTATION

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Declaring Elements - Element declarations are similar to BNF (Backus- Naur Form) - An element declaration specifies the element’s structure - If the element is a leaf node of the document tree, its structure is in terms of characters - If it is an internal node, its structure is a list of children elements (either leaf or internal nodes) - General form: e.g., memo fromtodaterebody

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Declaring Elements (continued) - Child elements can have modifiers, +, *, ? e.g., <!ELEMENT person (parent+, age, spouse?, sibling*)> - Leaf nodes specify data types, most often PCDATA, which is an acronym for parsable character data - Data type could also be EMPTY (no content) and ANY (can have any content) - Example of a leaf declaration: - Declaring Attributes - General form:

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Declaring Attributes (continued) - Attribute types: there are many possible, but we will consider only CDATA - Default values: a value #FIXED value (every element will have this value), #REQUIRED (every instance of the element must have a value specified), or #IMPLIED (no default value and need not specify a value) - e.g.,...

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Declaring Entities - Two kinds: - A general entity can be referenced anywhere in the content of an XML document - A parameter entity can be referenced only in a markup declaration - If several predefined entities must appear near each other in a document, it is better to avoid using entity references - Character data section e.g., instead of Start > > > > HERE < < < < use >>> HERE - If the CDATA content has an entity reference, it is taken literally

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Declaring Entities (continued) - General form of declaration: e.g., - A reference: &jfk; - If the entity value is longer than a line, define it in a separate file (an external text entity) --> SHOW planes.dtd - XML Parsers - Always check for well formedness - Some check for validity, relative to a given DTD - Called validating XML parsers - You can download a validating XML parser from:

Chapter 10 © 2001 by Addison Wesley Longman, Inc Data Type Definitions (continued) - Internal DTDs <!DOCTYPE root_name [ … ]> - External DTDs <!DOCTYPE XML_doc_root_name SYSTEM “DTD_file_name” > --> SHOW planes.xml - Problems with DTDs: 1. Syntax is different from XML - cannot be parsed with an XML parser 2. Do not allow specification of a particular kind of data - XML Schema are a solution to these problems - We don’t cover them because the popular browsers don’t support them, yet

Chapter 10 © 2001 by Addison Wesley Longman, Inc Namespaces - A markup vocabulary is the collection of all of the element types and attribute names of a markup language (a tag set) - An XML document may define its own tag set and also use that of another tag set - CONFLICTS! - An XML namespace is a collection of names used in XML documents as element types and attribute names - The name of an XML namespace has the form of a URI - A namespace declaration has the form: - The prefix is a short name for the namespace, which is attached to names from the namespace in the XML document - In the document, you can use - Purposes of the prefix: 1. Shorthand 2. URI includes characters that are illegal in XML

Chapter 10 © 2001 by Addison Wesley Longman, Inc Namespaces (continued) - Can declare two namespaces on one element <gmcars xmlns:gm = " xmlns:html = " - The gmcars element can now use gm names and html names - One namespace can be made the default by leaving the prefix out of the declaration 6. 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 --> SHOW Figure > SHOW Figure 10.3

Chapter 10 © 2001 by Addison Wesley Longman, Inc Displaying XML Documents with CSS - 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 planes.css and Figure XML Transformations and Style Sheets - XSL (Extensible Stylesheet Language), formerly called Extensible Style Language, is a language for creating a style sheet that describes how data sent over the Web using the (XML) is to be presented to the user. - XSL began as a standard for presentations of XML documents - Split into two parts: - XSLT – Transformations: XSL Transformations (XSLT) is a standard way to describe how to transform (change) the structure of an XML document into an XML document with a different structure. - XSL-FO - Formatting objects - XSLT uses style sheets to specify transformations

Chapter 10 © 2001 by Addison Wesley Longman, Inc XML Transformations and Style Sheets (continued) - 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. - 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 <?xml:stylesheet type = "text/xsl" href = " XSL style sheet "?> - An example: <?xml:stylesheet type = "text/xsl" href = "xslplane.xsl" ?> 1977 Cessna Skyhawk Light blue and white

Chapter 10 © 2001 by Addison Wesley Longman, Inc XML Transformations and Style Sheets (continued) - An XSLT style sheet is an XML document with a single element, stylesheet, which defines namespaces <xsl:stylesheet xmlns:xsl = " - For IE5, you must use the earlier namespace, - 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 HTML elements

Chapter 10 © 2001 by Addison Wesley Longman, Inc XML Transformations and Style Sheets (continued) Happy Easter! - XSLT elements that represent HTML 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.xsl and Figure The XSLT for-each element - Used when an XML document has a sequence of the same elements --> SHOW xslplanes.xml --> SHOW xslplanes.xsl & Figure 10.6