XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.

Slides:



Advertisements
Similar presentations
Working with Web Tables
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.
Tutorial 6 Creating a Web Form
Creating Special Effects with CSS
Tutorial 9 Working with XHTML
XHTML1 Building Document Structure. XHTML2 Objectives In this chapter, you will: Learn how to create Extensible Hypertext Markup Language (XHTML) documents.
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 4 Creating Special Effects with CSS
Tutorial 11 Creating XML Document
Tutorial 2: XML Working with Namespaces. COMBINING XML VOCABULARIES IN A COMPOUND DOCUMENT Section 2.1.
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
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Validating DOCUMENTS with DTDs
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
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.
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
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.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorial 9: Working With XHTML.
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.
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.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
Tutorial 5 Working with Tables and Columns
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
New Perspectives on XML, 2nd Edition
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.
Tutorial 5 Working with Web Tables. XP Objectives Explore the structure of a Web table Create headings and cells in a table Create cells that span multiple.
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
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
1 Compound Documents: Combining XML Vocabularies.
Positioning and Printing Creating Special Effects with CSS.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
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.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
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.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.
Tutorial 6 Creating a Web Form
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
XML Namespaces In this first lesson XML Namespaces, you will learn to:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Internet & World Wide Web How to Program, 5/e 1. 2.
Working with Cascading Style Sheets
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
Tutorial 9 Working with XHTML
>> Introduction to CSS
WORKING WITH NAMESPACES
Website Design 3
Tutorial 9 Working with XHTML
New Perspectives on XML
Presentation transcript:

XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES

XP New Perspectives on XML, 2nd Edition Tutorial 2 2 COMBINING XML VOCABULARIES A document that combines several vocabularies is known as a compound document

XP New Perspectives on XML, 2nd Edition Tutorial 2 3 WORKING WITH NAMESPACES Name collision occurs when elements from two or more documents share the same name. 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.

XP New Perspectives on XML, 2nd Edition Tutorial 2 4 NAME COLLISION This figure shows name collision Parts vocabulary Model vocabulary

XP New Perspectives on XML, 2nd Edition Tutorial 2 5 DECLARING A NAMESPACE 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.

XP New Perspectives on XML, 2nd Edition Tutorial 2 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 prefix is a string of letters “Short hand name”Full, unique name

XP New Perspectives on XML, 2nd Edition Tutorial 2 7 DECLARING A NAMESPACE For example, xmlns:mod=“ declares a namespace with the prefix “mod” and the URI The URI is not a Web address. A URI (Uniform Resource Identifier) identifies a physical or an abstract resource. URI (Uniform Resource Identifier) URL (Uniform Resource Locator) Physical Resource: file, a Web page, or an address URN (Uniform Resource Name) Persistent name for a resource

XP New Perspectives on XML, 2nd Edition Tutorial 2 8 URIs, URLs, AND URNs URN (Universal Resource Name) is a persistent resource identifier, meaning the user need only know the name of a resource. URNs take the form: urn:NID:NSS NID = namespace identifier NSS = text string specific to that the namespace Example –urn: isbn:

XP New Perspectives on XML, 2nd Edition Tutorial 2 9 APPLYING A NAMESPACE TO AN ELEMENT Use prefix instead of the URI to qualify element names General form: content For example xmlns:mod= Laser4C (PR205)

XP New Perspectives on XML, 2nd Edition Tutorial 2 10 APPLYING A NAMESPACE TO AN ELEMENT Prefixed names are called qualified names Example: Laser4C (PR205) A name without a namespace prefix is called an unqualified name. Example: Laser4C (PR205)

XP New Perspectives on XML, 2nd Edition Tutorial 2 11 DECLARING A NAMESPACE AS AN ELEMENT ATTRIBUTE For example, the code: Laser4C (PR205) Entry level color laser printer color laser 320 …applies the namespace to the model element and all of its child elements.

XP New Perspectives on XML, 2nd Edition Tutorial 2 12 DECLARING A DEFAULT NAMESPACE You can specify a default namespace by omitting the prefix in the namespace declaration. Example: Laser4C (PR205) Entry level color laser printer color laser 320 All elements including the model element, are considered to be part of the name space :mod removed

XP New Perspectives on XML, 2nd Edition Tutorial 2 13 USING NAMESPACES WITH ATTRIBUTES Attributes, like elements, can become qualified by adding the namespace prefix to the attribute name. The syntax is: … For example: <mod:model xmlns:mod= mod:id=“pr205”> …. Attributes inherit their namespace from their parent element: For example: <mod:model xmlns:mod= id=“pr205”> …..

XP New Perspectives on XML, 2nd Edition Tutorial 2 14 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 url(uri); Where prefix is the namespace previx and uri is the URI of the namespace mod url(

XP New Perspectives on XML, 2nd Edition Tutorial 2 15 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

XP APPLYING A NAMESPACE TO A SELECTOR You also can use the wildcard symbol (*) to apply a style to any element within a namespace or to elements across different namespaces mod | title {width: 15px} applies width style to all title elements in the models namespace mod | * {font-size: 12 pt} applies the font-sie style to any element within the models namespace title {witdth: 15p} applies a width of 150 pixels to any element named title Not supported by Firefox, Opera, and Netscape New Perspectives on XML, 2nd Edition Tutorial 2 16

XP New Perspectives on XML, 2nd Edition Tutorial 2 17 COMBINING STANDARD VOCABULARIES Standard vocabularies may be combined within single documents

XP A compound XHTML and MathML document See page XML 68 New Perspectives on XML, 2nd Edition Tutorial 2 18

XP New Perspectives on XML, 2nd Edition Tutorial 2 19 XHTML

XP Summary Combining vocabularies in a single document can result in name collisions Use namespaces to resolve collisions Namespaces use URI to provide unique identification for each vocabulary in a document CSS style sheets can be modified to accommodate namespaces You can create an XHTML document that combines features from XHTML and other XML vocabularies New Perspectives on XML, 2nd Edition Tutorial 2 20