Flex is a very powerful Framework for RIA development. You can write mxml files in xml syntax and compile them to Flex-Applications using mxmlc (mxml compiler) shipped with Flex-SDK. Eclipse (and many other Editors can handle XML-Files) provides code-completion for XML-Files once you have specified a XML-Schema or DTD. Editors with code-completion accelerate the learning process and speed up the development.
Unfortunately there is nowhere a XML-Schema for mxml since Flex 2 (except http://code.google.com/p/xsd4mxml/ ;-) ). The solution is to write some ActionScript classes to generate the XML-Schema.
To do this you need the list of components, which should appear in the XML-Schema. Either extract this from each catalog.xml file located in swc files in <FLEX_HOME>/frameworks/libs directory or simply take the <FLEX_HOME>/frameworks/mxml-manifest.xml file which contains the same information allready.
catalog.xml
...
<component className="mx.collections:ArrayCollection"
name="ArrayCollection" uri="http://www.adobe.com/2006/mxml" />
<component className="mx.collections:ListCollectionView"
name="ListCollectionView" uri="http://www.adobe.com/2006/mxml" />
<component className="mx.collections:Sort"
name="Sort" uri="http://www.adobe.com/2006/mxml" />
<component className="mx.collections:SortField"
name="SortField" uri="http://www.adobe.com/2006/mxml" />
...
mxml-manifest.xml
...
<component id="Accordion" class="mx.containers.Accordion"/>
<component id="AddChildAction" class="mx.effects.AddChildAction"/>
<component id="AnimateProperty" class="mx.effects.AnimateProperty"/>
<component id="Application" class="mx.core.Application"/>
...
!Notice! your generator application should include the libraries contains the component.
Once you have a List of components, actually a XML-File with full qualified class names, you can use flash.utils.getDefinitionByName()
and flash.utils.describeType()
functions to reflect the information needed to generate the XML-Schema. This functions doesn't deliver all information you need to generate the XML-Schema because of the default compiler options in <FLEX_HOME>/frameworks/flex-config.xml. You should edit the flex-config.xml and append following
lines.
...
<keep-as3-metadata>
<name>Bindable</name>
<name>Managed</name>
<name>ChangeEvent</name>
<name>NonCommittingChangeEvent</name>
<name>Transient</name>
<name>Event</name>
<name>Style</name>
</keep-as3-metadata>
...
http://code.google.com/p/xsd4mxml/
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI8MOuswvq2eCcOwADN9JF1zh7wHYoZeHHQpBo_0frWBctz_3wyry88Ea0gpBuOm_r9RSxLyv5x4xYu2giKixBveF6Vmno6P-tkHVMKpURxU13oqzaEsagMYwuAiX2dDezhG1CwJmx_hM/s320/element.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgioVhnHHuhUIaMdmGrYvet37kmehgZUU6Nyw0fZqkYR97HekmEtivPA0MNg0Jx69_3OdFbnrgh5bzBvJ3rPXjl-gyOLd207pICqKokiYkZn2CsuoagTJXbQleO1RHu2dMhYivzHTY_C18/s320/attribute.png)
To be continue...