如何从XSD架构ActionScript对象(Flex的),在运行时去?架构、对象、XSD、Flex

由网友(人心易碎i)分享简介:我已经看到了questions在这里询问xsd->动作的对象,但这些似乎需要xsd-> Java的>动作,是所有源$ C ​​$ C。我们的要求是有点不同:在运行过程中收到一个XSD,我们以前从来没有见过创建基础上,XSD一个实例对象填写实例的值(无论是从XML文档或用户输入 - 无论)任何人都知道一个动作库或工具...

我已经看到了questions在这里询问xsd->动作的对象,但这些似乎需要xsd-> Java的>动作,是所有源$ C ​​$ C。我们的要求是有点不同:

在运行过程中收到一个XSD,我们以前从来没有见过 创建基础上,XSD一个实例对象 填写实例的值(无论是从XML文档或用户输入 - 无论)

任何人都知道一个动作库或工具,将帮助我们做到这一点,在运行时?这将是很好,如果这样的事情已经存在 - 但我们肯定会满足于给了我们一个编程接口来提取XSD架构信息库。此外,我们将采取建议的替代方法来达到相同的目的。

解决方案

你看的SchemaLaoder ... ?您正在寻找不完全是为......但是一个很好的开始。

首先 - 你应该检查这个博客条目和的这个的博客条目,它指导您完成多米尼克·德洛伦佐经验使用Flex SDK提供的自定义ActionScript类的自动映射为XML模式中的元素定义(XSD)。

之内使用的功能

步骤获得正朝这边包括(来自多米尼克的博客):

0)创建SchemaLoader的实例,异步从给定的URL 加载XML架构 1)一旦方案被加载,将它添加到SchemaManager和注册任何ActionScript类到其对应的模式类型

----在这个阶段,你可以根据架构做一些操作

2)基于加载关闭该模式的XML文件 3)一旦XML被加载,德$ C C使用XMLDe codeR内容$。当解码XML 在schemaTypeRegistry注册的任何类将被使用 4)恩codea的自定义ActionScript类转化成XML格式使用XMLEn codeR。 XMLEn coder.en code()支持各种方式来定义该模式中的相应元素(顶级元素,特定类型或甚至自定义的XSD定义),将用于对连接code中的ActionScript对象。

博客条目链接到code样品等...

希望这有助于。

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:

receive an xsd during runtime that we have never seen before Create an instance object based on the xsd 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.

解决方案 Flex3技术开发 ActionScript3.0

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.

阅读全文

相关推荐

最新文章