XML Namespaces: Understanding Unique Identifiers for Elements and Attributes, Slides of Information Security and Markup Languages

Learn about xml namespaces, their definition, purpose, and ways to specify them in xml files or dtds. Xml namespaces help distinguish between duplicate element and attribute names, acting as a mapping between an element prefix and a unique identifier. The basics of namespaces and answers common questions.

Typology: Slides

2011/2012

Uploaded on 07/17/2012

panita
panita 🇮🇳

4.8

(6)

43 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Overview
Why do we need Namespaces in XML?
Definition of Namespace.
How do we specify Namespaces?
Questions.
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download XML Namespaces: Understanding Unique Identifiers for Elements and Attributes and more Slides Information Security and Markup Languages in PDF only on Docsity!

Overview

• Why do we need Namespaces in XML?• Definition of Namespace.• How do we specify Namespaces?• Questions.

Why Namespaces?

The purpose of XML Namespaces is to distinguishbetween duplicate element and attribute names.For example:

$$

Both “sedans” and “trucks” have the same “price”element, so the parser doesn’t know which one is which.

Ways to Specify Namespaces

-^

Inside the XML file.

-^

Inside the DTD file.

XML File

Specify a Namespace for every element. <lower:aaa xmlns:lower = “http://website/lowercase”>

<lower:bbb xmlns:lower = “http://website/lowercase”>

<lower:ccc xmlns:lower = “http://website/lowercase” /> </lower:bbb><upper:BBB xmlns:upper = “http://website/uppercase” >

<upper:CCC xmlns:upper = “http://website/uppercase” /> </upper:BBB> </lower:aaa>

XML File

Namespaces do not have to be specified explicitly withprefixes. The attribute

xmlns

defines the default

namespace which is used for the element.

<bbb xmlns = "http://website/lowercase“>

XML File

Attributes can be explicitly assigned a value and beassociated with a Namespace by using prefixes.<lower:aaa xmlns:lower = “http://website/lowercase”

xmlns:upper = “http://website/uppercase”><lower:bbb lower:zz = “11” >

<lower:ccc upper:VV = “22” /> </lower:bbb><upper:BBB lower:sss = “***” /> </lower:aaa>

XML File

A Namespace specification can be overridden

using the

prefixes.<lower:aaa xmlns:lower="http://website/lowercase">

<lower:bbb>

<lower:ccc xmlns:lower="http://website/uppercase">

<lower:ddd>It’s uppercase

now.</lower:ddd>

</lower:ccc> </lower:bbb> </lower:aaa>

DTD File

Here is a sample Namespace specification within a DTD.