XmlTools: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (link fixes)
m (→‎Overview: minor note)
Line 10: Line 10:
It is written in C++, works in both Mac OS X and Windows and is currently very efficient in terms of performance.
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 also written in C# (previous 2.0) but later it was rewritten to C++ due to performance reasons. It was then developed further for the purposes of the [[AE]] so that resources could be patched smartly. To learn about the overall process, read [[Making a patch mod]] and [[Anniversary Edition/Framework#XML patching|AE Framework - XML patching]].
The initial version was written to help with the development of the Old China level mod and was also written in C# (previous 2.0) but later it was rewritten to C++ due to performance reasons and cross platform problems. It was then developed further for the purposes of the [[AE]] so that resources could be patched smartly. To learn about the overall process, read [[Making a patch mod]] and [[Anniversary Edition/Framework#XML patching|AE Framework - XML patching]].


XmlTools can be used as a standalone tool or as a base for another tools. 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 can be used as a standalone tool or as a base for another tools. 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.

Revision as of 15:13, 3 May 2014

XML Background

This documentation uses many XML technical expressions such as: element, parent element, node, attribute. Because of this it is highly recommended that you have a basic background of XML before using XmlTools or any of its documentation.

You can get a rapid and good tutorial to get familiar with this expressions and XML itself in this page.

Overview

XmlTools is a command-line modding tool that operates on XML files, including those exported by OniSplit. It supports many operations in XML files and even non implemented operations using custom javascript code.

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 also written in C# (previous 2.0) but later it was rewritten to C++ due to performance reasons and cross platform problems. It was then developed further for the purposes of the AE so that resources could be patched smartly. To learn about the overall process, read Making a patch mod and AE Framework - XML patching.

XmlTools can be used as a standalone tool or as a base for another tools. 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.

Aditional documentation for XmlTools can be found in XmlTools/Full documentation.

Links

  • Download the tool here and its dependencies here or download them all using the AEI.
  • XmlTools is used along with OniSplit as the backend for the GUI tool Vago.

Features

  • Update all values in a set of XML elements (e.g., repositioning an OBAN animation or adjusting the pelvis height of a TRAM).
  • Inverts a set of XML elements (e.g., invert 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 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 elements to the above operations it can be used the element name, parent element name, attribute name/value and XPath 1.0.

Syntax

You can find out the XmlTools options if you don't provide any or when using --help option. 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 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 variable.
Option The command to perform. Note the commands are prefaced by a --, some commands have a short version which is prefaced by 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 bellow with XmlTools. If you don't provide all the required options to an operation XmlTools will notice you.

Options

-a, --add-values

Add new values to a set of XML elements;

--remove-values

Removes values from a set of XML elements;

--replace-value

Replaces 1 value in a set of XML elements;

--replace-all-values

Replaces all values in a set of XML elements;

-u, --update-elements

Updates all values in a set of XML elements;

-i, --invert-elements

Inverts a set of XML elements.

Input Options

-c, --current-val <current-val>

Current value(s) [use space as separator];

-n, --new-val <new-val>

New value(s) [use space as separator];

-d, --diff-old-new-val <diff-old-new-val>

Difference between old and new value;

--positions <positions>

Positions [use space as separator] [0-index based];

-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> [used as filter];

--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 to select elements where processing will occur;

--no-backups

No backups [faster processing];

--no-verbose

Reduce the number of text messages output [faster processing].

Patch file operations

Patch files are mainly used for two purposes: to create a list of commands within one file that you can pass to XmlTools to execute all at once, to remove XML nodes, to insert new XML 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 '#'.

Options

Operations in patch files always begin with '@'. They are named using all letters in upper case and words separated by underscore (_).

@XML_TOOLS

XmlTools information. Right now is only used to specify the executable minimum version for the current patch file;

@ADD_INSIDE_NODES

Adds new XML nodes;

@REMOVE_NODES

Removes existing XML nodes;

@COMMAND

Runs any of the commands available under "Command-line options" above. Use standard command-line syntax described in that section;

@CUSTOM_CODE

Executes the JavaScript code for XML editing. When specifically you are using this operation for AE Patches you should try to avoid this operation as much as possible because it is much slower than the native XmlTools commands;

Input Options

The values of the following options inputs must be always inside of quotes (""). The input options use pascal casing.

Files

Wildcard that matches the file(s) that you want to edit;

ElementName

XML element name where processing will occur;

ParentElementName

XML parent element name of ElementName, used as filter;

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 to select elements where the processing will occur;

Options

Allows to specify any option of command-line operations. Values must be within " ' " to avoid confusion with the quotes.