18,700
edits
m (→Features: typo) |
(grammar edit and some wiki touch-up) |
||
Line 1: | Line 1: | ||
:''This documentation uses many technical [[wikipedia:XML|XML]]-related expressions such as: element, parent element, node, attribute. Because of this, it is highly recommended that you have a basic background in XML before using XmlTools or reading its documentation. You'll find a good quick tutorial to familiarize yourself with these terms and XML itself [http://www.w3schools.com/xml/xml_whatis.asp on this page].'' | |||
XmlTools is a command-line modding tool developed by [[User:Script 10k|s10k]] to operate on XML files, especially those exported by [[OniSplit#XML|OniSplit]]. It supports many basic operations, and allows more complex programmable operations through [[wikipedia:JavaScript|JavaScript]]. It is written in C++, works in both Mac OS X and Windows, and is currently very efficient in terms of performance. | |||
The initial version was written to help with the development of the Old China level mod and was written in C# previous to v2.0, but later was rewritten in C++ for performance and cross-platform reasons. It was then developed further for the purposes of the [[AE]] so that resources could be patched smartly. | |||
XmlTools can be used as a standalone tool or as a base for another tool. It can be issued commands directly on the command-line interface (CLI) or passed a text file on the CLI with a list of commands to perform. | |||
XmlTools | |||
The full documentation for XmlTools' commands is found on the [[XmlTools/Full documentation|Full documentation]] subpage. | |||
The | |||
XmlTools | |||
==Links== | ==Links== | ||
*Download the tool [http://mods.oni2.net/node/265 here] and its dependencies [http://mods.oni2.net/node/304 here] or download them | *Download the tool [http://mods.oni2.net/node/265 here] and its dependencies [http://mods.oni2.net/node/304 here], or download them together using the [[AEI]]'s Tools menu. | ||
*XmlTools is used along with OniSplit as the backend for the GUI tool [[Vago_(tool)|Vago]]. | *XmlTools is used along with OniSplit as the backend for the GUI modding tool [[Vago_(tool)|Vago]]. | ||
==Features== | ==Features== | ||
*'''Update all values in a set of XML elements''' (e.g., | *'''Update all values in a set of XML elements''' (e.g., re-position an OBAN animation or adjusting the pelvis height of a TRAM). | ||
*'''Inverts a set of XML elements''' (e.g., | *'''Inverts a set of XML elements''' (e.g., reverse the motion of an OBAN animation). | ||
*'''Add new values to a set of XML elements''' (e.g., add the 'unkillable' flag to some characters in a level). | *'''Add new values to a set of XML elements''' (e.g., add the 'unkillable' flag to some characters in a level). | ||
*'''Remove values from a set of XML elements''' (e.g., remove boss shields from characters in a level). | *'''Remove values from a set of XML elements''' (e.g., remove boss shields from characters in a level). | ||
Line 29: | Line 22: | ||
*'''Add new XML inside existing nodes''' (patch only). | *'''Add new XML inside existing nodes''' (patch only). | ||
*'''Remove XML nodes''' (patch only). | *'''Remove XML nodes''' (patch only). | ||
*'''Powerful custom XML editing using | *'''Powerful custom XML editing using JavaScript''' (e.g., to employ complex logical or mathematical operations) (patch only). | ||
* To select elements to the above operations | * To select the elements to which the above operations will apply, you can supply the '''element name, parent element name, attribute name/value, or an XPath expression'''. | ||
==Syntax== | ==Syntax== | ||
You can | You can see XmlTools' options by supplying the '''--help''' option or no option at all. You can get the version with the option '''--version'''. The commands below must be preceded by either <tt>XmlTools.exe</tt> (Windows) or <tt>./XmlTools</tt> (Mac). If XmlTools is not in the current folder, you can provide the full/relative path to it or set the path environment variable. On the Mac, be sure to use <tt>/</tt> rather than <tt>\</tt> in paths. | ||
The basic syntax is: | The basic syntax is: | ||
Line 49: | Line 42: | ||
|- valign="top" | |- valign="top" | ||
|<span style="background:rgb(235,235,235); border-radius:0.33em;">'''Invocation'''</span> | |<span style="background:rgb(235,235,235); border-radius:0.33em;">'''Invocation'''</span> | ||
|Note that if XmlTools is not in the Command Prompt/Terminal's current directory, you must provide the full path to it or set the path variable. | |Note that if XmlTools is not in the Command Prompt/Terminal's current directory, you must provide the full path to it or set the path environment variable. | ||
|- | |- | ||
|<span style="background:rgb(175,175,255); border-radius:0.33em;">'''Option'''</span>||The command to perform. Note | |<span style="background:rgb(175,175,255); border-radius:0.33em;">'''Option'''</span>||The command to perform. Note that commands are prefaced by a <tt>--</tt>; some commands also have a short version which is composed of a single <tt>-</tt> followed by a letter. | ||
|- | |- | ||
|<span style="background:rgb(156,255,156); border-radius:0.33em;">'''Option Value'''</span>||This is where you supply the value that this specific command needs. As seen below, --element-name requires the XML element name, so we provide that here. Quotes should be used when the value has spaces or to avoid [http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html Unix shell expansion]. | |<span style="background:rgb(156,255,156); border-radius:0.33em;">'''Option Value'''</span>||This is where you supply the value that this specific command needs. As seen below, '''--element-name''' requires the XML element name, so we provide that here. Quotes should be used when the value has spaces or to avoid [http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html Unix shell expansion]. | ||
|- valign="top" | |- valign="top" | ||
|} | |} | ||
==Command-line operations== | ==Command-line operations== | ||
You can use any of the following operations | You can use any of the following operations with XmlTools. If you don't provide all the required options to an operation, XmlTools will notify you. | ||
===Options=== | ===Options=== | ||
<tt>[[XmlTools/Full_documentation#--add-values|-a, --add-values]]</tt> | <tt>[[XmlTools/Full_documentation#--add-values|-a, --add-values]]</tt> | ||
: | :Adds new values to a set of XML elements; | ||
<tt>[[XmlTools/Full_documentation#--remove-values|--remove-values]]</tt> | <tt>[[XmlTools/Full_documentation#--remove-values|--remove-values]]</tt> | ||
Line 68: | Line 61: | ||
<tt>[[XmlTools/Full_documentation#--replace-value|--replace-value]]</tt> | <tt>[[XmlTools/Full_documentation#--replace-value|--replace-value]]</tt> | ||
:Replaces | :Replaces a specific value in a set of XML elements; | ||
<tt>[[XmlTools/Full_documentation#--replace-all-values|--replace-all-values]]</tt> | <tt>[[XmlTools/Full_documentation#--replace-all-values|--replace-all-values]]</tt> | ||
Line 74: | Line 67: | ||
<tt>[[XmlTools/Full_documentation#--update-elements|-u, --update-elements]]</tt> | <tt>[[XmlTools/Full_documentation#--update-elements|-u, --update-elements]]</tt> | ||
: | :Shifts all values in a set of XML elements by an offset; | ||
<tt>[[XmlTools/Full_documentation#--invert-elements|-i, --invert-elements]]</tt> | <tt>[[XmlTools/Full_documentation#--invert-elements|-i, --invert-elements]]</tt> | ||
: | :Reverses a set of XML elements. | ||
===Input | ===Input options=== | ||
<tt>-c, --current-val <current-val></tt> | <tt>-c, --current-val <current-val></tt> | ||
: | :Value to be replaced or removed (use space as separator) | ||
<tt>-n, --new-val <new-val></tt> | <tt>-n, --new-val <new-val></tt> | ||
:New value(s) | :New value(s) to add or replace current value (use space as separator) | ||
<tt>-d, --diff-old-new-val <diff-old-new-val></tt> | <tt>-d, --diff-old-new-val <diff-old-new-val></tt> | ||
:Difference | :Difference to adjust values by, when using '''--update-values''' | ||
<tt>--positions <positions></tt> | <tt>--positions <positions></tt> | ||
:Positions [use space as separator] | :Positions [use space as separator] (zero-based index) | ||
<tt>-f, --files <files></tt> | <tt>-f, --files <files></tt> | ||
:XML files to process | :XML files to process (wildcards supported) | ||
<tt>-p, --patch-files <patch-files></tt> | <tt>-p, --patch-files <patch-files></tt> | ||
:Patch files to process | :Patch files to process (wildcards supported) | ||
<tt>--force-target-files <force-target-files></tt> | <tt>--force-target-files <force-target-files></tt> | ||
:Force the patch-files operation in the specified XML files | :Force the patch-files operation in the specified XML files (wildcards supported) | ||
<tt>-e, --element-name <element-name></tt> | <tt>-e, --element-name <element-name></tt> | ||
:Name of the XML element(s) where processing will occur | :Name of the XML element(s) where processing will occur | ||
<tt>--parent-element-name <parent-element-name></tt> | <tt>--parent-element-name <parent-element-name></tt> | ||
:Name of the XML parent element of <element-name> | :Name of the XML parent element of <element-name> (can be used to filter out elements in different parts of the hierarchy that have duplicate names) | ||
<tt>--attribute-name <attribute-name></tt> | <tt>--attribute-name <attribute-name></tt> | ||
:Attribute name of <element-name> | :Attribute name of <element-name> (used as filter) | ||
<tt>--attribute-value <attribute-value></tt> | <tt>--attribute-value <attribute-value></tt> | ||
:Attribute value of <attribute-name> | :Attribute value of <attribute-name> (used as filter) | ||
<tt>-x, --xpath-expression <xpath-expression></tt> | <tt>-x, --xpath-expression <xpath-expression></tt> | ||
:[http://www.w3.org/TR/xpath/ XPath 1.0] expression | :[http://www.w3.org/TR/xpath/ XPath 1.0] expression (used as filter) | ||
<tt>--no-backups</tt> | <tt>--no-backups</tt> | ||
: | :Don't make backups of XML files (faster processing) | ||
<tt>--no-verbose</tt> | <tt>--no-verbose</tt> | ||
:Reduce the number of text messages output | :Reduce the number of text messages in output (faster processing) | ||
==Patch file operations== | ==Patch file operations== | ||
Patch files are | Patch files are primarily used to create a list of commands within one file that you can pass to XmlTools to execute all at once, to insert blocks of XML into existing nodes, and to use [[wikipedia:JavaScript|JavaScript]] code to modify the XML. | ||
To make a patch, create a plain-text file that uses the following commands and pass it to XmlTools using the <tt>patchfile</tt> command documented above. See [[Making a patch mod|HERE]] for instructions on making a patch mod package for the AE and [[Anniversary Edition/Framework#XML patching|HERE]] to learn how the [[AEI]] handles patch mods. | To make a patch, create a plain-text file that uses the following commands and pass it to XmlTools using the <tt>patchfile</tt> command documented above. See [[Making a patch mod|HERE]] for instructions on making a patch mod package for the AE and [[Anniversary Edition/Framework#XML patching|HERE]] to learn how the [[AEI]] handles patch mods. | ||
Comments in patch files begin with '#'. | Comments in patch files begin with a '#'. | ||
Operations in patch files always begin with '@'. | ===Commands=== | ||
Operations in patch files always begin with an '@'. The commands are named in upper case and with words separated by an underscore (_). | |||
<tt>[[XmlTools/Full_documentation#.40XML_TOOLS|@XML_TOOLS]]</tt> | <tt>[[XmlTools/Full_documentation#.40XML_TOOLS|@XML_TOOLS]]</tt> | ||
:XmlTools | :Options for running XmlTools. Right now is only used to specify the minimum version of XmlTools needed for the current patch file. | ||
<tt>[[XmlTools/Full_documentation#.40ADD_INSIDE_NODES|@ADD_INSIDE_NODES]]</tt> | <tt>[[XmlTools/Full_documentation#.40ADD_INSIDE_NODES|@ADD_INSIDE_NODES]]</tt> | ||
:Adds | :Adds the following XML to existing XML nodes | ||
<tt>[[XmlTools/Full_documentation#.40REMOVE_NODES|@REMOVE_NODES]]</tt> | <tt>[[XmlTools/Full_documentation#.40REMOVE_NODES|@REMOVE_NODES]]</tt> | ||
:Removes existing XML nodes | :Removes existing XML nodes | ||
<tt>[[XmlTools/Full_documentation#.40COMMAND|@COMMAND]]</tt> | <tt>[[XmlTools/Full_documentation#.40COMMAND|@COMMAND]]</tt> | ||
:Runs any of the commands available under "Command-line options" above. Use | :Runs any of the commands available under "Command-line options" above. Use the usual command-line syntax described in that section. | ||
<tt>[[XmlTools/Full_documentation#.40CUSTOM_CODE|@CUSTOM_CODE]]</tt> | <tt>[[XmlTools/Full_documentation#.40CUSTOM_CODE|@CUSTOM_CODE]]</tt> | ||
:Executes the [[wikipedia:JavaScript|JavaScript]] code for XML | :Executes the following [[wikipedia:JavaScript|JavaScript]] code for the purpose of editing the XML. If you are creating a [[Anniversary_Edition/Framework#XML_patching|patch mod]] for the AE, <u>you should try to avoid this operation as much as possible</u> because it is much slower than the native XmlTools commands. | ||
The values | ===Command options=== | ||
The values supplied for the following options must <u>always</u> be inside quotes (""). The option names use [http://c2.com/cgi/wiki?PascalCase Pascal case]. | |||
<tt>Files</tt> | <tt>Files</tt> | ||
:[http://www.computerhope.com/jargon/w/wildcard.htm Wildcard] that matches the file(s) that you want to edit | :[http://www.computerhope.com/jargon/w/wildcard.htm Wildcard] that matches the file(s) that you want to edit | ||
<tt>ElementName</tt> | <tt>ElementName</tt> | ||
:XML element name where processing will occur | :XML element name where processing will occur | ||
<tt>ParentElementName</tt> | <tt>ParentElementName</tt> | ||
: | :Name of parent element of ElementName (can be used to filter out elements in different parts of the hierarchy that have duplicate names) | ||
<tt>AttributeName</tt> | <tt>AttributeName</tt> | ||
:XML attribute name of the ElementName | :XML attribute name of the ElementName (used as filter) | ||
<tt>AttributeValue</tt> | <tt>AttributeValue</tt> | ||
:XML attribute value of the AttributeName | :XML attribute value of the AttributeName (used as filter) | ||
<tt>XPathExpression</tt> | <tt>XPathExpression</tt> | ||
:[http://zvon.org/comp/r/tut-XPath_1.html#intro XPath 1.0] expression | :[http://zvon.org/comp/r/tut-XPath_1.html#intro XPath 1.0] expression (used as filter) | ||
<tt>Options</tt> | <tt>Options</tt> | ||
:Allows to | :Allows you to name any of the [[#Command-line_operations|command-line operations]]. Values must be within " ' " to avoid confusion with the quotes. | ||
[[Category:Bi-platform modding tools]][[Category:Completed modding tools]][[Category:Modding tutorials]] | [[Category:Bi-platform modding tools]][[Category:Completed modding tools]][[Category:Modding tutorials]] |