Skip to content
jan-vcapgemini edited this page Aug 12, 2020 · 9 revisions

LeXeMerger

Build State

https://maven-badges.herokuapp.com/maven-central/com.github.maybeec/lexeme/

Branch Build Coverage

master

Build Status

https://coveralls.io/r/maybeec/lexeme?branch=master

development

Build Status

https://coveralls.io/r/maybeec/lexeme?branch=development

Description

The Language-aware XML Merger (for short LeXeMe) is a 2-way XML merger that allows to influence the structural merge by declaring additional structural information. Therefore, a so called merge schema can be specified for each namespace, which itself is a XML document that will be parsed and used by LeXeMe as an additional input for the structural merge.

Features

A merge schema allows to specify …​

  • …​ what properties of a XML element should be considered while matching elements from the base with elements from the patch

  • …​ XML elements can or should occur only once or more often as children of a specific XML node

  • …​ whether the value of an attribute of the patch is allowed to be attached to the base value or not

  • …​ whether the textual content of an XML node of the patch is allowed to be attached to the base textual content or not

  • …​ different merge rules (called handlings) depending on the XML elements location in the DOM node tree

LeXeMe is able to …​

  • …​ perform four conflict handlings (override with patch’s or base’s contents as well as attaching attributes and text contents when it’s desired or not)

  • …​ optionally validate the merge result

Usage

The api of the LeXeMe library is the LeXeMerger class.

To instanciate a merger you need to specify a folder in that LeXeMe will search for merge schemas. The merge process will use default settings for each namespace that has no merge schema in that folder. The merger is now set and ready to merge XMl documents. Depending on the namespace of the documents the algorithm chooses the corresponding merge schema (if one is found).

LeXeMerger merger = LeXeMergerFactory.build("path/to/merge/schemas/");
org.jdom2.Document result = merger.merge(org.jdom2.Document baseDoc, org.jdom2.Document patchDoc, ConflictHandlingType c);

Interfaces

LeXeMe provides multiple interfaces for the merge() method using org.jdom2, java.nio.File and plain String objects:

org.jdom2.Document merge(Document base, Document patch, ConflictHandlingType c)
org.jdom2.Element merge(Element base, Element patch, ConflictHandlingType c)
org.jdom2.Document merge(File base, String patch, String charset, ConflictHandlingType c)
String mergeInString(File base, String patch, String charset, ConflictHandlingType c)

ConflictHandlingTypes

Take a look at ConflictHandlingType enum for available conflict handling strategies during the merge process.

Clone this wiki locally