XmlTools: Difference between revisions
Script 10k (talk | contribs) |
m (using hatnote template) |
||
(27 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Hatnote|This documentation uses many technical [[wp:XML|XML]]-related expressions such as: element, parent element, node, attribute. Therefore 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 [https://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 [[wp:JavaScript|JavaScript]]. It is written in C++, works in both macOS 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. | |||
The full documentation for XmlTools' commands is found on the [[XmlTools/Full documentation|Full documentation]] subpage. | |||
XmlTools is | |||
==Links== | ==Links== | ||
*Download the tool | *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). | ||
*'''Replace values in a set XML elements''' (e.g., increase the health of characters by replacing the old HP value). | *'''Replace values in a set of XML elements''' (e.g., increase the health of characters by replacing the old HP value). | ||
*'''Patch file support''' that allows the modder to list multiple commands in a file, to all be performed at once. | *'''Patch file support''' that allows the modder to list multiple commands in a file, to all be performed at once. | ||
*'''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 54: | Line 41: | ||
|- 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;">''' | |<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;">''' | |<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 [https://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>-a, --add-values</tt> | <tt>[[XmlTools/Full_documentation#--add-values|-a, --add-values]]</tt> | ||
: | :Adds new values to a set of XML elements; | ||
<tt>--remove-values</tt> | <tt>[[XmlTools/Full_documentation#--remove-values|--remove-values]]</tt> | ||
:Removes values from a set of XML elements; | :Removes values from a set of XML elements; | ||
<tt>--replace-value</tt> | <tt>[[XmlTools/Full_documentation#--replace-value|--replace-value]]</tt> | ||
:Replaces | :Replaces a specific value in a set of XML elements; | ||
<tt>--replace-all-values</tt> | <tt>[[XmlTools/Full_documentation#--replace-all-values|--replace-all-values]]</tt> | ||
:Replaces all values in a set of XML elements; | :Replaces all values in a set of XML elements; | ||
<tt>-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>-i, --invert-elements</tt> | <tt>[[XmlTools/Full_documentation#--invert-elements|-i, --invert-elements]]</tt> | ||
: | :Reverses a set of XML elements. | ||
=== | ===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> | ||
:[ | :[https://www.w3.org/TR/1999/REC-xpath-19991116/ 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 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# | 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#Installation|HERE]] to learn how the [[AEI]] handles patch mods. | ||
Comments in patch files begin with a '#'. | |||
===Commands=== | |||
Operations in patch files always begin with an '@'. The commands are named in upper case and with words separated by an underscore (_). | |||
<tt>@ | <tt>[[XmlTools/Full_documentation#.40XML_TOOLS|@XML_TOOLS]]</tt> | ||
: | :Options for running XmlTools. Right now is only used to specify the minimum version of XmlTools needed for the current patch file. | ||
<tt>@ | <tt>[[XmlTools/Full_documentation#.40ADD_INSIDE_NODES|@ADD_INSIDE_NODES]]</tt> | ||
: | :Adds the following XML to existing XML nodes | ||
<tt>@ | <tt>[[XmlTools/Full_documentation#.40REMOVE_NODES|@REMOVE_NODES]]</tt> | ||
: | :Removes existing XML nodes | ||
<tt>@ | <tt>[[XmlTools/Full_documentation#.40COMMAND|@COMMAND]]</tt> | ||
: | :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> | |||
:Executes the following JavaScript code for the purpose of editing the XML. If you are creating a 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://wiki.c2.com/?PascalCase Pascal case]. | |||
<tt>Files</tt> | <tt>Files</tt> | ||
:[ | :[https://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]] |
Latest revision as of 21:52, 2 July 2022
- This documentation uses many technical XML-related expressions such as: element, parent element, node, attribute. Therefore 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 on this page.
XmlTools is a command-line modding tool developed by s10k to operate on XML files, especially those exported by OniSplit. It supports many basic operations, and allows more complex programmable operations through JavaScript. It is written in C++, works in both macOS 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.
The full documentation for XmlTools' commands is found on the Full documentation subpage.
Links
- Download the tool here and its dependencies here, or download them together using the AEI's Tools menu.
- XmlTools is used along with OniSplit as the backend for the GUI modding tool Vago.
Features
- 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., 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).
- Remove values from a set of XML elements (e.g., remove boss shields from characters in a level).
- Replace values in a set of XML elements (e.g., increase the health of characters by replacing the old HP value).
- Patch file support that allows the modder to list multiple commands in a file, to all be performed at once.
- Add new XML inside existing nodes (patch only).
- Remove XML nodes (patch only).
- Powerful custom XML editing using JavaScript (e.g., to employ complex logical or mathematical operations) (patch only).
- 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
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 XmlTools.exe (Windows) or ./XmlTools (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 / rather than \ in paths.
The basic syntax is:
Windows | XmlTools.exe --add-values --element-name "Weapon" --new-val "w1_tap" --files "BINACJBOCharacter.xml" |
Mac | ./XmlTools --add-values --element-name "Weapon" --new-val "w1_tap" --files "BINACJBOCharacter.xml" |
Here's how it breaks down:
Invocation | 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. |
Option | The command to perform. Note that commands are prefaced by a --; some commands also have a short version which is composed of a single - followed by a letter. |
Option Value | 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 Unix shell expansion. |
Command-line 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
- Adds new values to a set of XML elements;
- Removes values from a set of XML elements;
- Replaces a specific value in a set of XML elements;
- Replaces all values in a set of XML elements;
- Shifts all values in a set of XML elements by an offset;
- Reverses a set of XML elements.
Input options
-c, --current-val <current-val>
- Value to be replaced or removed (use space as separator)
-n, --new-val <new-val>
- New value(s) to add or replace current value (use space as separator)
-d, --diff-old-new-val <diff-old-new-val>
- Difference to adjust values by, when using --update-values
--positions <positions>
- Positions [use space as separator] (zero-based index)
-f, --files <files>
- XML files to process (wildcards supported)
-p, --patch-files <patch-files>
- Patch files to process (wildcards supported)
--force-target-files <force-target-files>
- Force the patch-files operation in the specified XML files (wildcards supported)
-e, --element-name <element-name>
- Name of the XML element(s) where processing will occur
--parent-element-name <parent-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)
--attribute-name <attribute-name>
- Attribute name of <element-name> (used as filter)
--attribute-value <attribute-value>
- Attribute value of <attribute-name> (used as filter)
-x, --xpath-expression <xpath-expression>
- XPath 1.0 expression (used as filter)
--no-backups
- Don't make backups of XML files (faster processing)
--no-verbose
- Reduce the number of text messages in output (faster processing)
Patch file operations
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 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 patchfile command documented above. See HERE for instructions on making a patch mod package for the AE and HERE to learn how the AEI handles patch mods.
Comments in patch files begin with a '#'.
Commands
Operations in patch files always begin with an '@'. The commands are named in upper case and with words separated by an underscore (_).
- Options for running XmlTools. Right now is only used to specify the minimum version of XmlTools needed for the current patch file.
- Adds the following XML to existing XML nodes
- Removes existing XML nodes
- Runs any of the commands available under "Command-line options" above. Use the usual command-line syntax described in that section.
- Executes the following JavaScript code for the purpose of editing the XML. If you are creating a patch mod for the AE, you should try to avoid this operation as much as possible because it is much slower than the native XmlTools commands.
Command options
The values supplied for the following options must always be inside quotes (""). The option names use Pascal case.
Files
- Wildcard that matches the file(s) that you want to edit
ElementName
- XML element name where processing will occur
ParentElementName
- Name of parent element of ElementName (can be used to filter out elements in different parts of the hierarchy that have duplicate names)
AttributeName
- XML attribute name of the ElementName (used as filter)
AttributeValue
- XML attribute value of the AttributeName (used as filter)
XPathExpression
- XPath 1.0 expression (used as filter)
Options
- Allows you to name any of the command-line operations. Values must be within " ' " to avoid confusion with the quotes.