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/
To be continue...
2 Kommentare:
hi Ali, thank you for your project. i added mxml support to my eclipse plugin today with your schema (http://axdt.org/changeset/58). i put it to the update site in a couple of days.
lots of thanks to you and my best regards
mb0
Hi, I used your generator as base for my Relax NG Generator. Thank you very much, now it's possible to load the schema in emacs, which helps a lot for mxml editing. Look at my blog post for more information.
Kommentar veröffentlichen