A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: For Vaykent, Tupps and all Flash/XML heavies

  1. #1
    ...in human form
    Join Date
    Aug 2002
    Posts
    188

    For Vaykent, Tupps and all Flash/XML heavies

    So I was thinking of developing a Flash component for XML dtd's. It reads a xml doc. Determines the DTD and parses accordingly to capture the information logical for the DTD.

    The second project would to be reverse the process to write XML from flash based on a DTD.

    I know it's possible, but I'd need a lot of help.

    My reasoning is work related. I do library application development. As you can imagine in the library there are a lot of protocols including for document encoding. We definitely use a lot of public dtd's and I'd assume a lot of business do as well. A flash component to handle them would be beautiful for presentation of content.
    Incarnations

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112
    You're right - it would be nice... but DTD's are not XML based - so you'd need to do straight string processing... and that can get cumbersome in Flash. It's much faster now with MX than it was with F5... but still...

    Count me in on the project though... sounds like fun!
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

  3. #3
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Yeah I know the issue with the DTD's not being XML is the big hurdle. The issue is getting Flash to understand the definitions in the DTD. In effect you either have to hardcode the DTD into flash before hand, or convert the DTD into an XML readable format which Flash can interpret. I'm kind of partial to the latter as this kind of solve could conceivably work for all DTD's. What it adds though is a backend step to convert the DTD, or having preexistant converted DTD's on a public server.

    + Flash loads a valid XML document.
    + Flash identifies the corresponding DTD/rules.
    + Flash either -
    1) Refers to the DTD path in the document and executes a script which converts that DTD into DTDXML.
    or
    2) Recognizes the DTD and pulls the DTDXML from a public server.
    + The DTDXML tells flash how to interpret the nodes of the XML document.
    + Flash converts the XML into logical arrays based on the DTDXML.

    I'm not sure which of the two options would be the best for this. I'm a bit leary about option one only because it leaves a lot of room for error in conversion. Option two requires doing the conversions manually, but in the end, you should be able to guarantee that the conversions will work.

    I'm going to try and contact Arul over at Shockwave India to see if he'll pitch in on this. He's done some pretty great things with Flash and XML. Thanks for coming in on this.
    Incarnations

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112
    Have you tried to find XMLSchema versions of the DTDs you use?

    XMLSchema is an XML based syntax, so it might work out easier for you...
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

  5. #5
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Just found this which may be of use -
    http://www.thaiopensource.com/relaxng/dtdinst/#format
    Incarnations

  6. #6
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    XML Schema could work but finding them for the various dtd's is very difficult. Here's a few more thoughts.

    What flash needs to know is what node name's mean. When flash parses an XML document everything is generic. So unless the coder knows the xml they have to hardcode how to handle any XML they load. This is why so many flash programmers will just build their own schema for their xml files and not even worry about validation.

    If flash could recognize that an xml document that opens with a docbook declaration has book elements, and author elements with corresponding attributes, when flash parsed this information it could do so in a somewhat logical manner, like an array for each page of the book.

    On a simple flash exclusive model I was thining about a set of swf component files for various dtd's. When flash loaded an xml file it would check its declaration then load the corresponding swf. That swf would then tell flash what elements to look for in recursion and how to organize them. I'm inclined to go back to this model for its simplicity.

    I'm going to begin with docbook as it is a pretty straight forward example. Just as a hint as to the direction I'm headed, if I can get it working for docbook, I'd like to try for xhtml. Hopefully you're thinking what I'm thinking on that.
    Incarnations

  7. #7
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    What would be the advantage to using a DTD. I typically use them when I want to ensure that the XML file conforms to a certain specification.

    I don't see how an application developer can build an app to read the DTD and then find the correct elements, this would still have to be coded into the app. (I am not saying it can't be done, I just don't see how/why)

    I would definately agree that DTD or XML Schema support for writing XML documents could be quite usefull.
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  8. #8
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112
    I would want it just to get general entities.

    ... default attributes... things like that.
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

  9. #9
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    here's a theoretical line of code -

    Code:
    theXML = new XML;
    theXML.ignoreWhite = true;
    theXML.onLoad = function(){
      getDocType();
    // returns the dtd of the loaded xml.
      convert(dtd);
    // does a recursive function based on the dtd in which it searches through the document for certain tags and attributes, pulling them out and naming them logically.
      display(dtd);
    // provides a presentation of the data in the logical manner suggested by the dtd.
    }
    theXML.load("myxml.xml")
    See now I think flash can handle this by itself if you coded out the key searches for the dtd. surely this alone could be beneficial.
    Incarnations

  10. #10
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Okay, so instead of docbook I chose teilite. attached is a simple array structure for the elements in teilite with the parent and children for each element. I didn't do attributes yet because there was no easy way to do it besides manually typing each element, and doing the parent and children was tiring enough for one sitting. Anyway I figure this will be a good base for testing how flash can work for this. Probably won't get to code any usage until tommorow but I figured I'd share this.
    Attached Files Attached Files
    Incarnations

  11. #11
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    okay, here goes a horrible excuse for a function, which does not work at all but i believe is on the right track for what I'm talking about. any suggestions on where to fix would be appreciated. i altered the tei as a little bit to include the tei2 tag which only has two children text and teiheader.

    Code:
    function validParse(dtd, thexml, level, recordname) {
    	checkthis = thexml;
    	checkpar = thexml.nodeName
    	if (checkpar =="TEI.2"){
    		checkpar="tei2";
    	}
    	checkarray = dtd[checkpar].children;
    	_level0[recordname] = new Array();
    	for (_level0[recordname].level=0; _level0[recordname].level&ltcheckthis.childNodes.length; _level0[recordname].level++) {
    		if (checkthis.childNodes[_level0[recordname].level].hasChildNodes()) {
    			_level0[recordname][_level0[recordname].level] = new Array();
    			_level0[recordname][_level0[recordname].level][checkthis.childNodes[_level0[recordname].level].nodeName] = checkthis.childNodes[_level0[recordname].level].nodeValue;
    			validParse(dtd, checkthis.childNodes[_level0[recordname].level], recordname+level, "_level0["+recordname+"]["+level+"][checkthis.childNodes["+_level0[recordname].level+"].nodeValue]");
    		} else {
    			_level0[recordname][_level0[recordname].level] = new Array();
    			_level0[recordname][_level0[recordname].level][checkthis.childNodes[_level0[recordname].level].nodeName] = checkthis.childNodes[_level0[recordname].level].nodeValue;
    		}
    	}
    }
    Incarnations

  12. #12
    I am of the opinion that you dont need DTDs for this or any other XML project unless you are working with lots of other people/objects. A large scale XML solution may warrant them, but you can just use flash to shape your parsers how you want them. I like to create an object in flash which mirrors the abstract form of the XML doc and then fill all the data into arrays of sub objects and so on. You can also place functions on the object to search and things. assign this object to _global. Then, anywhere in the movie you can make a call like:

    theText = cardCat.getBookID(123.54.234).Author.firstName;

    its sort of an internal DTD

  13. #13
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Thanks for your input matt. That is actually my long range point. That the need for dtd's is decreasing, but, at least in my work environment there's tons of data still in these formats, and when it comes to utilizing them without a way to generally handle a dtd, it comes down to configuring for each document.

    Even more, sharing data requires being able to handle other people's data. If they are using a format which your interface isn't prepared to display you then have to reconfigure for that. What i'm trying to do is have Flash validate the document based on the element list, as it's parsing to ensure that the content is handled logically by flash.
    By example for a large document broken into divisions with different header information, upon parsing flash could recognize those header fields as what should be searchable and thus index the search words for all of the headers before a search having isolated that texts meaning.
    Incarnations

  14. #14
    Yes, I see your point. It may be more than inconvientent to expicitly define each possible DTD in flash, and it would be nice to do this automaticly. Remember however, that unleass all the data represents text, your still gonna need to apply meaning to it at some point. Other than printing out the data to screen in some radable formatt(tree shaped), i dont see how your gonna use a generic DTD. This may well be all you want to do, but you can probably do that w/o a DTD anyway, by looping through the tree. Youve got to know what your getting before hand in order to anything that makes much sense to it

  15. #15
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Well by example in the TEI dtd there are two main elements, teiHeader and text. all tagging fits into these two elements. within the text, it can be broken up by div. in a div, the attribute can tell you what type of division it is. if on parsing flash could recognize the structure, identify the divs and know what type of divs they were it could say that this div, deserves this type of display component. it then could autoload what was needed to display the content in the file just from the xml.load.
    Incarnations

  16. #16
    Well, i suppose if you know enfough about what kind of data your getting you could have several display components that could eventually handle all possibilities. Depending on the diversity of data your expecting this could be quite an undertaking. Ive found that extream encapsulation such as your planning is the most difficult aspect of any programing language. All I can say is this:
    1)good luck, let me know if you get it
    2)time is money

  17. #17
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    just my thoughts on this:

    Although it probably is possible to achieve all this in Flash, for me the structure of this project is a little odd.

    Surely data handling should be done server-side, with Flash acting as a client to display specific data (with a known structure - so no need to use DTDs) fed to it by the server.

    Seems overkill to try and achieve all this in Flash. Yes, it has a built-in scripting language but is that really the best use for it? It seems you have a large scale project - in my opinion it would be wiser to use established industry-standard techniques for handling XML server-side and using Flash only to display the data.

    just my thoughts, to add another side to the debate...

    - n.

  18. #18
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    I agree with you. I mean there are many ways to handle this outside of flash and then pass the data to flash in array's by example. I guess I'm just trying to utilize XML and the XML function in Flash. Seeing that Flash can handle XML, I guess I'm just of the opinion it should handle it well. Unfortunately, it doesn't, which makes it neccessary to manipulate then display the data. I really just wish Macro would build in dtd reading for XML. Since they haven't I have to think up alternatives, wild as they may be.
    Incarnations

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center