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.
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.
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.
精彩评论