For Modders: XML Diff and Patch. A VS Code extension that automatically generates and applies RFC 5261-compatible XML patch files using XPath selectors, watching modified XML files and producing diffs on save.
Features
- Auto-diff on save: Save a modified XML file and a diff is generated against the original (vanilla) version automatically.
- Auto-patch on save: Save a diff file and it is applied to the original to regenerate the modified file.
- Multiple folder pairs: Configure any number of
modifiedFolder/diffFolderpairs under a singleoriginalFolder, each with an optionalpathPrefix. - Glob pattern support: All folder paths accept
*,?, and**glob wildcards so a single config entry can cover multiple mod directories. - Explorer context menu: Right-click XML files or folders for Reset to Original, Reconstruct from Diff, and Regenerate Diff commands.
- Watch modes:
onSave,onTheFly(debounced filesystem watcher), orcontextMenuOnly. - Settings sidebar: A dedicated explorer panel lets you add, edit, and remove folder pairs per scope (User / Workspace / Folder) without editing JSON directly.
- XSD validation: Optionally validate generated diff files against a schema, with configurable fail behavior.
- Empty diff handling: Choose to write, delete, warn, or warn-and-delete when a save produces no diff operations.
- Orphan cleanup: Regenerating a diff folder removes diff files that no longer have a corresponding modified file.
Requirements
Set xmlDiffAndPatch.originalFolder to the path containing the baseline XML files, then add at least one entry to xmlDiffAndPatch.folderPairs.
Minimal workspace settings example
{
"xmlDiffAndPatch.originalFolder": "C:/Games/X4 Foundations/data",
"xmlDiffAndPatch.folderPairs": [
{
"modifiedFolder": "${workspaceFolder}/src",
"diffFolder": "${workspaceFolder}/diff",
"pathPrefix": "libraries"
}
]
}
originalFolder: Path to the vanilla/baseline XML files. Always required.folderPairs: Array of pairs to process. Each pair needsmodifiedFolderanddiffFolder;pathPrefixis optional (see below).- Use
"."to refer to the workspace folder itself. modifiedFolderanddiffFoldermust not point to the same directory.originalFolder,modifiedFolder, anddiffFoldersupport glob patterns (*,?,**).pathPrefixdoes not support globs: it must be a plain file-system path segment.
Installation
Visual Studio Code Marketplace: XML Diff and Patch
X4: Foundations Usage
X4: Foundations uses RFC 5261 XML patches to allow mods to modify game data without replacing entire files. This extension automates the diff/patch cycle:
- Set
originalFolderto the extracted X4 game-data folder. - Add a folder pair pointing at your mod's source XML and the diff output directory.
- Edit and save your modified XML: the extension writes the RFC 5261 patch automatically.
- Include the diff files in your mod package.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Credits
- Egosoft - for the game itself (In fact - for the series of games)!
- Members of the x4_modding discord channel - for their answers, support, ideas, and inspiration!
Changelog
[0.6.0] - 2026-05-17
- Added
- Initial public version