Skip to content

Commit

Permalink
Merge pull request #8 from herminiogg/develop
Browse files Browse the repository at this point in the history
Version 0.1.0
  • Loading branch information
herminiogg authored Jan 22, 2024
2 parents 5e325f5 + b0268e2 commit 9cc39bc
Show file tree
Hide file tree
Showing 45 changed files with 2,710 additions and 585 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Scala CI

on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Run tests
run: sbt "+ test"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ project/plugins/project/
.scala_dependencies
.worksheet
.idea/

.bsp
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
language: scala

jdk: openjdk8

scala:
- 2.11.2
- 2.12.4
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 XMLSchema2ShEx

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# XMLSchema2ShEx
[![Master build](https://github.com/herminiogg/xmlschema2shex/actions/workflows/scala.yml/badge.svg?branch=master)](https://github.com/herminiogg/xmlschema2shex/actions/workflows/scala.yml?query=branch%3Amaster)
[![Maven Central](https://img.shields.io/maven-central/v/com.herminiogarcia/xmlschema2shex_3?color=blue)](https://central.sonatype.com/artifact/com.herminiogarcia/xmlschema2shex_3)

XMLSchema2ShEx is a tool to convert XML Schema files to "equivalent" Shape Expressions files. The goal is to support
the translation from XML data to RDF, preserving the validation rules. It is based in the theoretical paper developed
in the companion paper (see the [Publications section](#publications)) and implements a subset of the defined
conversions (see the [Supported features section](#supported-features)).

:heavy_exclamation_mark: An experimental conversion to ShExML is being tested in this library letting users to scaffold
the necessary mapping rules in a semi-automatic fashion and then validate the results.

## Supported features
| Supported features | Pending implementation |
|:------------------:|:----------------------:|
| Complex type | Choice |
| Simple type | List |
| All | Union |
| Attributes | Extension |
| Restriction | Fraction Digits |
| Element | Length |
| Max exclusive | Max Length |
| Min exclusive | Min Length |
| Max inclusive | Total digits |
| Min inclusive | Whitespace |
| Enumeration | Unique |
| Pattern | |
| Cardinality | |

## Usage
The library provides two methods of operation: a CLI through the provided JAR package and a JVM compatible API.

### CLI
The CLI can be called using the command `$ java -jar XMLSchema2ShEx.jar [options]` where options are as described below:

```
Usage: XMLSchema2ShEx [-hsV] -i=<file> [-o=<output>]
Convert from XML Schema to ShEx and more...
-h, --help Show this help message and exit.
-i, --input=<file> Path to XML Schema file
-o, --output=<output> Path where the output file should be created
-s, --shexml Generate ShExML scaffold
-V, --version Print version information and exit.
```

### JVM compatible API
It can also be called from any JVM compatible language that has it as its dependency. The call
should look like similar to the following snippet:

```scala
val shexResult = XMLSchema2ShexParser().parse(input)
val shexmlResult = XMLSchema2ShexParser().convertToShExML(input)
```

## Publications
For citation purposes please use the companion paper:
```
Garcia-Gonzalez, H., & Labra-Gayo, J. E. (2020). XMLSchema2ShEx:
Converting XML validation to RDF validation. Semantic Web, 11(2), 235-253.
```
30 changes: 20 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name := "xmlschema2shex"

organization := "es.weso"

version := "0.1-SNAPSHOT"

scalaVersion := "2.11.8"

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.1" % "test"
ThisBuild / organization := "com.herminiogarcia"

lazy val xmlschema2shex = project
.in(file("."))
.settings(
name := "xmlschema2shex",
version := "0.1.0",
scalaVersion := "3.2.0",
crossScalaVersions := Seq("2.12.17", "2.13.9", "3.2.0"),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.3.0",
"org.scalatest" %% "scalatest" % "3.2.15" % "test",
"com.herminiogarcia" %% "shexml" % "0.4.2" exclude("io.gatling", "gatling-jsonpath"),
"info.picocli" % "picocli" % "4.7.3",
),
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "services", xs@_*) => MergeStrategy.concat
case PathList("META-INF", xs@_*) => MergeStrategy.discard
case x => MergeStrategy.first
}

)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.8
sbt.version = 1.7.2
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
logLevel := Level.Warn
logLevel := Level.Warn
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
24 changes: 24 additions & 0 deletions purchaseOrder.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xs"
targetNamespace="http://tempuri.org/PurchaseOrderSchema.xs"
elementFormDefault="qualified">
<xs:element name="PurchaseOrder" type="PurchaseOrderType"/>
<xs:complexType name="PurchaseOrderType">
<xs:sequence>
<xs:element name="ShipTo" type="USAddress" maxOccurs="2"/>
<xs:element name="BillTo" type="USAddress"/>
</xs:sequence>
<xs:attribute name="OrderDate" type="xs:date"/>
</xs:complexType>

<xs:complexType name="USAddress">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="country" type="xs:NMTOKEN" fixed="US"/>
</xs:complexType>
</xs:schema>
24 changes: 24 additions & 0 deletions purchaseOrderChanges.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xs"
targetNamespace="http://tempuri.org/PurchaseOrderSchema.xs"
elementFormDefault="qualified">
<xs:element name="PurchaseOrder" type="PurchaseOrderType"/>
<xs:complexType name="PurchaseOrderType">
<xs:all>
<xs:element name="ShipTo" type="USAddress" maxOccurs="2"/>
<xs:element name="BillTo" type="USAddress"/>
</xs:all>
<xs:attribute name="OrderDate" type="xs:date"/>
</xs:complexType>

<xs:complexType name="USAddress">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="country" type="xs:NMTOKEN" fixed="US"/>
</xs:complexType>
</xs:schema>
Loading

0 comments on commit 9cc39bc

Please sign in to comment.