1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

XHTML Basics.
 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.
Tutorial 6 Creating a Web Form
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
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.
Tutorial 11 Creating XML Document
4.01 Cascading Style Sheets
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
Tutorial 2: XML Working with Namespaces. COMBINING XML VOCABULARIES IN A COMPOUND DOCUMENT Section 2.1.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Working with Namespaces Combining XML Vocabularies in a Compound Document.
XML 2nd EDITION Tutorial 2 Working With Namespaces.
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
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Validating DOCUMENTS with DTDs
Working with XHTML Creating a Well-Formed Valid Document.
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.
Web Technologies Website Development Trade & Industrial Education
HTML, XHTML, and CSS Chapter 12 Creating and Using XML Documents.
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
Website Development with Dreamweaver
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
XP New Perspectives on The Internet, Sixth Edition— Comprehensive Tutorial 8 1 Creating Effective Web Pages Creating HTML Documents Tutorial 8.
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 1 TUTORIAL 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and.
Tutorial 8 Designing a Web Site with Frames. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore the uses of frames.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
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.
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.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
1 Compound Documents: Combining XML Vocabularies.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Objective: To describe the evolution of the Internet and the Web. Explain the need for web standards. Describe universal design. Identify benefits of accessible.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
Creating and Editing a Web Page
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
HTML5 and CSS3 Illustrated Unit C: Getting Started with CSS.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 1 Using HTML to Create Web Pages.
HTML Structure & syntax
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
Tutorial 9 Working with XHTML
4.01 Cascading Style Sheets
WORKING WITH NAMESPACES
Website Design 3
Introducing HTML & XHTML:
Tutorial 9 Working with XHTML
Tutorial 3 Working with Cascading Style Sheets
Understand basic HTML and CSS terminology, concepts, and basic operations. Objective 3.01.
4.01 Cascading Style Sheets
New Perspectives on XML
Presentation transcript:

1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Combining XML Vocabularies A document that combines several vocabularies is known as a compound document

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 3 Working with Namespaces Name collision occurs when elements from different XML vocabularies use the same name within a compound document Name collision is not a problem if you are not concerned with validation. The document content only needs to be well-formed. However, name collision will keep a document from being validated.

Name Collision New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 4

5 Working with Namespaces A namespace is a defined collection of element and attribute names. Names that belong to the same namespace must be unique. Elements can share the same name if they reside in different namespaces. Namespaces must be declared before they can be used.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 6 Declaring a Namespace A namespace can be declared in the prolog or as an element attribute. The syntax for an attribute used to declare a namespace in the prolog is: xmlns:prefix=“URI” Where URI is a Uniform Resource Identifier that assigns a unique name to the namespace, and prefix is a string of letters that associates each element or attribute in the document with the declared namespace.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 7 Declaring a Namespace For example, > Declares a namespace with the prefix “mod” and the URI The URI is not a Web address. A URI identifies a physical or an abstract resource.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 8 Understanding URIs The purpose of a URI is simply to provide a unique string of characters that identify a resource. A URL is one type of URI. Although the URI doesn’t actually need to point to a real site on the Web, it is often helpful to place documentation at the site identified by the URI so that users can go there to learn more about the XML vocabulary being referenced

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 9 Applying a Namespace to an Element After you declare a namespace, you have to indicate which elements in the document belong to that namespace. content Here, prefix is the namespace prefix and element is the local part of the element name.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 10 Applying a Namespace to an Element Prefixed names are called qualified names and an element name without a namespace prefix is called an unqualified name. Qualified names can be added to a document using code entered directly into the document.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 11 Applying a Namespace to an Element the code: Laser4C (PR205) Entry level color laser printer color laser 320

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 12 Applying a Namespace to an Element …applies the namespace namespace to the model element and all of its child elements. While the “mod” prefix was only added to the model element name, the XML parser considers the other elements parts of the model namespace and they inherit the namespace.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 13 Applying a Namespace to an Element They are unqualified elements, though, because they lack a namespace prefix. Declaring a namespace by adding it as an attribute of the document’s root element places all elements in the namespace. All elements thus are children of the root element.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 14 Declaring a Default Namespace You can specify a default namespace by omitting the prefix in the namespace declaration. The element containing the namespace attribute and all of its child elements are assumed to be part of the default namespace.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 15 Working with Attributes Attributes, like elements, can become qualified by adding the namespace prefix to the attribute name. For example,...

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 16 Working with Attributes No element may contain two attributes with the same name. No element may contain two qualified attribute names with the same local part, pointing to identical namespaces, even if the prefixes are different.

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 17 Adding a Namespace to a Style Sheet: Declaring a Namespace To declare a namespace in a style sheet, you add the following rule to the style sheet prefix “uri”; Where prefix is the namespace prefix and uri is the URI of the namespace mod “

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 18 Applying a Namespace to a Selector Once you’ve declared a namespace in a style sheet, you can associate selectors with that namespace using the syntax: prefix|selector {attribute1:value1; attribute2:value2;…} For example: mod|title {width: 150px} You also can use the wildcard symbol (*) to apply a style to any element within a namespace or to elements across different namespaces

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 19 Defining Namespaces with the Escape Character Not all browsers support the use of rule A proposal implement in the Internet Explorer browser was to insert the backslash escape character before the namespace prefix in CSS style sheets: prefix\:selector {attribute1:value1; attribute2:value2;…} Browsers like Firefox, Opera, and Safari do not support this method with XML documents

20 Declaring and Applying a Namespace in a Style Sheet To declare a namespace in a CSS style sheet, add the prefix "uri"; before any style declarations, where prefix is the namespace prefix and uri is the namespace URI. If no prefix is specified, the namespace URI is the default namespace for selectors in the style sheet. To apply a namespace to a selector, use the form prefix|selector {attribute1:value1; attribute2:value2;...} where prefix is the namespace prefix and selector is a selector for an element or group of elements in the document. For Internet Explorer browsers, use the following form to apply a namespace to a selector: prefix\:selector {attribute1:value1; attribute2:value2;...}

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 21 Combining Standard Vocabularies Standard vocabularies may be combined within single documents

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 22 Converting HTML to XHTML Use your text editor to open the reptxt.htm file from the tutorial.12/tutorial folder. Enter your name and the date in the comment section at the top of the document. Save the file as report.htm. Insert the following xml declaration as the very first line in the file (above the comment section): Add the following attribute to the opening tag: xmlns="

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 23 Converting HTML to XHTML

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 24 Adding the Elements of the Parts Vocabulary Return to the order.xml file in your text editor. Copy the contents of the document from the opening tag through the closing tag. Return to the report.htm file in your text editor and paste the copied elements directly below the h2 heading “Parts List.” Add the following attribute to the opening tag: xmlns:pa=" Below the link element that links the report.htm file to the report.css style sheet, insert the following link element: Save the changes and open the report.htm file in your Web browser

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 25 Adding the Elements of the Parts Vocabulary

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 26 Describing the Items in the Parts List Return to the report.htm file in your text editor. Scroll down to the first title element in the parts namespace. Directly after the opening tag, insert the text Title Directly after the opening tag in the next line, insert the text Description Directly after the opening tag in the following line, insert the text Parts in Stock Repeat the previous 3 steps, as necessary

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 27 Describing the Items in the Parts List

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 28 Describing the Items in the Parts List

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 29 Adding Elements from the Models Vocabulary Return to the report.htm file in your text editor and add the following namespace declaration to the opening tag: xmlns:mod=" Add the following link to the document’s head: In the table cell directly after the Title table heading, insert the element Laser4C (PR205)

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 30 Adding Elements from the Models Vocabulary In the table cell directly after the Description table heading, insert the element Entry level color laser printer In the table cell directly after the Type table heading, insert the element color laser In the table cell directly after the “Items to be Built” table heading, insert the element 320

Adding Elements from the Models Vocabulary Add the following tag directly after the opening tag to include the root element of the models vocabulary: Directly before the closing tag, insert the following closing tag for the root model element: New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 31

New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 32 Adding Elements from the Models Vocabulary