Tutorial 11 Creating XML Document

Slides:



Advertisements
Similar presentations
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
Advertisements

 Fundamentals of Web Design.  Describe the history and theory of XHTML  Understand the rules for creating valid XHTML documents  Apply a DTD to an.
An Introduction to XML Based on the W3C XML Recommendations.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
Tutorial 9 Working with XHTML
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
XML Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
Introduction to XML: Yong Choi CSU Bakersfield.
Upgrading to XHTML DECO 3001 Tutorial 1 – Part 1 Presented by Ji Soo Yoon 19 February 2004 Slides adopted from
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
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.
WORKING WITH NAMESPACES
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
Validating DOCUMENTS with DTDs
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.
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
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
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
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.
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.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
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.
XP 2 HTML Tutorial 1: Developing a Basic Web Page.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
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.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
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.
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 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.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
XML Basics A brief introduction to XML in general 1XML Basics.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
XML Module 1 Creating an XML Document. XP Objectives Session 1.1 – Describe the history of XML and the uses of XML documents – Understand XML vocabularies.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XP 1 New Perspectives on XML Tutorial 1 – Creating an XML Document Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga University.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
XP 1Creating Web Pages with XML Tutorial 1 New Perspectives on XML Tutorial 1 – Creating an XML Document.
XML Extensible Markup Language
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.
Unit 4 Representing Web Data: XML
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
Tutorial 9 Working with XHTML
Chapter 7 Representing Web Data: XML
Creating an XML Document
Introducing HTML & XHTML:
Tutorial 9 Working with XHTML
Presentation transcript:

Tutorial 11 Creating XML Document

Objectives Describe the history of XML and the uses of XML documents Understand XML vocabularies Define well-formed and valid XML documents, and describe the basic structure of an XML document Create an XML declaration Work with XML comments Work with XML parsers and understand how Web browsers work with XML documents New Perspectives on HTML, CSS, and XML 4th edition

Objectives (continue) Create XML elements and attributes Work with character and entity references Describe how XML handles parsed character data, character data, and white space Create an XML processing instruction to apply a style sheet to an XML document Declare a default namespace for an XML vocabulary and apply the namespaceAccess desktop icons and gadgets on the desktop New Perspectives on HTML, CSS, and XML 4th edition

Introducing XML XML stands for Extensible Markup Language. It is markup language that can be extended and modified to match the needs of the document author and data being recorded. XML has some advantages in presenting structured content. Because it is extensible, XML can be used to create a wide variety of document types. New Perspectives on HTML, CSS, and XML 4th edition 4

Introducing XML XML has its roots in Standard Generalized Markup Language (SGML) which was introduced in the 1980s. SGML is device-independent and system-independent. SGML is difficult to learn and to apply because of its power, scope, and flexibility. XML is a language used to create vocabularies for other markup languages but does not have SGML complexity. New Perspectives on HTML, CSS, and XML 4th edition 5

XML Syntax Rules New Perspectives on HTML, CSS, and XML 4th edition 6

XML Today XML was originally created to structure, store, and transport information. XML has become the most common tool for data transmission among various applications. XML is used across a variety of industries. XML is used in all major Web sites. Many software applications (Excel and Word), and server languages (Java, .NET, Perl, PHP) can read and create XML files. New Perspectives on HTML, CSS, and XML 4th edition 7

XML Today (continue) All major databases can read and create XML files. On Web pages the structure of XML closely matches the structure used to display the same information in HTML. Mobile device platforms (Google’s Android and Apple’s iOS use XML in a variety of ways. New Perspectives on HTML, CSS, and XML 4th edition 8

XML Vocabularies New Perspectives on HTML, CSS, and XML 4th edition 9

Well-Formed and Valid XML Documents An XML document is well-formed if it contains no syntax errors and satisfies the general specifications for XML code as laid out by the W3C. A well-formed XML document that satisfies the rules of a DTD or schema is said to be a valid document. New Perspectives on HTML, CSS, and XML 4th edition 10

The Structure of an XML Document XML documents consist of three parts The prolog The document body The epilog The prolog is optional and provides information about the document itself XML declaration Processing instructions Comments lines Document type declaration (DTD) New Perspectives on HTML, CSS, and XML 4th edition 11

The Structure of an XML Document New Perspectives on HTML, CSS, and XML 4th edition 12

The Structure of an XML Document The document body contains the document’s content in a hierarchical tree structure. The epilog is also optional and contains any final comments or processing instructions. New Perspectives on HTML, CSS, and XML 4th edition 13

The XML Declaration The XML declaration is always the first part of the prolog in an XML document. It signals to the program reading the file that the document is written in XML, and it provides information about how that code is to be interpreted by the program. The syntax is: <?xml version=“version number” encoding=“encoding type” standalone=“yes | no” ?> A sample declaration: <?xml version=“1.0” encoding=“UTF-8” standalone=“yes” ?> New Perspectives on HTML, CSS, and XML 4th edition 14

Inserting Comments Comments can appear anywhere in the prolog go after the XML declaration. Comments provide additional information about what the document will be used for and how it was created. The syntax for comments is <!-- comment --> This is the same syntax for HTML comments <!-- This document contains data on SJB Pet Butique holiday specials File name: sjbpet.xml Author: Patricia Dean Date: 9/18/2016 --> New Perspectives on HTML, CSS, and XML 4th edition 15

XML Parsers Parser (or processor) is a program that reads and interprets an XML document. Parser interprets a document’s code and verifies that it satisfies all the XML specifications for document structure and syntax. Parsers are strict. All major Web browsers include an XML parser. New Perspectives on HTML, CSS, and XML 4th edition

XML Parsing Process New Perspectives on HTML, CSS, and XML 4th edition

Exchanger XML Editor New Perspectives on HTML, CSS, and XML 4th edition

Working with Elements Elements are the basic building blocks of XML. An element can have text content and child element content. The content is stored between an opening tag and a closing tag, just as in HTML. The syntax of an XML element with text: <element>content</element> Example: <manufacturer>SJB Pet Boutique</manufacturer> New Perspectives on HTML, CSS, and XML 4th edition 19

Working with Elements Element names are case sensitive. Element names must begin with a letter or the underscore and cannot contain blank spaces. The element’s name in closing tag must exactly match the name in the opening tag. An empty element with a single tag: <element /> An empty element with a pair of tags: <element></element> New Perspectives on HTML, CSS, and XML 4th edition 20

Nesting Elements An element contained within another element. Nested elements also called child elements. Child elements must be enclosed within their parent elements. Example: <product> <productName>Dog Shirt Gift Basket</productName> <manufacturer>SJB Pet Boutique</manufacturer> <description>Something for every day of the week</description> <price>35.99</price> <productItems>1200, 1201, 1202, 1203, 1204 </productItems> </product> New Perspectives on HTML, CSS, and XML 4th edition 21

The Element Hierarchy All elements in the body are children of a single element called the root or document element. There can be only one root element. The familial relationship of parent, child, and sibling extends throughout the entire document body. New Perspectives on HTML, CSS, and XML 4th edition 22

The Element Hierarchy New Perspectives on HTML, CSS, and XML 4th edition

Charting the Element Hierarchy New Perspectives on HTML, CSS, and XML 4th edition 24

Writing the Document Body New Perspectives on HTML, CSS, and XML 4th edition 25

Working with Attributes An attribute is a feature or characteristic of an element. Every element can contain one or more attributes. Attributes are text strings and must be placed in single or double quotes. The syntax is: <element attribute=“value”> … </element> or <element attribute=“value” /> New Perspectives on HTML, CSS, and XML 4th edition 26

Working with Attributes New Perspectives on HTML, CSS, and XML 4th edition

Using Character and Entity References Special characters, such as the € symbol, can be inserted into your XML document by using a character reference. The syntax is: &#nnn; Some symbols also can be identified using entity reference. The syntax is: &#entity; New Perspectives on HTML, CSS, and XML 4th edition 28

Using Character and Entity References nnn is a character reference number or name from the ISO/IEC character set. entity is the name assigned to the symbol. ISO/IEC character set is an international numbering system for referencing characters from virtually any language. Character references in XML are the same as in HTML. New Perspectives on HTML, CSS, and XML 4th edition 29

Using Character and Entity References New Perspectives on HTML, CSS, and XML 4th edition 30

Using Character and Entity References New Perspectives on HTML, CSS, and XML 4th edition 31

Parsed Character Data Parsed character data (PCDATA) consists of all those characters that XML treats as parts of the code of XML document The XML declaration The opening and closing tags of an element Empty element tags Character or entity references Comments New Perspectives on HTML, CSS, and XML 4th edition 32

Character Data and White Space Character data is not processed, but instead is treated as pure data content. White space refers to nonprintable characters such as spaces (created by pressing the Spacebar), new line characters (created by pressing the Enter key), or tab characters (created by pressing the Tab key). HTML applies white space stripping, in which consecutive occurrences of white space are treated as a single space. New Perspectives on HTML, CSS, and XML 4th edition 33

Creating a CDATA Section A CDATA section is a block of text that XML treats as character data only. The syntax to create a CDATA section is: <! [CDATA [ character data ] ]> A CDATA section may contain most markup characters, such as <, >, and &. New Perspectives on HTML, CSS, and XML 4th edition 34

Creating CDATA Section This example shows an element named htmlcode that contains a CDATA section, which is used to store several HTML tags: <htmlcode> <![CDATA[ <h1>SJB Pet Boutique</h1> <h2>Fashion for Pets and Their Humans</h2> ]]> </htmlcode> New Perspectives on HTML, CSS, and XML 4th edition 35

Example of CDATA Section New Perspectives on HTML, CSS, and XML 4th edition 36

Formatting XML Data with CSS XML documents do not include any information about how they should be rendered. Rendering is determined solely by the parser. Link the XML document to a style sheet to format the document. The XML parser will combine the style sheet with the XML document and will render a single formatted document. New Perspectives on HTML, CSS, and XML 4th edition 37

Formatting XML Data with CSS New Perspectives on HTML, CSS, and XML 4th edition 38

Applying a Style to an Element Cascading Style Sheets (CSS) – style sheet language. To apply a style sheet to a document, use the following style declaration: selector { attribute1: value1; attribute2: value2; … } selector is an element (or set of elements, separated by comma) from the XML document. attribute and value are the style attributes and attribute values to be applied to the document. New Perspectives on HTML, CSS, and XML 4th edition 39

Applying a Style to an Element For example: author { color: red; font-weight: bold; } Will display the text of the artist element in a red boldface type. New Perspectives on HTML, CSS, and XML 4th edition 40

Inserting a Processing Instruction The link from the XML document to a style sheet is created using a processing instruction. A processing instruction is a command that tells an XML parser how to process the document. Processing instruction syntax: <?target instruction ?> target identifies the program (or object) to which the processing instruction is directed and instruction is information that the document passes on to the parser for processing <?xml-stylesheet type=”text/css” href=”url” media=”type” ?> New Perspectives on HTML, CSS, and XML 4th edition 41

The sjbpet.xml Document with Style Sheet Applied New Perspectives on HTML, CSS, and XML 4th edition 42

Working with Namespaces Namespace – a defined collection of element and attribute names. Applying a namespace to an XML document involves two steps: Declare the namespace. Identify the elements and attributes within the document that belong to that namespace. New Perspectives on HTML, CSS, and XML 4th edition

Declaring a Namespace Syntax: <element xmlns:prefix=”uri”> ... </element> element is the element in which the namespace is declared, prefix is a string of characters that you’ll add to element and attribute names to associate them with the declared namespace, and uri is a Uniform Resource Identifier (URI)—a text string that uniquely identifies a resource. Example: <products xmlns:prd=”http://example.com/sjbpetboutique/products”> ... </products> New Perspectives on HTML, CSS, and XML 4th edition

Applying a Default Namespace A default namespace is declared omitting the prefix in the namespace declaration. Syntax: <element xmlns=”uri”> ... </element> Example: <products xmlns=”http://example.com/sjbpetboutique/products”> New Perspectives on HTML, CSS, and XML 4th edition