views:

25

answers:

3

When you create a new silverlight page, you get a number of xml namespaces auto created in the user control tag. Eg -

<UserControl x:Class="QuickStart.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d"
   d:DesignHeight="300" d:DesignWidth="400">

I know that xmlns has the core silverlight tags, :x has xaml language elements, :d has expression blend stuff etc. My question is this - does silverlight actually make a call to the defined schema UIs either during design or run-time? I can't imagine that it is going out to schemas.microsoft.com every time it renders a page. But if not, are the URIs effectively just constants?

+1  A: 

No, it does not go out to microsoft.com (those folders don't even exist), and yes, that makes these basically constants.

500 - Internal Server Error
+4  A: 

XML namespaces are URLs, but in most cases, they don't correspond to actual websites, or documentation or anything. They basically serve to provide a unique identifier for XML elements, as long as everyone cooperates an uses a domain name that they own as part of the URL. In the early days, whoever came up with using URLs for xmlns's may have intended for people to post documentation at the URLs, but nobody really does that.

XML parsers do not visit these URLs at any point, they are basically just identifiers.

Andy White
It's generally considered polite to put *something* useful to humans at a namespaceURI, and many do, but not Microsoft. (For some reason, their openxmlformats.org domain kicks me out to an advertisement for XBoxes at MSN Entertainment. In Spanish. Handy.)
bobince
+1  A: 

Your question has already been answered, but nobody mentioned why they are used.

Not mentioned is that you can also specify a namespace via an assembly reference, but that would mean you would need one namespace per assembly. The Silverlight libraries are spread out over multiple assemblies (more than just the example xmls entries above indicates).

Using a "constant" as you rightly call them as the namespace means that multiple assemblies can be referenced with a single shared namespace.

This saves on a large number of separate xmlns entries, but does introduce the problem of figuring out what assemblies a namspace refers to if you only have the page source :)

Enough already