Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL references in namespaces, how do they work?

I understand regular XML namespaces such as:

 xmlns:myExample="clr-namespace:WindowsApp.MyNamespace;assembly=MyAssembly"

But I often times see namespaces of the form:

 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

What do these URL namespaces mean? The URLs don't work when I type them into my browser; does anyone know how this works? Thanks in advance.

like image 911
Shai UI Avatar asked May 06 '11 16:05

Shai UI


People also ask

Why are namespaces URLs?

URL namespaces allow you to uniquely reverse named URL patterns even if different applications use the same URL names. It's a good practice for third-party apps to always use namespaced URLs. Similarly, it also allows you to reverse URLs if multiple instances of an application are deployed.

What is the URL in XML namespace?

The Namespace starts with the keyword xmlns. The word name is the Namespace prefix. The URL is the Namespace identifier.

How do XML namespaces work?

An XML namespace is a collection of names that can be used as element or attribute names in an XML document. The namespace qualifies element names uniquely on the Web in order to avoid conflicts between elements with the same name.

How does namespace work in C#?

The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types. namespace SampleNamespace; class AnotherSampleClass { public void AnotherSampleMethod() { System. Console.


2 Answers

See this page on MSDN and the relevant attribute: XmlnsDefinitionAttribute

This attribute is used for clr-mapping by the XAML processor, it allows mapping one or multiple clr-namespaces to a single xmlns and it can be defined in the assembly info.

like image 114
H.B. Avatar answered Sep 20 '22 02:09

H.B.


As John Saunders said, the namespace is the URL. The fact that it's a URL is misleading. The namespace is identified by a URI (of which URL is a subset). The URI is treated as a string. Two namespace identifiers are equal if and only if the strings are equal, so all three of these represent different namespaces:

  • http://www.example.org/~wilbur
  • http://www.example.org/%7ewilbur
  • http://www.example.org/%7Ewilbur

(The example is from the spec: http://www.w3.org/TR/xml-names/)

The namespace serves (as namespaces do) to enable the same name to refer to different things. Thus, you can write XML like this (assuming you have declared namespace prefixes legacy and newSystem):

<newSystem:Type newSystem:TypeName="Customer" newSystem:TableName="Customers" legacy:TableName="cstmr" />

The two TableName elements refer to different things because their namespaces are different.

like image 20
phoog Avatar answered Sep 18 '22 02:09

phoog