Design of a Scripting system using XML

ErorcecaspZes

New Member
I've built a system that parses a XML file into a Script class (described above). That file contains information about the scripting language (Javascript, Python etc) that is being used and the code it should run.Then, I've built another system that runs a Script class, using the name and version provided, I can detect the correct engine to be used. Finally, after thinking and thinking of how to solve my problems, I failed to achieve so, therefore I ask your help.Let me show you the current design\[code\]class Script { String content; Language language; class Language { String name; String version; }}class Effect { Script initial; Script final;}class Usuable { Script onUse; Script onHit;}\[/code\]Necessities:
  • I want to be able to work with multiple languages and versions.
  • An Effect class therefore contains 2 Script classes instances. Those scripts are run multiple times.
  • The same applies for the Usuable class.
  • Scripts on the Usuable class may be the same of the ones used on Effect.
  • A Script may call another script while running.
  • Scripts should be able to recieve parameters to work with.
Changeable:
  • Effect, Usuable and Script classes are loaded from XML files.
I've seen the necessity of separating the Script from inside the Effect (on the XML files), so I've decided to use ID's on those root nodes, so I can load the correct files. So the Script class gains an ID attribute, and in the Effect and Usuable XML files only stores the ID's for those Effects.Now, to pass parameters to a script code located inside a XML file and run other Scripts, I've found no good solution, and I think that the problem is the solution I've come up. I wanted to avoid externalizing the code to the XML by creating Parameter elements in the Script XML files.So, I've imagined that I could load the Scripts classes, and the code inside them should be a function, that could be called. But I've not found a good way to keep up the references.[*]Is that approach correct? If you can't answer that, do you like it or think it's good?[*]Is it a good approach to store scripts in XML files? I've seen many other applications that simply put the script files in a ZIP file, and supouse they were made for the current version, but I cannot affort to trust that.[*]How can I keep up with the references? I don't know a good way to generate the ID's, so they can pass information like a function name does.[*]If I apply that last idea I've come up with, would it be good to name the functions with it's ID's?Edit: I'm adding the conversation of this same question that I posted somewhere else.\[quote\] Without stepping off of the deep end because this is a potentially HUGE topic
 
Back
Top