What are namespaces in XML?

3

Well, I understand the concept of namespaces in C #, C ++, etc.

But I do not understand the concept of namespaces in WPF (XAML).

I've been trying to understand the xmlns parameters in an XAML code. I read MSDN publications on the subject but frankly I still have not understood the concept of namespaces in XML.

    
asked by anonymous 12.07.2016 / 18:24

1 answer

2

In essence the purpose is to avoid name conflict too, just like C # or C ++. The declaration and import syntax are different, but works in an analog (not identical) way. It remains only a last name for your members .

The idea came from XML. It made a bit more sense to use URIs , after all it is used to exchange data with third parties and the chance of two names of the namesapce themselves are too large. What is the way to ensure that your namespace is unique? Use a name that you have control, that no one else can use an equal (not that there is a prohibition, but there is a convention, who does not follow it or trouble). A name that you have control is a URI with your internet domain. And he's just this, a name. A lot of people think that this is to connect on the internet and get something. Anything! it's just text. Nothing prevents you from using something else, but then the risk of conflict becomes greater.

In XAML, which is used in a more restricted environment, the chance is much lower, but there is still a risk when using third-party components. Anyway, he kept the XML convention.

Often this is a mapping with the namespace of C # code. Example:

clr-namesapce:System.Collections;assembly=mscorlib

I'll leave some references you might not have read and should help:

If you have more specific questions, you can do it individually.

    
12.07.2016 / 18:59