feat(xml-diff): add XML diff tool

Compare two pasted XML documents and highlight the differences, mirroring
the JSON diff tool's UI and diff engine. XML is parsed with a native
DOMParser-based normalizer (attributes as @name, text-only leaves as plain
strings) instead of xml-js, and a reconciliation step coerces mismatched
single/repeated element shapes into arrays before diffing so a repeated
element compares cleanly instead of producing a garbled type-mismatch diff.

From PR #1840
Fix #1839

Co-Authored-By: @sharevb
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
authored and ShareVB committed 2026-11-22 21:06:08 +01:00
1 parent 5bbc672017
commit e8f0677f94
29 files changed
+761

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
import DiffsViewer from './diff-viewer/xml-diff-viewer.vue';
import { isValidXML, parseXml } from './xml-diff.parser';
const rawLeftXml = ref('');
const rawRightXml = ref('');
const leftXml = computed(() => parseXml(rawLeftXml.value));
const rightXml = computed(() => parseXml(rawRightXml.value));
const xmlValidationRules = [
{
validator: (value: string) => isValidXML(value),
message: t('tools.xml-diff.texts.message-invalid-xml-format'),
},
];
</script>
<template>
<c-input-text
v-model:value="rawLeftXml"
:validation-rules="xmlValidationRules"
:label="t('tools.xml-diff.texts.label-your-first-xml')"
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-first-xml-here')"
rows="20"
test-id="leftXml"
raw-text
multiline
monospace
/>
<c-input-text
v-model:value="rawRightXml"
:validation-rules="xmlValidationRules"
:label="t('tools.xml-diff.texts.label-your-xml-to-compare')"
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-xml-to-compare-here')"
rows="20"
multiline
test-id="rightXml"
raw-text
monospace
/>
<DiffsViewer :left-xml="leftXml" :right-xml="rightXml" />
</template>