XML in MODs?

Want to share what MODs you've gotten to work with EM? Happy about all the time your're saving? Want to say "thanks"? Here's the place.
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

XML in MODs?

Post by iliasch »

I'd like to think noone has thought about it yet, but it may be a good solution to several problems... read on please, this a long post and I'm sorry I couldn't make it shorter :)

Here is an example of what an XML MOD could look like (an XML MOD Template if you prefer):

Code: Select all

<mod>
 <name>ModName</name>
 <version>1.0.0</version>
 <author>ModAuthor</author>
 <description>ModDescription</description>
 <main>
  <copy source="SourceFile1" dest="DestFile1" />
  <copy source="SourceFile2" dest="DestFile2" />
  <copy source="SourceFile3" dest="DestFile3" />
  <copy source="SourceFile4" dest="DestFile4" />
  <sql>sql1</sql>
  <sql>sql2</sql>
  <sql>sql3</sql>
  <sql>sql4</sql>
  <edit file="filename1">
   <find>
    <line>
     <value>FindLine1</value>
     <value>FindLine2</value>
     <value mode="repeat" mark="0"></value>
     <value>FindLine3</value>
     <value>FindLine4</value>
    </line>
    <after>
     <value>Line1</value>
     <value>Line2</value>
     <value>Line3</value>
     <value>Line4</value>
    </after>
    <inline>
     <value>FindWord1</value>
    </inline>
    <in_after>
     <value>InsertWord1</value>
    </in_after>
   </find>
  </edit>
  <save />
 </main>
</mod>
On first site it looks ugly I know, but those that have got in touch with XML will probably know its potential. This is especially true for EasyMOD.

Here are some "pros" I can think of right now:

- <name>ModName</name>: EasyMOD will know exactly where to look for header info, no more "slow" pattern matching OR mismatching.

- <copy source="SourceFile1" dest="DestFile1" />: No more "whitespace" limitations, or syntax requirement (copy X to Y).

- <edit file="filename1">: Actions are grouped per file, so you can easily tell where its action belongs.

- <find><line><value>...</value></line><after ... /></line></find>: Nested commands allow you to easily skip to the proper place if a FIND action fails! No more guessing...

- <value mode="repeat" mark="0"></value>: Last, but not least, this is something that a lot of MOD authors have been waiting for! Passing parameters such as "mode" and "mark" as indicated you can have the effect you wish! In this case you're telling EasyMOD that the specific (empty) line can exist multiple times, not just once. Furthermore, "mark=0" tell EasyMOD to ignore those lines, ie work as if they did not exist. If the next action is replace, those lines will NOT be replaced.

Here is an example from Ptirhiik's Categories Hierarchy:

Code: Select all

#
#-----[ FIND ]------------------------------------------------
#
			'FORUM_NAME' => $forum_name,

			'L_FORUM' => $lang['Forum'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			'FORUM_NAME' => $forum_name,

//-- mod : categories hierarchy 
//-- delete
//			'L_FORUM' => $lang['Forum'],
//-- add
			'L_FORUM' => ( $cat_id > 0 ) ? $lang['Category'] : $lang['Forum'],
//-- fin mod : categories hierarchy
He has to FIND and then REPLACE 'FORUM_NAME' => $forum_name, with itself in order to achieve what he wants. What if he had the ability to tell EasyMOD to ignore that line and just replace the rest? The XML code would look like this:

Code: Select all

...
   <find>
    <line>
     <value mark="0">'FORUM_NAME' => $forum_name,</value>
     <value />
     <value>'L_FORUM' => $lang['Forum'],</value>
    </line>
    <replace>
     <value />
     <value>//-- mod : categories hierarchy</value>
     <value>//-- delete</value>
     <value>//			'L_FORUM' => $lang['Forum'],</value>
     <value>//-- add</value>
     <value>			'L_FORUM' => ( $cat_id > 0 ) ? $lang['Category'] : $lang['Forum'],<value>
     <value>//-- fin mod : categories hierarchy</value>
    </replace>
   </find>
...
Note that it's still easy for people to read. And it looks less ugly, to me at least.

All the above are just a sample of the posibilities. I believe XML is a very important step towards creating a standard easily readable by both people and the machine. How about being able to include "uninstall" tags? I can just not see a limit anymore. That's why I'm bringing the issue here. I'm not sure how mature the audience is for such a change, but it might be worth the fuss.

Note: all MOD may be distributed in both plain and XML forms, we can even make a converter to turn one into the other automatically (I've got one almost ready).

Some comments on this?
http://www.zine.gr/" target="_blank

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: XML in MODs?

Post by Ptirhiik_ »

To difficult to read for users : today most of the support on installing a mod is relative to a wrong reading of a find or any statement, so multiplying the number of instructions for really a very little gain (IMHO none actually) doesn't sound a good move. Also, there are a lot of potential issue between the xml tags and the content of the mod.

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: XML in MODs?

Post by iliasch »

Ptirhiik_ wrote:To difficult to read for users : today most of the support on installing a mod is relative to a wrong reading of a find or any statement, so multiplying the number of instructions for really a very little gain (IMHO none actually) doesn't sound a good move. Also, there are a lot of potential issue between the xml tags and the content of the mod.
Actually I mostly agree with your points Ptirhiik, but the thing is this is a forum for EasyMOD, so the suggestion is mainly for its profit. The purpose is to make the script's job easier and above all more accurate.

As far as readability is conserned, plain text is certainly easier to read, but XML isn't a Gordian Knott either. Personally, I like the "strict" structure of XML as opposed to plain text.

About the potential issue of conflicts between the tags and the code, that's an issue to be solved, I know. However, it's not a big one. Here's a simple solution that comes to mind right now: <values data="codeHere" /> and "escape" all quotes in the code, so that it's limited within the "data" field.


Overall, I don't think you can say it's a bad idea. It may be difficult to switch, but it can be used in parallel with plain text. For instance, a MOD author writes his MOD in plain text (using the MOD Template) and also runs a convertor to make it XML. He can then browse the XML result to make any needed adjustments. Finally he distributes both files, the plain text for those that manually modify their boards, the XML for those that use EasyMOD.

Hopefully, EasyMOD will prove to be even more accurate this way. This means that more MODs will be installed successfully, less people will come back for support and MOD authors will have more time available to invest in development.

Think about it...
http://www.zine.gr/" target="_blank

wGEric
Registered User
Posts: 521
Joined: Wed Jun 11, 2003 2:07 am
Contact:

Re: XML in MODs?

Post by wGEric »

MOD Team is way ahead of you.
Eric

iliasch
Registered User
Posts: 23
Joined: Sun May 11, 2003 3:50 pm
Location: Greece

Re: XML in MODs?

Post by iliasch »

Could you please give me a hint of what's that supposed to imply?
http://www.zine.gr/" target="_blank

wGEric
Registered User
Posts: 521
Joined: Wed Jun 11, 2003 2:07 am
Contact:

Re: XML in MODs?

Post by wGEric »

No, because it is no where near being done. Probably around 2.2. I'm not sure of the details.
Eric

Locked