|
|
Line 122: |
Line 122: |
|
| |
|
| ==Patch file operations== | | ==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, and to use [[wikipedia:JavaScript|JavaScript]] code to modify the XML. | | 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 [[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. |
|
| |
|
| Arguments in square brackets are optional.
| | Comments in patch files begin with '#'. |
|
| |
|
| <tt>@ADDTO Element <quoted tag name> [ParentElement <quoted tag name>] [File <quoted file name>]</tt>
| | ===Operations=== |
| :Adds the raw XML that follows to the named array tag.
| |
| @ADDTO Element "Particles"
| |
| <xml>
| |
| <Particle>
| |
| <Start>0</Start>
| |
| <End>45</End>
| |
| <Bone>Head</Bone>
| |
| <Name>glass_break</Name>
| |
| </Particle>
| |
| </xml>
| |
|
| |
|
| <tt>@REMOVE Element <quoted tag name> [ParentElement <quoted tag name>] [File <quoted file name>]</tt>
| | Operations in patch files always begin with '@'. The operations options use [http://c2.com/cgi/wiki?PascalCase pascal casing]. |
| :Removes named element from the array tag named by ParentElement.
| |
|
| |
|
| <tt>@COMMAND <command-line string></tt> | | <tt>@XML_TOOLS</tt> |
| :Runs any of the commands available under "Command-line operations" above. Use standard command-line syntax described in that section, including <tt>-filename</tt>. | | :XmlTools information. Right now is only used to specify the executable minimum version for the current patch file; |
| @COMMAND invert -element:Height -parelement:Heights -filename:test.xml
| |
|
| |
|
| <tt>@CUSTOMCODE [File <quoted file name>]</tt> | | <tt>@ADD_INSIDE_NODES</tt> |
| :Executes the JavaScript code inside a <tt><nowiki><code></nowiki></tt> tag. <u>You should avoid this method when possible</u> because it is much slower than the native XmlTools commands. | | :Adds new XML nodes; |
| :The XML library that you can use in your JavaScript code is called ''W3C DOM Parser'' and its documentation is available [http://xmljs.sourceforge.net/website/documentation-w3cdom.html here]. The most important thing to know about the DOM Parser is that the contents of the XML file are saved in the global variable ''$xmlData''. So you will need to access it to edit the XML. Make sure that after the editing process you update ''$xmlData'' with the new XML so the file gets correctly edited.
| |
|
| |
|
| Here is a sample usage for <tt>@CUSTOMCODE</tt>:
| | <tt>@REMOVE_NODES</tt> |
| | :Removes existing XML nodes; |
|
| |
|
| Sample XML file to be patched:
| | <tt>@COMMAND</tt> |
| <Oni>
| | :Runs any of the commands available under "Command-line options" above. Use standard command-line syntax described in that section; |
| <Animation>
| |
| <Lookup>
| |
| <Type>KickForward</Type>
| |
| <AimingType>KickForward</AimingType>
| |
| <FromState>RunBackStart</FromState>
| |
| <ToState>Standing</ToState>
| |
| <Varient>Combat</Varient>
| |
| <FirstLevel>4</FirstLevel><span style="color:#008000"><nowiki><!--</nowiki>The JavaScript code below will change this tag's value from 4 to 0--></span>
| |
| ...
| |
| </Lookup>
| |
| </Animation>
| |
| </Oni>
| |
|
| |
|
| | <tt>@CUSTOM_CODE</tt> |
| | :Executes the [[wikipedia:JavaScript|JavaScript]] code for XML editing. <u>You should avoid this operation as much as possible</u> because it is much slower than the native XmlTools commands; |
|
| |
|
| XmlTools patch file contents:
| | ===Operations inputs=== |
| @CUSTOMCODE
| | |
| <nowiki><code></nowiki>
| | The values of the following options inputs must be <u>always</u> inside of quotes (""). |
| var parser = new DOMImplementation(); <span style="color:#008000">// instantiate the W3C DOM Parser</span>
| | |
| var domDoc = parser.loadXML($xmlData); <span style="color:#008000">// load the XML into the parser and get the DOMDocument, using $xmlData variable</span>
| | <tt>Files</tt> |
| var levelNode = domDoc.getDocumentElement().getElementsByTagName("FirstLevel").item(0).firstChild;
| | :description; |
| if (levelNode.toString() == "4")
| | |
| levelNode.setNodeValue("0"); <span style="color:#008000">// change level from 4 to 0</span>
| | <tt>ElementName</tt> |
| $xmlData = domDoc.getDocumentElement().getXML(); <span style="color:#008000">// update the global variable with the new XML</span>
| | :description; |
| <nowiki></code></nowiki>
| | |
|
| | <tt>ParentElementName</tt> |
| Note that if you don't use the optional <tt>File <quoted file name></tt> argument, the operation will be applied over all the XML files in the same directory as xmlTools.exe -- unless you used the <tt>-forceinfiles</tt> argument along with the <tt>patchfile</tt> command as described in that command's documentation. Note that the <tt>File</tt> argument allows wildcards ('*', '?').
| | :description; |
| | |
| | <tt>AttributeName</tt> |
| | :description; |
| | |
| | <tt>AttributeValue</tt> |
| | :description; |
| | |
| | <tt>XPathExpression</tt> |
| | :description; |
| | |
| | <tt>Options</tt> |
| | :description; |
|
| |
|
| [[Category:Bi-platform modding tools]][[Category:Completed modding tools]][[Category:Modding tutorials]] | | [[Category:Bi-platform modding tools]][[Category:Completed modding tools]][[Category:Modding tutorials]] |