AngelScript over XML

Started by
12 comments, last by abrken 18 years, 5 months ago
Quote:Original post by WitchLord
Can the XML comments include XML special characters like < > & " etc? Or do you have to escape them?



In comments, the only thing that isn't allowed is -- and even that is only for compatibilty (probably with sgml). --> ends the comment, so your comments obviosuly can't contain that either

Advertisement
Quote:Original post by WitchLord
Can the XML comments include XML special characters like < > & " etc? Or do you have to escape them?


Quote:Original post by evolutional
You'd use CDATA sections in the XML to contain your script, this essentially tells the XML parser to 'switch off' parsing until the end of the CDATA section.


The XML parser is an inhouse one. It allows < or > or even -- in comments.
It just scan for "-->" for getting the end comment.

First I wanted to implement the code in a CDATA section (as quasar3d has suggested) but our inhouse XML parser would have too been too many modified, and as I'm a little lazzy, the comments jusst has done the trick !

So I'm trying to insert a sample ...

<XPNTree>	<CUSTOM>		<version>1</version>		<author>abrken</author>	</CUSTOM>	<COMMON>		<CODE Name="thefunc" Pure="1"><!--// -------------------------// Global Function : thefunc// -------------------------int thefunc(){	return i--;}--></CODE>		<CODE Name="GLOBAL" Pure="1"><!--// ------------------------// Global Function : GLOBAL// ------------------------int i = 0;--></CODE>	</COMMON>	<PAGE Default="1" File="Animation.xml" Name="page1">		<TIMEOUT Elapse="1">			<NAV Name="page2"/>		</TIMEOUT>		<OnBeforeStart><!--// ----------------------------------------// page1 : 2) Avant Démarrage Visualisation// ------------------------------------------></OnBeforeStart>		<MOUSE>			<CIRC Coord="0351,0220,0146,0393">				<EXEC><!--// Add Your AngelScriptCString csFichier;Presenter.FileDialog(true, "Selection fichier", "*.txt", "",  "Fichiers Text (*.txt)|*.txt||", 0, csFichier);--></EXEC>			</CIRC>		</MOUSE>	</PAGE>	<PAGE File="Animation.xml" Name="page2">		<TIMEOUT Elapse="1">			<NAV Name="page1"/>		</TIMEOUT>		<OnBeforeStart><!--// ----------------------------------------// page2 : 2) Avant Démarrage Visualisation// ------------------------------------------></OnBeforeStart>	</PAGE></XPNTree>
You've given me some good suggestions that I think I'll be using myself when I get that far in my game project. I wasn't aware of the CDATA section before evolutional mentioned it, but this would be the perfect solution. Now I know what to answer when others ask about how to combine XML and scripting. [smile]

For everyone's information, here's an example of a CDATA section (from W3Schools.com):

<script><![CDATA[function matchwo(a,b){if (a < b && a < 0) then   {   return 1   }else   {   return 0   }}]]></script>


Doing it the way abrken does it also work, though I'd prefer using the CDATA section as that is part of the XML standard so that common XML editors can be used without problems to edit your scripts.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

About editing, rather you choose CDATA (that is best appropriate) or XML comment, the result is an xml file that will be easely edited with some xml editor, but ... none of them will understand your script. you'll then have to "compile" the xml file and check for errors and so.

The better is to write your own editor.

If you do not take time to write an editor you will endup loosing your time in xml editing/application compiling and finally, all of the time in addition would have been the time to write your own editor.

This is just my point of view taken from a real project ;)

Regards,

AbrKen.

This topic is closed to new replies.

Advertisement