Skip to content

elomagic/xmltools

Repository files navigation

xmltools - Tooling for managing XML


build workflow GitHub issues GitHub tag Maintenance Buymeacoffee

What is this xmltools ?

This project is a Java library to ease up the handling of XML files.

  • Supports Java 17 or higher

Current limitations

  • XML mixed content not supported

Using the library

Maven

Add following dependency to your project. Replace the value of the attribute version according to the used version in your project.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">

    ...

    <dependencies>
        <dependency>
            <groupId>de.elomagic</groupId>
            <artifactId>xmltools</artifactId>
            <version>[1,]</version>
        </dependency>
    </dependencies>
    
    ...
    
</project>

Using the API

Convert XML to key values

import de.elomagic.xmltools.Xml2KeyValueConverter;

import org.w3c.dom.Document;

import java.nio.file.Paths;

class Sample {

  void example() throws Exception {
    Xml2KeyValueConverter converter = new Xml2KeyValueConverter();
    Map<String, String> map = converter.convert(Paths.get("document.xml"));
  }

}

Convert key values to XML

import de.elomagic.xmltools.KeyValue2XmlConverter;
import org.w3c.dom.Document;
import java.util.Map;

class Sample {

    void example() throws Exception {
        Map<String, String> map = Map.of(
            "de.elomagic.a", "1234",
            "de.elomagic.b", "5678"
        );

        KeyValue2XmlConverter converter = new KeyValue2XmlConverter();
        Document document = converter.convert(map);
    }

}

How to build artefact by myself?

What you need is an installed JDK at least version 17 and Apache Maven. Then clone this project to your local file system and execute mvn clean install in the project folder. After successful finish you find the artefact in the target folder.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Versioning

Versioning follows the semantic of Semantic Versioning 2.0.0

Releasing new version / hotfix (Only for users who have repository permissions)

Releasing new version / hotfix

Execute following steps:

  • Are the CHANGELOG.md up to date?
  • Check the version in the pom.xml and CHANGELOG.md
  • Set release date in the CHANGELOG.md
  • Credentials (Nexus, GitHub) up to date?
  • Execute Maven release process
    mvn clean install release:prepare -P release
    mvn release:perform -P release

Releasing snapshot package on GitHub

Execute Maven deploy process

mvn clean install deploy

Who do I talk to?

  • Repo owner or admin

License

The xmltools is distributed under Apache License, Version 2.0