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.
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.
The Namespace starts with the keyword xmlns. The word name is the Namespace prefix. The URL is the Namespace identifier.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With