PDA

View Full Version : validating xml for actionscript


trishtren
03-25-2012, 11:59 AM
Hello,
iv been working on a data application using xml, but when i try to validate it and load it into actionscript it fails. Although this is in large part an XML problem im hoping someone can shed light on it, as every other forum iv tried no one ever replies :p.
Im using an xml file and external dtd and when i load it into actionscript i am present with the error :

XML Declaration not well formed
Extra content at the end of the document.

The DTD is as follows:

<?xml encoding="UTF-8"?>
<!ELEMENT Sword (Damage,Accuracy,Range)>
<!ELEMENT Damage(#PCDATA)>
<!ELEMENT Accuracy(#PCDATA)>
<!ELEMENT Range(#PCDATA)>
<!ATTLIST Sword Name CDATA #IMPLIED>

The XML is valid and well formatted, which is why i am confused of the error i recieve.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Module SYSTEM "sword.dtd">
<Sword Name="cleaver">
<Damage>4</Damage>
<Accuracy>10</Accuracy>
<Range>5</Range>
</Sword>

Any help finding why i receive these errors from my dtd would be helpful as evey xml forum seems dead.

The file works perfectly if i use an internal dtd however i was planning to just reuse the dtd and thats why i am trying an external, so any help figuring this one out :)

anx
03-26-2012, 02:40 AM
ha the good news is your right it looks all kosher but the bad news is flash/actionscript doesn't support DTD or any xml validations for that mater such as XSLT and such as flash takes xml as raw data your internal application would then need to manage the rules.

if its critical for the operation you can have that done in Javascript or on the server and then send the file just as xml when its in flash.