https://github.com/dataliquid/commons-xml
Simplifying XML Processing and Manipulation with Java
https://github.com/dataliquid/commons-xml
dom-utils xml-creation xml-parsing xml-utils xml-validation xpath
Last synced: 4 months ago
JSON representation
Simplifying XML Processing and Manipulation with Java
- Host: GitHub
- URL: https://github.com/dataliquid/commons-xml
- Owner: dataliquid
- License: apache-2.0
- Created: 2023-05-13T14:00:41.000Z (almost 3 years ago)
- Default Branch: develop
- Last Pushed: 2025-12-02T15:21:53.000Z (5 months ago)
- Last Synced: 2025-12-05T12:45:02.160Z (5 months ago)
- Topics: dom-utils, xml-creation, xml-parsing, xml-utils, xml-validation, xpath
- Language: Java
- Homepage:
- Size: 167 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# commons-xml
[](https://github.com/dataliquid/commons-xml/actions/workflows/ci.yml)
[](https://search.maven.org/artifact/com.dataliquid/commons-xml)
[](https://opensource.org/licenses/Apache-2.0)
A lightweight and efficient Java library for XML processing and manipulation. This library provides comprehensive utilities for parsing, creating, validating, and transforming XML documents with a focus on simplicity and performance.
## Features
- **XML Parsing**: Easy-to-use utilities for parsing XML documents from files, resources, or strings
- **XML Creation**: Programmatic XML document creation with fluent API
- **XPath Support**: Advanced XPath expression support with namespace handling
- **Schema Validation**: Validate XML documents against XSD schemas
- **DOM Manipulation**: Comprehensive DOM utilities for working with XML elements and attributes
- **Namespace Support**: Built-in namespace context management for complex XML documents
## Requirements
- Java 8 or higher (supports Java 8, 11, 17, and 21)
- Maven 3.6 or higher
## Installation
### Maven
```xml
com.dataliquid
commons-xml
1.2.0
```
### Gradle
```gradle
implementation 'com.dataliquid:commons-xml:1.2.0'
```
## Quick Start
Here's a simple example demonstrating XML document creation and manipulation:
```java
import com.dataliquid.commons.xml.DomUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class Example {
public static void main(String[] args) {
// Create an empty XML document using DomUtils
Document document = DomUtils.createDocument();
// Create the root element
Element rootElement = DomUtils.createElement(document, "root");
DomUtils.appendChild(document, rootElement);
// Add a child element
Element childElement = DomUtils.createElement(document, "child");
DomUtils.setTextContent(childElement, "Hello, World!");
DomUtils.appendChild(rootElement, childElement);
// Represent the document as xml string using DomUtils
String xml = DomUtils.asXml(document);
System.out.println("XML: " + xml);
}
}
```
For more detailed examples including XPath queries, namespace handling, and schema validation, see [EXAMPLES.md](EXAMPLES.md).
## Building from Source
To build the project from source:
```bash
git clone https://github.com/dataliquid/commons-xml.git
cd commons-xml
mvn clean install
```
## Running Tests
```bash
mvn test
```
## Contributing
We welcome contributions to the commons-xml project! If you have found a bug, want to propose an improvement, or add a new feature, please follow these steps:
1. Fork the repository
2. Create a new branch for your changes: `git checkout -b feature/my-feature`
3. Make your changes and add tests
4. Run tests to ensure everything works: `mvn test`
5. Commit your changes: `git commit -m 'Add my feature'`
6. Push to your fork: `git push origin feature/my-feature`
7. Create a Pull Request
Please ensure your code follows the existing code style and includes appropriate tests.
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.