Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elomagic/xsd-model
Object model of the XSD
https://github.com/elomagic/xsd-model
binding jarkartaee java java17 xsd
Last synced: about 16 hours ago
JSON representation
Object model of the XSD
- Host: GitHub
- URL: https://github.com/elomagic/xsd-model
- Owner: elomagic
- License: apache-2.0
- Created: 2017-08-30T15:53:26.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T16:20:27.000Z (14 days ago)
- Last Synced: 2024-10-23T22:37:17.537Z (14 days ago)
- Topics: binding, jarkartaee, java, java17, xsd
- Language: Java
- Homepage:
- Size: 455 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# xsd-model - Simple object model of the XSD file
---
[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license]
[![Maven Central](https://img.shields.io/maven-central/v/de.elomagic/xsd-model.svg?label=Maven%20Central)](https://mvnrepository.com/artifact/de.elomagic/xsd-model)
[![build workflow](https://github.com/elomagic/xsd-model/actions/workflows/maven.yml/badge.svg)](https://github.com/elomagic/xsd-model/actions)
[![GitHub issues](https://img.shields.io/github/issues-raw/elomagic/xsd-model)](https://github.com/elomagic/xsd-model/issues)
[![GitHub tag](https://img.shields.io/github/tag/elomagic/xsd-model.svg)](https://GitHub.com/elomagic/xsd-model/tags/)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/elomagic/xsd-model/graphs/commit-activity)
[![Buymeacoffee](https://badgen.net/badge/icon/buymeacoffee?icon=buymeacoffee&label)](https://www.buymeacoffee.com/elomagic)## What is this xsd-model ? ###
This project is a Java library to ease up the reading of XSD files.
* Supports Java 17 or higher
* Supports Jakarta XML Binding 4.0## 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
...
de.elomagic
xsd-model
[3,]
...
```
## Using the API
### Read a XSD file
```java
import de.elomagic.xsdmodel.XsdReader;
import de.elomagic.xsdmodel.elements.XsdSchema;import java.nio.file.Paths;
class Sample {
void example() throws Exception {
System.setProperty(XsdSchemaFactory.XSD_SCHEMA_FACTORY_CLASS, XsdSchemaFactoryMock.class.getName());XsdSchema schema = XsdReader.read(Paths.get("root2.xsd"));
Assertions.assertEquals("Documentation of the schema annotation.", schema.getAnnotation().getDocumentation().getValue());
Assertions.assertEquals(12, schema.getComplexTypes().size());
}
}
```### Convert XSD to key map
Very experimental implementation of mapping a XSD to key a map.
```java
import de.elomagic.xsdmodel.XsdReader;
import de.elomagic.xsdmodel.converter.Xsd2KeyValueConverter;import java.nio.file.Paths;
class Sample {
void example() throws Exception {
Xsd2KeyValueConverter converter = new Xsd2KeyValueConverter<>()
.setKeyDelimiter(".")
.setAttributeDelimiter("#")
.setAttributeSupport(true)
.setKeyPropertySupplier(KeyProperties::new);Map map = converter.convert(getClass().getResourceAsStream("/example.xsd"));
map.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(e -> System.out.println(e.getKey() + "=" + e.getValue().getDatatype()));
}
}
```#### Limitations
* No repetition support
* No attribution support
* No recursive element type support
* Simple restriction support## How to build artefact by myself?
What you need is an installed JDK at least version 17 and [Apache Maven](https://maven.apache.org).
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](../../issues/new).
### Versioning
Versioning follows the semantic of [Semantic Versioning 2.0.0](https://semver.org/)
### Releasing new version / hotfix (Only for users who have repository permissions)
#### Releasing new version / hotfix
Execute following steps:
* Are the [CHANGELOG.md](https://github.com/elomagic/xsd-model/blob/main/CHANGELOG.md) up to date?
* Check the version in the ```pom.xml``` and [CHANGELOG.md](https://github.com/elomagic/xsd-model/blob/main/CHANGELOG.md)
* Set release date in the [CHANGELOG.md](https://github.com/elomagic/xsd-model/blob/main/CHANGELOG.md)
* Execute GitHub action "release"## Who do I talk to? ###
* Repo owner or admin
## License
The xsd-model is distributed under [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
[license]: https://www.apache.org/licenses/LICENSE-2.0