You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[size=150][b]Modding tools: XML diff and patch for X4: Foundations[/b][/size]
2
+
3
+
This toolset is a simple XML diff and patch tools for X4: Foundations. It is designed to help modders to compare and patch XML files.
4
+
5
+
The format of diff XML files is compatible with the appropriate [b]diff.xsd[/b] format definition. It is means - you can you this tool to create diff files for any XML files used in game.
6
+
Also, you can use appropriate tool to patch XML files with diff files, this action has reason to check how your diff file will be applied to the vanilla XML file. Or better understand, what other modders did in their mods.
7
+
8
+
[size=120][b]Important note[/b][/size]
9
+
It is highly recommended to use the [b]diff.xsd[/b] file to validate the diff XML files. It is especially important when you creating them by [b]XMLDiff.exe[/b].
10
+
11
+
12
+
[size=120][b]How to use[/b][/size]
13
+
[list=1]
14
+
[*] Download the latest release from the [url=https://github.com/chemodun/x4_XMLDiffAndPatch/releases/]releases page[/url] - there is an archive file [b]XMLDiffAndPatch.zip[/b].
15
+
[*] Extract the archive file to any useful location.
16
+
[*] Inside will be a folder, named XMLDiffAndPatch with two executable - [b]XMLDiff.exe[/b] and [b]XMLPatch.exe[/b].
17
+
[/list]
18
+
[size=100][b]How to create a diff file[/b][/size]
19
+
There is a command line help for the [b]XMLDiff[/b] tool:
20
+
[code]
21
+
XMLDiff 0.2.13
22
+
Developed by Chem O`Dun
23
+
24
+
-o, --original_xml Required. Path to the original XML file or directory.
25
+
26
+
-m, --modified_xml Required. Path to the modified XML file or directory.
27
+
28
+
-d, --diff_xml Required. Path for the diff XML file or directory.
29
+
30
+
-x, --xsd Path to the diff.xsd schema file.
31
+
32
+
-l, --log-to-file (Default: false) Log to a file.
33
+
34
+
--only-full-path (Default: false) Generate only full path.
35
+
36
+
--use-all-attributes (Default: false) Use all attributes in XPath.
<replace sel="//do_if[@value="@$speak and not this.assignedcontrolled.nextorder and (@$defaultorder.id != 'Patrol') and (@$defaultorder.id != 'ProtectPosition') and (@$defaultorder.id != 'ProtectShip') and (@$defaultorder.id != 'ProtectStation') and (@$defaultorder.id != 'Plunder') and (@$defaultorder.id != 'Police') and (not this.assignedcontrolled.commander or (this.assignedcontrolled.commander == player.occupiedship)) and notification.npc_await_orders.active"]/@value">@$speak and not this.assignedcontrolled.nextorder and (@$defaultorder.id != 'ProtectSector') and (@$defaultorder.id != 'Patrol') and (@$defaultorder.id != 'ProtectPosition') and (@$defaultorder.id != 'ProtectShip') and (@$defaultorder.id != 'ProtectStation') and (@$defaultorder.id != 'Plunder') and (@$defaultorder.id != 'Police') and (not this.assignedcontrolled.commander or (this.assignedcontrolled.commander == player.occupiedship)) and notification.npc_await_orders.active</replace>
71
+
</diff>
72
+
```
73
+
[size=90][b]Path options[/b][/size]
74
+
75
+
[size=80][b]Only full path[/b][/size]
76
+
The [b]--only-full-path[/b] option will generate only the full path to the element in the XML file. It is mean - there no [b]//[/b] will be in the [b]sel[/b] attribute of the [b]add[/b], [b]replace[/b] or [b]remove[/b] element.
[size=80][b]Use all attributes in XPath[/b][/size]
96
+
The [b]--use-all-attributes[/b] option will generate the [b]sel[/b] attribute with all attributes of the element in the XML file. It is mean - there will be all attributes of the element in the [b]sel[/b] attribute of the [b]add[/b], [b]replace[/b] or [b]remove[/b] element.
<do_if value="@$speak and not this.assignedcontrolled.nextorder and (@$defaultorder.id != 'Patrol') and (@$defaultorder.id != 'ProtectSector') and (@$defaultorder.id != 'ProtectPosition') and (@$defaultorder.id != 'ProtectShip') and (@$defaultorder.id != 'ProtectStation') and (@$defaultorder.id != 'Plunder') and (@$defaultorder.id != 'Police') and (not this.assignedcontrolled.commander or (this.assignedcontrolled.commander == player.occupiedship)) and notification.npc_await_orders.active">
[size=100][b]If output XML is a directory[/b][/size]
181
+
If the output XML is a directory, the tool will create a new XML file with the same name as the original XML file in the output directory.
182
+
For example, if the original XML file is [b]vanilla.xml[/b] and the output directory is [b]output[/b], the tool will create a new XML file [b]output/vanilla.xml[/b].
183
+
184
+
[size=100][b]How to apply a tools to a directories[/b][/size]
185
+
You can apply the tools to directories. In this case, the tools will apply the diff or patch to all XML files in the directory.
186
+
The logic will be a next:
187
+
[*] all input parameters are directories - the tools will apply the diff or patch to all XML files in the directories.
188
+
[*] it will recursively gro thru the diff or changed XML files in the directories, respectively to the tool.
189
+
[*] for each diff or changed files will be checked a corresponding original XML file in the original directory with the same relative path.
190
+
[*] if the original XML file is not found - the diff or changed file will be skipped.
191
+
[*] if the original XML file is found - the diff or changed file will be patched with the original XML file and created a new patched XML file in the output directory with the same relative path.
0 commit comments