Author Topic: EasyExtension DTD  (Read 2498 times)

RainCT

  • Guest
EasyExtension DTD
« on: 10 May 2007, 18:36:35 »
Hey!

If you don't know it, easyExtension is a way to package Glest extensions to make them easy to distribute and install. Those can be installed using a program done in Python (development info about it here).

EasyExtension Packages can be either compressed as .zip, .tar.gz or .tar.bz2 files, and they have to include a .xml file, with the same name as the package (for example, on a MyCoolExtension.zip it would be named MyCoolExtension.xml), where it tells that installer what to do. That file has to validate with the easyExtension Document Type Definition; the structure it has to follow is what will be explained on this thread.



XML Header
At the top of the .xml file there have to be exactly this two lines, to tell that it's a easyExtension XML:

Code: [Select]
<?xml version='1.0'?>
<!DOCTYPE extension SYSTEM 'easyExtension.dtd'>



Extension Start
After the XML header, a line like this must be there to tell what the extension is about:

Code: [Select]
<extension type='easyExtension' version='1.0' name='Sample Extension' extversion='1.0' author='MyName'>
Type: Just leave that at "easyExtension".
Version: That's the version of easyExtension, leave it at 1.0.
Name: Write here the name of your extension.
Extversion: The version of your extension (it should look like: 1.0, 1.0.0.1, 0.1, etc.)
Author: Your name (of who created the extension)



Extension Description
After that, you can and should, but don't need to, write a description about it. That looks like:

Code: [Select]
<description>Just a sample extension. This description is optional.</description>


Require - Depending on other Extensions
Now many 'require' entries can be placed here, but generally you will just ignore that. Require is thought for the case you want to make a extension depending on another one; in this case you can tell it to look after one or more files and abort the installation process if they aren't there. That looks like:

Code: [Select]
<require file='factions/magitech/tech/lkjsd/awdf.xml' need='true' />
File: Easy, that's just the path to the file (from inside the Glest directory) you want to look after.
Need: This can be "true" or "false". If it's true, it will abort if the file doesn't exists; if it's false, it will abort if the file exist! This last one is to avoid the installation of the extension if another incompatible one is already installed.



Doing all the work
Now it's time to explain the real work. You will use 'copy' and 'file' (with it's child 'search') for that.


Code: [Select]
<copy to='factions/magitech/tech/whatever/bla'>newfolder</copy>
With that code (above) you can let it copy a file, or even a complete folder, to some place on the Glest folder. Write the destination folder on the 'to' argument, and the path inside the compressed file of whatever you want to copy between copy's open and close tags.


Code: [Select]
<file name='factions/magitech/tech/bla/ble/bli.xml'> ... here one or more operations ... </file>
This one tells it to open a file and do some operations with it. The path of the file should go on the parameter 'name', and at least one operation between file's tags. Those operations are done with that:

Code: [Select]
<search add='before'>
            <target>This is line 21</target>
            <bullet>Now this is line 21. The target is now line 22.</bullet>
</search>


You can assign the 'add' parameter either 'before', 'after', or 'replace'. 'Before' will search for the line given in 'target' and add the text from 'bullet' before it; 'after' should be clear now. If you use 'replace', that will replace those lines that look like 'target' with the content from 'bullet'.
« Last Edit: 1 January 1970, 00:00:00 by RainCT »

 

anything