views:

1011

answers:

3

Are there any tools available for transforming types defined in an xsd schema (may or may not include other xsd files) into ActionScript value objects? I've been googling this for a while but can't seem to find any tools and I'm pondering wether writing such a tool would save us more time right now than to simply code our value objects by hand.

Another possibility I've been considering is using a tool such as XMLBeans to transform the types defined by the schema to Java classes and then converting those classes in ActionScript. However, I've come to realize that there are about a gazillion java -> as3 converters out there and the general consesus seems to be that they sort of work, ie, I have no idea which tool is a good fit.

Any thoughts?

+1  A: 

I don't have any kind of translator either. What I do is have an XML object wrapped by an ActionScript object. Then you have a getter/setter for each value that converts xml->whatever and whatever->XML. You still have to write the getter/setter though, but you can have a macro/snippit handle that work for you.

So for XML like:

<person>
    <name>Bob</name>
    ...
</person>

Then we have an XML Object Wrapper class and extend it. Normally

class XMLObjectWrapper
{
    var _XMLObject:XML;

    function set XMLObject(xml:XML):void
    {
     _XMLObject = xml;
    }

    function get XMLObject():XML
    {
     return _XMLObject;
    }
}

class person extends XMLObjectWrapper
{
    function set name(value:String):void
    {
     _XMLObject.name = value;
    }

    function get name():String
    {
     return _XMLObject.name;
    }

}
enigmatic
Not really what I was asking for I think, but a very interesting approach none-the-less! Thanks for sharing!
macke
+2  A: 

For Java -> AS generation, check out GAS3 from the Granite Data Services project:

http://www.graniteds.org/confluence/display/DOC/2.+Gas3+Code+Generator

This is the kind of thing you can write yourself too, especially if you leverage a tool like Ant and write a custom Task to handle it.

cliff.meyers
Yeah, I noticed GAS3 just the other day but haven't been able to try it yet. Thanks, I'll accept this as the answer!
macke
Feel free to vote me up, too. LOL :)
cliff.meyers
A: 

Hi everyone, RIA Team is developing XSD-To-AS3 Class Generator, a simple Air app that allow developers to quickly build any Flex/Flash app XML based.

It takes an XML schema and an XML document and uses it to generate a class library. These classes map directly to data contained in your XML Schema, the generated classes is strongly typed, it forms a kind of template for the developer, ensuring that the data created conforms the underlying XML Schema.

It will be very usefull for quickly work with 3th party API RESTful interface!

Try it @Adobe Air Marketplace

..:: The Ria Team ::..
riateam.wordpress.com

Gonte - The RIA Team