Skip to content

Syntea/xdef

Repository files navigation

About X-definition

X-definition is registered technology of the Syntea software group a.s., for processing of the XML documents or JSON data.

For the purpose of describing the structure of XML documents or JSON data, their validation, processing and creation, this tool was developed by Syntea Software Group Inc. It allows the user to not only define the structure of XML documents or JSON data, but also to describe specifically their processing and construction.

Homepage: http://www.xdef.org

This project is an implementation for the platform Java 1.8+ (additional note: up to the version 41.0.4 for the platform Java 1.6+).

License

The source code for this project is licensed under Apache 2.0 license.

Illustrative examples

You can try the following examples online at: http://xdef.syntea.cz/tutorial/examples/validate.html

Example 1: Essential concepts

Let´s have the following XML data:
<Employee
  FirstName = "Andrew"
  LastName  = "Aardvark"
  EnterDate = "1996-03-12"
  Salary    = "21700"
>
  <Address
    Street = "Broadway"
    Number = "255"
    Town   = "Beverly Hills"
    State  = "CA"
    Zip    = "90210"
  />
  <Competence>electrician</Competence>
  <Competence>carpenter</Competence>
</Employee>
This is the complete X-definition file with the model of the XML data on the left:
<xd:def
  xmlns:xd = "http://www.xdef.org/xdef/4.2"
  xd:root  = "Employee"
>
  <Employee
    FirstName = "required string()"
    LastName  = "required string()"
    EnterDate = "required date()"
    Salary    = "optional decimal()"
  >
    <Address
      Street = "required string()"
      Number = "required int()"
      Town   = "required string()"
      State  = "required string()"
      Zip    = "required int()"
    />
    <Competence xd:script = "occurs 1..5">
      required string()
    </Competence>
  </Employee>
</xd:def>

Example 2: References

XML data:
<Family>
  <Father
    GivenName  = "John"
    FamilyName = "Smith"
    PersonalID = "7107130345"
    Salary     = "18800"
  />
  <Mother
    GivenName  = "Jane"
    FamilyName = "Smith"
    PersonalID = "7653220029"
    Salary     = "19400"
  />
  <Son
    GivenName  = "John"
    FamilyName = "Smith"
    PersonalID = "9211090121"
  />
  <Daughter
    GivenName  = "Jane"
    FamilyName = "Smith"
    PersonalID = "9655270067"
  />
  <Residence
    Street     = "Small"
    Number     = "5"
    Town       = "Big"
    Zip        = "12300"
  />
</Family>
Model of the XML data:
<xd:def
  xmlns:xd = "http://www.xdef.org/xdef/4.2"
  xd:root  = "Family"
>
  <Family>
    <Father    xd:script = "occurs 0..1; ref Person"  />
    <Mother    xd:script = "occurs 1..1; ref Person"  />
    <Son       xd:script = "occurs 0..*; ref Person"  />
    <Daughter  xd:script = "occurs 0..*; ref Person " />
    <Residence xd:script = "occurs 1;    ref Address" />
  </Family>
  
  <Person
    GivenName  = "string()" 
    FamilyName = "string()" 
    PersonalID = "long()"
    Salary     = "optional int()"
  />
  <Address
    Street = "string()"
    Number = "int()"
    Town   = "string()"
    Zip    = "int()"
  />
</xd:def>

Annotation

This document describes the programming language and the technology called “X‑definition“. X‑definition is designed for description and processing of data in the form of XML or JSON.

X-definition is a tool that provides the description of both the structure and the properties of data values in an XML document. Moreover, the X-definition allows the description of the processing of specified XML objects. Thus X‑definitions may replace existing technologies commonly used for XML validation - namely the DTD (Data Type Definition) or the XML schemas and Schematron. With X-definition it is also possible to describe the construction of XML documents (or the transformation of XML data). X-definitions provides also generation of JAVA class objects similar way as JAXB technology.

X-definition enables the merging in one source of both the validation of XML documents and processing of data (i.e. using actions assigned to events when XML objects are processed). Compared to the “classical” technologies based on DTD and XML schemas, the advantage of X-definitions is (not only) higher readability and easier maintenance. X‑definition has been designed for processing of XML data files of unlimited size, up to many gigabytes.

A principal property of X-definition is maximum respect for the structure of the described data. The form of X‑definition is an XML document with a structure similar to the described XML data. This makes possible quickly and intuitively describe given XML data and its processing. In many cases it requires just to replace the values in the XML data by the description written in the X‑definition X‑script language. You can also gradually add to your X‑script required actions providing data processing. You can take a step-by-step approach to your work.

It is assumed that the reader already knows the elementary principles of XML. To get the most out of this document, you should also have at least basic knowledge of the Java programming language.

X‑definition technology enables also to generate the source code of Java classes representing XML elements described by X‑definition. Such class is called X‑component. You can use the instances of XML data in the form of X‑components in Java programs (similar way as in the JAXB technology).

The term "X‑definition" we use in the two different meanings: either as a name of the programming language or as an XML element containing the code of X‑definition language.

Documentation and online playground

For the complete documentation see the directory xdef/src/documentation.

You can try your X-definition examples at following online playgrounds:

Usage in other projects

Check and download available versions

Links:

Package content

List of file assets:

  • xdef-{version}.jar - the java-library X-definition
  • xdef-{version}-userdoc-en.zip - complete user documentation and tutorial examples
  • xdef-{version}-javadoc.jar - html-documentation of java source code generated from the java source code
  • xdef-{version}-sources.jar - origin java source code
  • xdef-{version}-src.zip - java source code insertable directly into your source code, very similar to xdef-{version}-sources.jar
  • xdef-{version}.pom - maven metadata of the package

For maven projects

Configuration file pom.xml:

  • dependency on a release version in the central maven repository:

    <dependencies>
        <dependency>
            <groupId>org.xdef</groupId>
            <artifactId>xdef</artifactId>
            <version>[release version]</version>
        </dependency>
    <dependencies>
  • dependency on a snapshot (or also release) version in the central maven snapshot repository:

    <dependencies>
        <dependency>
            <groupId>org.xdef</groupId>
            <artifactId>xdef</artifactId>
            <version>[snapshot (or also release) version]</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>central-snapshot</id>
            <url>https://central.sonatype.com/repository/maven-snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>

Building this project

Source code at GitHub:

Prerequisities:

  • download project X-definition, e.g. from GitHub
    • for example git-command: git clone [email protected]:Syntea/xdef.git
    • git-repo uses file system symbolic links. If it's not enabled in your git, it can be enabled by two git-commands (run from the git-project root directory) "git config set core.symlinks true", "git reset --hard". For example, on Linux OS it is enabled by default. For example, on Windows OS it is disabled by default and in addition, "Developer Mode" (Start > Settings > Update & Security > For developers > Developer Mode > On) must be enabled in the system settings beforehand
  • install java (at least version 8)
  • install maven (at least version 3.6)
  • configuration:

Frequent building operations:

  • cleaning before any compiling, building, deploying, etc.:

    mvn clean
  • compile all java-resources, respectively all compilable resources:

    mvn compile
  • build the snapshot package:

    mvn package
  • build the snapshot package including documentation, javadoc, sources:

    mvn package -Pdoc
  • using the profile "skipTests", avoid junit-tests:

    mvn package -PskipTests
  • using the profile "testOnAllJvms", junit-tests will be run on all configured Java platforms, i.e.:

    • Java-8 (by default it is run in the module "xdef")
    • Java-11 (it is run in the module "xdef-test11")
    • Java-17 (it is run in the module "xdef-test17")
    • Java-21 (it is run in the module "xdef-test21")
    mvn package -PtestOnAllJvms
  • build the release package:

    mvn package -Prelease
  • build the release package including documentation, javadoc, sources:

    mvn package -Prelease,doc

Deploying to the maven central repository

Prerequisities:

Deploying:

  • build and deploy the X-definition snapshot package to the central maven snapshot repository (immediate deploy without processes validation and publishing):

    mvn deploy -Pdoc,dm-central
  • build and deploy the X-definition release package to the central maven repository

    • you can watch processes uploading, validation and publishing in https://central.sonatype.com/publishing/deployments as logged in appropriate user
    • the central repository requires to sign (this is done by using the profile "sign") deploying release-artifacts (on the other hand, the repository doesn't require to sign deploying snapshot-artifacts)
    mvn deploy -Prelease,doc,dm-central,sign

About

X-definition 4.2 (Open Source Software)

Topics

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages