Xml - Namespace (xmlns)

Card Puncher Data Processing

About

namespace in XML 1) are used to be able to have the same node name but in different namespace.

Example

A simple example would be to consider an XML document that contained references to:

  • a customer
  • and an ordered product.

Both the customer element and the product element could have a child element named id (for identifier).

References to the id element would therefore be ambiguous; placing them in different namespaces would remove the ambiguity.

<xml xmlns:c="https://domain.com/customer" xmlns:p="https://domain.com/product">
   <c:id>The customer id</c:id>
   <p:id>The product id</p:id>
</xml>

Usage

XML namespaces are used mainly for providing uniquely named elements and attributes in an XML document.

For a schema vocabulary, the XML namespace provides a naming context for:

  • named type definitions,
  • named model groups,
  • global element declarations
  • and global attribute declarations

The namespace mechanism defines custom namespaces in which the non-standard elements and attributes are supported.

Syntax

A namespace name is a uniform resource identifier (URI) and is declared using the reserved XML pseudo-attribute:

  • xmlns: to define the default namespace
  • or xmlns:name: to define a namespace where name is the unique namespace identifier (called also a prefix).

For example, the following JSF tag library declaration maps the h prefix to the http://java.sun.com/jsf/html namespace uri.

<xml xmlns:h="http://java.sun.com/jsf/html" >

http://java.sun.com/jsf/html doesn't represent a web page, it's just an unique identifier

Default

The default namespace of a document is defined without the name.

Example for an XHTML document

<html xmlns="http://www.w3.org/1999/xhtml">





Discover More
Eclipse Wtp Installation Update
Eclipse - How to consume a web service (OBIEE) with WTP ?

The aim of this article is to show how with WTP, the Web Tools Platform Plugin of Eclipse, you can consume a web service. All the details the Web Service Subproject can be found on this page....
Java Conceptuel Diagram
Java - Axis (Web Services / SOAP / WSDL engine)

Axis is a Web Services client generation engine. Download the binary distribution And unzip it Add the bin directory in the path Set...
Jndi Name Data Source Netbeans
Java - Java Naming and Directory Interface (JNDI)

JNDI is an interface describing naming and directory functionalities. It provides applications with methods for performing standard directory operations, such as: associating attributes with objects...
Java Conceptuel Diagram
Java XML - Java API for XML Processing (JAXP)

API JAXP (Java API for XML Processing) is an umbrella term that bundle the various low-level XML APIs in JavaSE. ie the parser standards javax/xml/parsers/package-summaryParsers Package (javax.xml.parsers):...
Card Puncher Data Processing
Language - Namespace (Scoping rule for name)

in code. namespace. Completely related to the notion of scope. See File System Dynamic Language: . php definition: In the broadest definition language.namespaces.rationalenamespaces are...
Chrome Devtool Selector
Selector is pseudo-class

:is() is a matches-any logical pseudo-class that takes a selector list as its argument. matches any element that is being hovered or focused, regardless of its namespace. represents only...
Card Puncher Data Processing
XML - Element

Each XML document contains one or more elements, the boundaries of which are either delimited by: start-tags and end-tags, or, for empty elements, by an empty-element tag. The element structure...
Card Puncher Data Processing
XSLT - Namespace

The XSLT namespace has the URI . It is used to identify elements, attributes, and other names that have a special meaning defined in this specification. Normally,...
Card Puncher Data Processing
XSLT/XPath - (Data|Document) Model

Like the Document Object Model (DOM), the XSLT/XPath data model consists of a tree containing a variety of nodes. The XPath specification defines an abstract document model that defines seven kinds...
Card Puncher Data Processing
Xml - Infoset

The XML Infoset: is a tree-based hierarchical representation of an XML document. is the abstract data and metadata (ie abstract means independently of this representation, independent of the actual...



Share this page:
Follow us:
Task Runner