JAX-SB Compiler

The JAX-SB Compiler, which is responsible for the compilation stage of the binding generation process.

License

License

GroupId

GroupId

org.jaxsb
ArtifactId

ArtifactId

compiler
Last Version

Last Version

2.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

JAX-SB Compiler
The JAX-SB Compiler, which is responsible for the compilation stage of the binding generation process.
Project Organization

Project Organization

JAX-SB

Download compiler

How to add to project

<!-- https://jarcasting.com/artifacts/org.jaxsb/compiler/ -->
<dependency>
    <groupId>org.jaxsb</groupId>
    <artifactId>compiler</artifactId>
    <version>2.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.jaxsb/compiler/
implementation 'org.jaxsb:compiler:2.1.6'
// https://jarcasting.com/artifacts/org.jaxsb/compiler/
implementation ("org.jaxsb:compiler:2.1.6")
'org.jaxsb:compiler:jar:2.1.6'
<dependency org="org.jaxsb" name="compiler" rev="2.1.6">
  <artifact name="compiler" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jaxsb', module='compiler', version='2.1.6')
)
libraryDependencies += "org.jaxsb" % "compiler" % "2.1.6"
[org.jaxsb/compiler "2.1.6"]

Dependencies

compile (2)

Group / Artifact Type Version
org.openjax.xml : sax jar 0.9.4
ch.qos.logback : logback-classic jar 1.2.3

test (3)

Group / Artifact Type Version
org.libj : test jar 0.7.1
junit : junit jar 4.12
org.mockito : mockito-core jar 3.1.0

Project Modules

There are no modules declared in this project.

JAX-SB

Build Status Coverage Status Javadocs Released Version Snapshot Version

Introduction

JAX-SB is a Java framework for binding to XML Schemas. The JAX-SB framework provides a complete solution for cohesive integration of Java applications to XML Documents via XML Schemas. The framework provides a JAX-SB Java Source Code Generator and a JAX-SB Runtime to parse and marshal XML Documents to and from Java objects. The JAX-SB framework is a complete implementation and covers the entirety of the XSD 1.1 Specification.

Features

Supports entire XSD Specification

JAX-SB supports all directives of the XSD Specification, and generates bindings with highest degree of cohesion possible with the Java language. JAX-SB supports the following:

Namespaces

JAX-SB provides complete binding to the namespaces and types defined in XML Schemas (import and include), and preserves prefix definitions.

Structural

JAX-SB provides binding to simpleType, complexType, element, group, attribute, attributeGroup, notation, any and anyAttribute structural types.

Non-structural

JAX-SB provides binding to annotation, documentation, key, keyref and unique.

Relational

JAX-SB provides binding to xs:type, xs:ref, all, sequence, choice,

Definition facets

JAX-SB provides binding to the complexContent, restriction, extension, list and union facets.

restriction facets

JAX-SB provides binding to the enumeration, pattern and [min|max][Inclusive|Exclusive].

xsi:type and redefine facets

JAX-SB properly binds to elements that use the xsi:type and redefine directives, which is represented by Java's class inheritance model.

Getting Started

Prerequisites

  • Java 8 - The minimum required JDK version.
  • Maven - The dependency management system.

Example

  1. Create a example.xsd XML Schema and put it in src/main/resources/.

    <xs:schema
      elementFormDefault="qualified"
      targetNamespace="http://mycompany.com/app/example.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <xs:element name="example">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="hello">
              <xs:complexType>
                <xs:attribute name="world" type="xs:boolean" use="required"/>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
    </xs:schema>
  2. Add the org.jaxsb:jaxsb-maven-plugin to the POM.

    <plugin>
      <groupId>org.jaxsb</groupId>
      <artifactId>jaxsb-maven-plugin</artifactId>
      <version>2.1.6</version>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <destDir>${project.build.directory}/generated-sources/jaxsb</destDir>
            <schemas>
              <schema>src/main/resources/example.xsd</schema>
            </schemas>
          </configuration>
        </execution>
      </executions>
    </plugin>
  3. Add the org.jaxsb:jaxsb-runtime dependency to the POM.

    <dependency>
      <groupId>org.jaxsb</groupId>
      <artifactId>runtime</artifactId>
      <version>2.1.6</version>
    </dependency>
  4. Run mvn install. Upon successful execution of the jaxsb-maven-plugin, a new path will be generated in target/generated-sources/jaxsb. Add this path to your Build Paths in your IDE to integrate into your project. A class by the name of com.mycompany.app.example.xe contains the bindings to example.xsd.

  5. Create a XML Document in src/test/resources.

    <example
      xmlns="http://mycompany.com/app/example.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://mycompany.com/app/example.xsd ../../main/resources/example.xsd">
    
      <hello world="true"/>
    
    </example>
  6. To parse the XML file into Java objects. In your App.java:

    ex_example example = (ex_example)Bindings.parse(new InputSource(Resources.getResourceOrFile("example.xml").getURL().openStream()));
  7. To marshal JAX-SB Java objects to a XML String:

    System.out.println(DOMs.domToString(Bindings.marshal(example), DOMStyle.INDENT));

Samples

Samples are provided in the JAX-SB source code:

git clone [email protected]:jaxsb/jaxsb.git
cd jaxsb/sample
mvn install

Tutorials

Tutorials are provided in the JAX-SB source code:

git clone [email protected]:jaxsb/jaxsb.git
cd jaxsb/tutorial
mvn install

Known Issues

The JAX-SB framework is not suitable for processing of large XML Documents (in the 100s of MBs). Built on top of Java's org.w3c.dom implementation of the Document Object Model (DOM) Level 3 Core Specification, XML Documents parsed and marshalled by JAX-SB consume a significant amount of memory. Work is underway for JAX-SB v3 to use Java's SAX Parser, which will allow the framework to process XML Documents of unbounded size.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Versions

Version
2.1.6
2.1.5
2.1.4