472,953 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,953 software developers and data experts.

Xml namespace

Hello!

What is the reason for having xml namespace ?
I know the reason for using namespace in C# but I can't see any similarities
to Xml.

Can you just give a simple example on a Xml document where namespace will
solve the problem.

//Tony
Aug 14 '08 #1
3 1703
Tony Johansson <jo*****************@telia.comwrote:
What is the reason for having xml namespace ?
I know the reason for using namespace in C# but I can't see any similarities
to Xml.

Can you just give a simple example on a Xml document where namespace will
solve the problem.
You want to refer to elements in two different schemas, and both
elements are called "Foo". Namespaces allow you to differentiate.

In other words, it really is the same reason for having them in C#.
Admittedly they're a bit more of a pain in XML...

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 14 '08 #2
It allows you to disambiguate between elements from different sources.
Perhaps more importantly, it allows you to write a compliant xml
document for cases when there is an expectation of namespaces ;-p

But as an example of the first, consider xslt; this uses a namespace
(commonly given the "xsl" alias) to indicate the xsl control statements
from output markup - i.e.

<xsl:choose>...</xsl:choose>

is a control statement (comparable to "switch"), where-as

<choose>...</choose>

(or other namespaces) is markup to be directed to the output stream.
Similarly, consider the <asp:Whatever>...</asp:Whateverin ASP.NET.

Marc
Aug 14 '08 #3
On Aug 14, 11:45*am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
Hello!

What is the reason for having xml namespace ?
I know the reason for using namespace in C# but I can't see any similarities
to Xml.

Can you just give a simple example on a Xml document where namespace will
solve the problem.
An example would be W3C XHTML+MathML+SVG profile (http://www.w3.org/TR/
XHTMLplusMathMLplusSVG/), which allows to use all three languages in a
single document, to represent formatted text, vector graphics, and
formulas. Sample XML using that profile looks like this - note the use
of namespaces used to separate the languages:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML as the host language</title>
</head>
<body>
... XHTML content ...
<math xmlns="http://www.w3.org/1998/Math/MathML">
... MathML content ...
</math>
... XHTML content ...
<svg:svg version="1.1"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
... SVG content ...
<svg:switch>
<svg:foreignObject ...>
<p>
... XHTML content ...
<math xmlns="http://www.w3.org/1998/Math/MathML">
... MathML content ...
</math>
... XHTML content ...
</p>
</svg:foreignObject>
</svg:switch>
</svg:svg>
</body>
</html>
Aug 14 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
6
by: Don Wash | last post by:
Hi There! I just need some advice on Namespace management for creating reusable VB.NET applications. I would like my applications to have this namespace structure... Namespace MyCompany ...
8
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
2
by: puzzlecracker | last post by:
after reading some of the post I found out something rather radical to my previous understanding: that when you do #include<iostream> #include<string> #include<vector> etc compiler puts...
2
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some...
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
14
by: Tiraman | last post by:
Hi , I would like to use nested namespace . I have 3 namespace as dll's : Namespace A Namespace B Namespace C And i want to have some namespace that contain them all , some thing like
2
by: Jeff Brown | last post by:
Hi, I suspect that this isn't possible, but I figured I'd ask. My project has a root namespace, let's say it's "Root", that applies to almost every source file (which is why I've set it as the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.