简体   繁体   English

验证Flex / actionscript的XML解析器?

[英]Validating XML parser for Flex/actionscript?

Is there a validating XML parser for flex/actionscript? 是否有针对flex / actionscript的验证XML解析器? The XML class verifies that it is well formed XML, but not that it follows the rules of the DTD. XML类验证它是格式良好的XML,但不是它遵循DTD的规则。 Java has a validating XML parser, but is there one for flex/actionscript? Java有一个验证XML解析器,但是有一个用于flex / actionscript吗?

Ok, good news, bad news time. 好消息,好消息,坏消息时间。

First the bad news: Unfortunately, no. 首先是坏消息:不幸的是,没有。 Actionscript does not support any form of DTD validation. Actionscript不支持任何形式的DTD验证。 It also does not support any form of XSL/XSLT validation or transformation. 它也不支持任何形式的XSL / XSLT验证或转换。 There are projects out there which will eventually make some of this possible ( XPath-AS3 for one), but for now you are stuck out of luck. 有些项目最终会使其中的一些成为可能( XPath-AS3为一个),但是现在你已经失去了运气。

But, there is good news (sort of): First, most servers support both. 但是,有一个好消息(有点):首先,大多数服务器都支持这两者。 This means that you could accomplish the same thing in Flash using a round-trip to the server. 这意味着您可以使用往返服务器在Flash中完成相同的操作。 It is, perhaps, less than ideal, especially when dealing with large amounts of information, but it will guarantee consistent results. 它可能不太理想,特别是在处理大量信息时,但它将保证一致的结果。

Second, JavaScript supports both XSL and DTD functionality This means, if absolutely necessary, you have the ability to us ExternalInterface to force the transformations for you (and you could even adapt the JavaScript/HTML abilities on Adobe Air to do the same). 其次,JavaScript支持XSL和DTD功能这意味着,如果绝对必要,您可以使用ExternalInterface强制转换(您甚至可以调整Adobe Air上的JavaScript / HTML功能来执行相同操作)。 This, of course, means that you will need to do even more cross-browser testing. 当然,这意味着您需要进行更多的跨浏览器测试。

Sorry there is no better news. 对不起没有更好的消息。

I haven't heard of a DTD validator yet for as3, but I would like to. 我还没有听说过as3的DTD验证器,但我想。 Meanwhile, can you not pass your xml to a server side script ( php or something ), validate it there and get the result ? 同时,你能不能将你的xml传递给服务器端脚本(php或其他东西),在那里验证并得到结果?

Interesting question though, I hope someone has a magic as3 dtd validation library lying around :). 有趣的问题,我希望有人有一个神奇的as3 dtd验证库躺在:)。

没有内置支持,你必须自己动手或使用现有的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM