views:

1550

answers:

2

I have seen questions here asking about xsd->actionscript objects, but these seem to require xsd->java->actionscript and is all in source code. Our requirements are a bit different:

  1. receive an xsd during runtime that we have never seen before
  2. Create an instance object based on the xsd
  3. fill in the values of the instance (either from an xml document or user input - whatever)

Anyone know of an actionscript library or tool that would help us accomplish this at runtime? It would be nice if something like this already existed - but we would certainly settle for a library that gave us a programmatic interface to extract information from an xsd schema. Additionally, we would take suggestions on alternate methods to accomplish the same ends.

+2  A: 

Have you looked at the SchemaLaoder...? Not EXACTLY what you're looking for ... But a great start.

First - you should check this blog entry and this blog entry which walks you through Dominic De Lorenzo experiences with utilising functionality within the Flex SDK that provides the automatic mapping of custom ActionScript classes to element definitions within an XML Schema (XSD).

The steps to get moving here include (from Dominic's blog):

0) Create an instance of SchemaLoader and asynchronously load an XML schema from a given URL
1) Once the schema is loaded, add it to the SchemaManager and register any ActionScript classes to their corresponding schema type

---- At this stage you can do several operation based on the schema

2) Load an XML file based off that schema
3) Once the XML is loaded, decode the contents using XMLDecoder. Any classes registered in the schemaTypeRegistry will be used when decoding the xml
4) Encode a custom ActionScript class back into XML using XMLEncoder. XMLEncoder.encode() supports various ways to define the corresponding element in the schema (top level element, a specific type or even a custom XSD definition) that will be used to encode the Actionscript object.

The blog entry has links to code samples, etc...

Hope this helps.

Gabriel
Ahhh - thanks for this information. Awarding you the gold star!
Shane C. Mason
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 ::..
ria.mnm.it/blog

Gonte - The RIA Team