Question

After reading MSDN-XAML Namespaces and MSDN-Understanding XAML Namespaces, I still do not understand the purpose of having a Qualified Name (QName).

Take the following namespace declaration as an example:

xmlns:x='http://www.w3.org/1999/XSL/Transform'

x is the prefix short for the full URI (in this case, an URL) : http://www.w3.org/1999/XSL/Transform. Then there is this QName called xmlns. The definition for QName in mdsn is:

This complete name including the prefix is the lexical form of a qualified name (QName):

What's that supposed to mean and why is it there since thet statement already has a locator and a prefix to identify the namespace and its names to be used?

Was it helpful?

Solution

I think more than this being an XAML question it is just an XML namespace question.

The xmlns attribute (a special attribute) is just the attribute used in XML to define a namespace. It says "here comes a namespace declaration". If you do not add a prefix, then you are telling it to set the namespace that is the value of the attribute as the default namespace for the page. If you omit in completely the default namespace is then assumed to be the value of the attribute (after the = and between the quotes).

XAML is XML and chooses to use the XML mechanism for declaring namespaces. I guess they could have created their own mechanism for doing it but since they didn't, if you added your namespace as you hint at in your question, without the xmlns:, the app processing the XML (the .NET framework in this case, parses the XAML file) would not know you were trying to define a namespace; it would think you were adding an attribute called "x" to the element it was defined in (which would most likely not be an attribute that is defined for that element).

For more about XML namespaces

http://www.w3.org/TR/REC-xml/

http://www.w3schools.com/XML/xml_namespaces.asp

http://en.wikipedia.org/wiki/XML_namespace

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top