1 understanding xml namespaces. 2 understanding namespaces Namespaces are the source of much confusion in XML, especially for those new to the technology.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 5-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Advertisements

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.
Chapter 3: XML Namespaces. Chapter 3 Objectives Why you need namespaces What namespaces are, conceptually and how they solve the problem of naming clashes.
17 Apr 2002 XML Namespaces Andy Clark. The Problem Documents use different vocabularies – Example 1: CD music collection – Example 2: online order transaction.
Namespace in XML Transparency No. 1 Namespace in XML Cheng-Chia Chen.
XML Namespaces Each schema file associated with a URL to uniquely identify where elements come from – Like packages in Java
XML Namespaces Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Enabling Grids for E-sciencE ISSGC’05 XML documents Richard Hopkins, National e-Science Centre, Edinburgh June 2005.
XML Syntax Lecture 2 – 06/25/02. XML Building Blocks XML Declaration Document Type Declaration Elements Attributes Comments Entities Processing Instructions.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
Namespace in XML Transparency No. 1 Namespace in XML Cheng-Chia Chen.
More XML namespaces, DTDs CS 431 – February 16, 2005 Carl Lagoze – Cornell University.
XML Namespaces Andrey Smirnov CSCI 7818 September 21, 2000.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML & Related LanguagesXML Essentials (part 2) © 2003 John E. Arnold All Rights Reserved. 1 XML & Related Languages Unit 2 XML Essentials (part 2)
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
Unit 4 – XML Schema XML - Level I Basic.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
17 Apr 2002 XML Schema Andy Clark. What is it? A grammar definition language – Like DTDs but better Uses XML syntax – Defined by W3C Primary features.
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.
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.
1 COS 425: Database and Information Management Systems XML and information exchange continued Last time: XML document structure XML querying with XQuery.
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.
Cornell CS 502 More XML XHTML, namespaces, DTDs CS 502 – Carl Lagoze – Cornell University.
XML eXtensible Markup Language Part 2.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
1 XML An Overview Roger Debreceny University of Hawai`i Skip White University of Delaware XBRL Workshop, August 2006.
New Perspectives on XML, 2nd Edition
An OO schema language for XML SOX W3C Note 30 July 1999.
More XML namespaces, DTDs CS 431 – Carl Lagoze – Cornell University.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
XML Basics A brief introduction to XML in general 1XML Basics.
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.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
1 Compound Documents: Combining XML Vocabularies.
XML Schema Definition (XSD). Definition of a Schema It is a model for describing the structure and content of data The XML Schema was developed as a content.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
CIS 228 The Internet 9/20/11 XHTML 1.0. “Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
PART 1 XML Basics. Slide 2 Why XML Here? You need to understand the basics of XML to do much with Android All of they layout and configuration files are.
XML Namespaces In this first lesson XML Namespaces, you will learn to:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
Beginning XML 4th Edition. Chapter 3: XML Namespaces.
1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.
The Purpose of XML Namespaces
Unit 4 Representing Web Data: XML
WORKING WITH NAMESPACES
XML QUESTIONS AND ANSWERS
Chapter 7 Representing Web Data: XML
XML Path Language Andy Clark 17 Apr 2002.
Namespace Review 21-Nov-18.
Namespace Review 29-Dec-18.
Namespace Review 14-Oct-19.
New Perspectives on XML
Presentation transcript:

1 understanding xml namespaces

2 understanding namespaces Namespaces are the source of much confusion in XML, especially for those new to the technology. This confusion dissipates when one understands the meaning of namespaces along with how they are defined and used in XML documents both syntactically and abstractly.

3 what is a namespace? A namespace is a set of names in which all names are unique –Namespaces make it easier to develop unique names –Namespace authorities ensure that new names don't already exist in the namespace –Namespaces can also be given names/identifiers

4 Figure 1.1: Sample Namespaces

5 namespace qualified names Namespace qualified names remove ambiguity –A namespace qualified name is a name scoped by a namespace identifier –If the namespace identifier is unique, so is the namespace qualified name –Unqualified names are ambiguous

6 namespaces in programming languages Many programming languages provide syntax for defining and using namespaces –C++, Java, C#, and VB.NET all provide namespace support –Each language provides syntax for defining namespaces –Each language provides syntax for referring to names in a namespace

7 // syntax for defining namespaces namespace foo1 { class bar {... }; } namespace foo2 { class bar {... }; } // syntax for using namespaces foo1::bar b1; // refers to bar class in foo1 foo2::bar b2; // refers to bar class in foo2 using foo1; // sets foo1 as a default namespace bar b1; // refers to bar class in foo1 Figure 1.3: Using namespaces in C++

8 namespaces in xml XML requires namespaces to avoid name collisions –XML 1.0 was considered incomplete because it didn't offer namespace support –Working with a single global namespace makes it hard to develop unique names –Mixing XML vocabularies in a namespace-less environment leads to name collisions –The Namespaces in XML Recommendation completed the XML 1.0 spec by defining support for namespaces

Jeff Smith C# Jill Smith Spanish 3.2 Figure 1.4: Example of name collisions in XML

10 defining namespaces in xml XML namespaces are defined by formal specification documents as well as schema definitions –Neither XML 1.0 or the namespaces specification codify how to define a namespace –Most XML namespaces are defined in formal specification documents (e.g., XSLT 1.0) –XML namespaces can also be defined in terms of XML schema definitions –All XML namespaces are given unique identifiers

11 xml namespace identifiers XML namespaces identifiers are URIs (RFC 2396) –A URI is a compact string of characters for identifying an abstract or physical resource –There are two general types of URI: URL and URN –When a URI is used as a namespace identifier, it only identifies an abstract resource (the namespace) not a physical resource –Namespace identifiers are treated as opaque strings –Namespace identifiers are identical when they are exactly the same character for character

urn:www-develop-com:student urn: urn:uuid:E7F73B13-05FE-44ec-81CE-F898C4A6CDB4 Figure 1.5: Examples of URLs and URNs

13 uniqueness of namespace identifiers XML namespace identifiers must be unique –URIs, by definition, are unique –Internet naming authorities help ensure uniqueness –Organizations are required to ensure uniqueness within their assigned name –Organizations should develop conventions for creating new namespace identifiers (e.g., W3C)

14 Figure 1.6: W3C namespace identifier examples

15 using namespaces in xml documents Namespaces in XML spec defines syntax for qualifying element/attribute names with a namespace identifier –Element/attribute names can be qualified with a namespace prefix ( QName = prefix:local_name ) –A namespace prefix is an abbreviation for a namespace identifier (URI) –Namespace prefixes are mapped to namespace identifiers through namespace declarations ( xmlns:prefix='namespace identifier' ) –Namespace declarations are placed within element start tags just like attributes

16 <d:student xmlns:d=' xmlns:i='urn:schemas-develop-com:identifiers' xmlns:p='urn:schemas-develop-com:programming-languages' > Jeff Smith C# 9.5 Figure 1.7: Sample document using namespace qualified names

17 namespace declaration scope A namespace prefix is considered in-scope on the declaration element and on any of its descendant elements –As long as the prefix is in-scope, it can be used in front of any element or attribute name separated by a colon –A prefix associates the element/attribute name with the associated namespace identifier –Prefixes can be overridden via nested declarations

Jeff Smith C# 35 Figure 1.8: Example of namespace declaration scoping

19 default namespace declarations Default namespace declarations are also used to associate namespace identifiers with element names –A default namespace declaration doesn't include a prefix ( xmlns='namespace identifier' ) –When a default namespace declaration is used on an element, all un-qualified element names within its scope are automatically associated with the specified namespace –Default namespace declarations have no effect on attributes

20 <d:student xmlns:d=' xmlns='urn:foo' id=' '> Jeff Smith C# 35 Figure 1.9: Sample document using default namespace declaration

21 namespace abstractions Dealing with namespaces from the abstract view of an XML document is simpler than dealing with the lexical issues –The Infoset specifies that elements/attributes have two name properties: a namespace identifier and a local name –These two properties together determine the role of an element/attribute within a document –All other XML specifications deal with XML documents from this perspective

22 Figure 1.10: Namespaces in the Infoset

23 summary A namespace is a set of names in which all names are unique XML namespaces are defined in specification documents XML namespaces are identified via URIs Elements/attributes are associated with a namespace identifier through a namespace prefix or a default namespace declaration Abstractly, elements/attributes have two name properties: namespace identifier and local name