View Full Version : Basic Namespace question
salim_designer
11-28-2007, 05:07 AM
Why do we use (xmlns:mx="http://www.adobe.com/2006/mxml")
If we create any component then we use an xml name space to use that component but we know that all the flex components are in the mx namespace, which is already in our system, so why should we use (xmlns:mx="http://www.adobe.com/2006/mxml"). Even if I am working offline the flex application works fine with (xmlns:mx="http://www.adobe.com/2006/mxml"). I am really confused at this.
Please help me.
dr_zeus
11-28-2007, 06:08 PM
If you go to http://www.adobe.com/2006/mxml in your browser, it doesn't really exist. Nothing is ever loaded from there. It's merely the accepted standard that namespaces are in the form of a URL. It's sort of like packages (com.adobe.*).
nmduc073
11-29-2007, 04:47 AM
Is it OK if I change to http://www.mysite.com/2006/mymxml?
salim_designer
11-29-2007, 04:54 AM
It's sort of like packages (com.adobe.*).
Thank you for your reply but I am still not getting it clearly.
If it is a package then how does it work when I work offline?
dr_zeus
11-30-2007, 06:42 PM
Is it OK if I change to http://www.mysite.com/2006/mymxml?
If you create your own components, and package them up into a SWC, you may put them in that namespace. You cannot change the namespace of Adobe's components.
dr_zeus
11-30-2007, 06:52 PM
Thank you for your reply but I am still not getting it clearly.
If it is a package then how does it work when I work offline?
I think you misunderstand what I mean by "package". In ActionScript, mx.controls.* is known as a package. Likewise, com.adobe.serialization.* is a package that looks a lot like a backwards URL. That's the convention that is generally accepted for package names. As you probably know, packages exist to put related classes together under a unique name so that your classes and another person's classes can exist independently.
XML namespaces are very similar. They provide a way to uniquely identify XML elements. The value http://www.adobe.com/2006/mxml is simply a unique string that Adobe uses to identify the components in the Flex framework. Alternatively, they could have chosen the string "Adobe's Unique Flex Identifier" and it would still be a legal namepace. It's not a real URL, and your Flex application will never load any data from there.
For more information, read about XML Namespaces (http://en.wikipedia.org/wiki/XML_Namespace)
Here's the relevant explanation from the article:
Note, however, that the URI is not actually read as an online address; it is simply treated by an XML parser as a string. For example, http://www.w3.org/1999/xhtml itself does not contain any code, it simply describes the xhtml namespace to human readers. Using a URL to identify a namespace, rather than a simple string (such as "xhtml"), reduces the possibility of different namespaces using duplicate identifiers. Namespace identifiers need not follow the conventions of web addresses, though they often do.
salim_designer
12-03-2007, 06:43 AM
Got it, Thank you very much :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.