The XML NameSpace - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

The XML NameSpace

Description:

The prefixes of default namespace can be omitted. URI is unique!!! 7. 7. Definition ... Mechanisms are provided for prefix scoping and defaulting. ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 12
Provided by: ccNct
Category:

less

Transcript and Presenter's Notes

Title: The XML NameSpace


1
The XML NameSpace
  • http//www.w3.org/TR/REC-xml-names

2
Motivation
  • XML is extensible
  • But, extensibility does not come free
  • Extensibility must be managed to avoid conflicts
  • Namespaces is a solution to help manage XML
    extensibility
  • Example xml_example/chap04 two people extend
    the same document in incompatible ways
  • bookmark.xml
  • star_rating.xml
  • pa_rating.xml
  • star_pa_rating.xml

3
Motivation (Cont.)
  • Problems in star_pa_rating.xml
  • Software designed to operate with PA rating would
    be lost
  • How to do with 4 stars rating?
  • Ignore?
  • No way to differentiate PA rating with Star
    rating
  • Brute-force solution Use different names for the
    two rating
  • qa_pa_rating.xml

4
Motivation (Cont.)
  • Documents that contain multiple markup
    vocabularies pose problems of recognition and
    collision.
  • Software modules need to be able to recognize the
    tags and attributes which they are designed to
    process, even in the face of "collisions"
    occurring when markup intended for some other
    software package uses the same element type or
    attribute name.
  • These considerations require that document
    constructs should have universal names, whose
    scope extends beyond their containing document.
    This specification describes a mechanism, XML
    namespaces, which accomplishes this.

5
NameSpaces
  • Introduced to solve the problem of name conflict!

6
Declaration
  • ltelement xmlnsprefixnamespace_urigt
  • lttitle xmlnsdchttp//purl.org/dcgt
  • Default namespace
  • ltelement xmlnsnamespace_urigt
  • lttitle xmlnshttp//purl.org/dcgt
  • Example namespace_bookmark.xml
  • ltqaratinggt5 stars lt/qaratinggt
  • A prefix is added before each element name
  • A colon separates the name and the prefix
  • The prefixes of default namespace can be omitted.

URI is unique!!!
7
Definition
  • An XML namespace is a collection of names,
    identified by a URI reference, which are used in
    XML documents as element types and attribute
    names.
  • URI references which identify namespaces are
    considered identical when they are exactly the
    same character-for-character.
  • Note that URI references which are not identical
    in this sense may in fact be functionally
    equivalent.
  • Examples include URI references which differ only
    in case, or which are in external entities which
    have different effective base URIs.

8
Names from XML NameSpaces
  • Names from XML namespaces may appear as qualified
    names, which contain a single colon, separating
    the name into a namespace prefix and a local
    part.
  • The prefix, which is mapped to a URI reference,
    selects a namespace.
  • The combination of the universally managed URI
    namespace and the document's own namespace
    produces identifiers that are universally unique.
  • Mechanisms are provided for prefix scoping and
    defaulting.
  • An attribute-based syntax described below is used
    to declare the association of the namespace
    prefix with a URI reference
  • Software which supports this namespace proposal
    must recognize and act on these declarations and
    prefixes.

9
Other Issues
  • namespace_uri is used to identify the definition
    sources of element/attribute
  • rff_ref.xml
  • Different prefixs, but the same namespace
  • Scope a namespace is valid for the element where
    it is declared and all the inside elements
  • scoping.xml
  • A namespace also can be associated with specific
    attributes.
  • attribute.xml

10
Uniqueness of Attributes
  • In XML documents conforming to this
    specification, no tag may contain two attributes
    which
  • have identical names, or
  • have qualified names with the same local part and
    with prefixes which have been bound to namespace
    names that are identical

11
Namespaces and DTD
  • The prefix and the attributes for namespace
    declaration must be declared in the DTD
  • dtd_namespace1.xml
  • dtd_namespace2.xml
  • It is dangerous to declare namespaces in an
    external DTD, because a non-validating parser
    might skip external DTDs
Write a Comment
User Comments (0)
About PowerShow.com