Relation?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Sifting-Sand
Posts: 2
Joined: October 6th, 2010, 1:58 pm

Relation?

Post by Sifting-Sand »

Is WML at all like working with XML?
------------------------------------------------------------------------------------------------------------
"Mors ultima linea rerum est mortalis."
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: Relation?

Post by Ken_Oh »

User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: Relation?

Post by pauxlo »

More detailed here: SyntaxWML.

Similarities:
  • In WML we have "tags", which correspond to "elements" in XML. (I think there was a naming confusion when this was created.)
  • Tags in WML may have subtags (any number, also multiple of each name), like elements in XML may have subelements.
  • Tags in WML (and elements in XML) can have attributes, which are simple name-value-pairs (of Strings).
  • There can be only one attribute of each name inside each tag/element. The ordering of attributes does not matter.
  • Ordering of subtags/subelements may or may not matter, depending on the actual use case.
Differences:
  • In WML the attributes are listed between the starting- and ending indicators, in XML inside the starting tag of an element.
  • In WML you may note several attributes together as a list: x,y=20,40. This is not possible in XML.
  • In WML attribute values you can concatenate multiple strings with +.
  • In XML there may be text content inside a element, in WML is no "text content" inside of tags.
  • There are no entity references (&) in WML.
  • Most visible: WML uses square brackets [], XML uses angle ones <>.
  • comments start in WML with # and go to the end of line, comments in XML start with <!-- and go to -->.
  • XML may be encoded using different character sets, WML supports only UTF-8.
  • XML can have a document type declaration, WML not (it implicitely is "WML like Wesnoth understands it").
  • WML has a "tag continuation" with [+tag] ... [/tag], which adds the content to the last closed tag which same name. There is no such thing in XML.
  • WML has a preprocessor (providing conditionals and macro replacement), which XML does not have.
  • In XML, all attribute values should be in quotation marks ("...") - in WML these are optional (mainly used for line-continuations or strings containing a +). Additionally WML has "stronger quotes" with << ... >>, inside of which the preprocessor does not do anything. (This is mentioned only on LuaWML, I hope it works also at other places. Please correct me if this is wrong.)
  • WML has an attribute translation feature: when you prefix an attribute value with _, it may be translated (support depends on context).
  • (The SyntaxWML page mentions variables with $varname, but I think this is actually not part of the WML syntax, but only used at later stages of the interpretation, and only in some contexts (events and similar)).
Post Reply