Skip to content

Commit

Permalink
Updating this library to the latest versions and cleaning stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
herminiogg committed Jan 18, 2024
1 parent 5cda06c commit ef8d406
Show file tree
Hide file tree
Showing 28 changed files with 162 additions and 219 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
30 changes: 15 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name := "xmlschema2shex"
ThisBuild / organization := "com.herminiogarcia"

organization := "es.weso"

version := "0.1-SNAPSHOT"

scalaVersion := "2.12.8"

resolvers += "jitpack" at "https://jitpack.io"

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.2" % "test"
libraryDependencies += "com.github.herminiogg" % "ShExML" % "0.2.5"
libraryDependencies += "info.picocli" % "picocli" % "4.0.4"

mainClass in (Compile, run) := Some("es.weso.xmlschema2shex.Main")
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",
)
)
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

This file was deleted.

83 changes: 0 additions & 83 deletions src/main/scala-2.12/es/weso/xmlschema2shex/parser/Parser.scala

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package es.weso.xmlschema2shex
package com.herminiogarcia.xmlschema2shex

import com.herminiogarcia.xmlschema2shex.parser.XMLSchema2ShexParser
import java.io.FileWriter
import java.util.concurrent.Callable

import es.weso.xmlschema2shex.parser.XMLSchema2ShexParser
import picocli.CommandLine
import picocli.CommandLine.{Command, Option}

Expand Down Expand Up @@ -43,7 +42,7 @@ class Main extends Callable[Int] {
fw.close()
}
println(result)
0
1
} finally { fileHandler.close() }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.weso.xmlschema2shex.ast
package com.herminiogarcia.xmlschema2shex.ast

/**
* Created by herminio on 4/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.check
package com.herminiogarcia.xmlschema2shex.check

import es.weso.xmlschema2shex.ast._
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, Restriction, Schema, SimpleType, Tag, Type, Typeable}

/**
* Created by herminio on 5/10/16.
Expand Down Expand Up @@ -44,7 +44,7 @@ class SemanticChecker(val schema: Schema) {
}

def checkRestriction(restriction: Restriction): Unit = {
restriction.restrictions.foreach(println(_))
//restriction.restrictions.foreach(println(_))
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.decorator
package com.herminiogarcia.xmlschema2shex.decorator

import es.weso.xmlschema2shex.ast.{ComplexType, Schema, Element}
import com.herminiogarcia.xmlschema2shex.ast.{ComplexType, Schema}

/**
* Created by herminio on 6/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.decorator
package com.herminiogarcia.xmlschema2shex.decorator

import es.weso.xmlschema2shex.ast._
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, Attributes, ComplexType, Element, Schema, SimpleType, Tag, Type, Typeable, XSDAnyURI, XSDBase64Binary, XSDBoolean, XSDByte, XSDDate, XSDDateTime, XSDDecimal, XSDDouble, XSDDuration, XSDENTITY, XSDGDay, XSDGMonth, XSDGMonthDay, XSDGYear, XSDGYearMonth, XSDHexBinary, XSDID, XSDIDREF, XSDIDREFS, XSDInt, XSDInteger, XSDLong, XSDNCName, XSDNMTokens, XSDName, XSDNegativeInteger, XSDNonPositiveInteger, XSDNotation, XSDPositiveInteger, XSDQName, XSDShort, XSDString, XSDTime, XSDType, XSDUnsignedByte, XSDUnsignedInt, XSDUnsignedLong, XSDUnsignedShort, XSNMToken}

/**
* Created by herminio on 6/10/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.xmlschema2shex.ast._
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, ElementsHolder, Schema, SimpleType, Typeable, XSDType, XSNMToken}

/**
* Created by herminio on 5/10/16.
Expand Down Expand Up @@ -70,7 +70,7 @@ class CodeGenerator(schema: Schema) {
case Some(theName) => ":" + theName
case None => element.ref match {
case Some(ref) => ":" + ref
case None => None
case None => ""
}
}
val typeString = element.aType match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.xmlschema2shex.ast._
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, ElementsHolder, Schema, SimpleType, Typeable, XSDType, XSNMToken}

/**
* Created by herminio on 5/10/16.
Expand Down Expand Up @@ -70,7 +70,7 @@ class CodeGeneratorShExML(schema: Schema) {
case Some(theName) => "FIELD " + theName + " <"+ theName +">"
case None => element.ref match {
case Some(ref) => ":" + ref
case None => None
case None => ""
}
}
val typeString = element.aType match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.xmlschema2shex.ast.Typeable
import com.herminiogarcia.xmlschema2shex.ast.Typeable

trait NameNormalizator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.shexml.ast.{AutoIncrement, DataType, DataTypeGeneration, DataTypeLiteral, Declaration, Expression, Field, Iterator, IteratorQuery, NestedIterator, ObjectElement, PredicateObject, Prefix, QueryClause, ShExML, Shape, ShapeLink, Source, URL, Var}
import com.herminiogarcia.shexml.ast.{Action, AutoIncrement, DataType, DataTypeGeneration, DataTypeLiteral, Declaration, Expression, Field, Iterator, IteratorQuery, LiteralSubject, NestedIterator, ObjectElement, PredicateObject, Prefix, QueryClause, ShExML, Shape, ShapeLink, ShapeVar, Source, URL, Var}

class ShExMLPrinter {

Expand Down Expand Up @@ -49,18 +49,26 @@ class ShExMLPrinter {

def print(s: Shape, indentation: Int): String = {
val shapeAction = s.action match {
case Var(action) => action
case Action(_, action, _) => action match {
case Var(name) => name
case _ => throw new Exception("Not supported")
}
case LiteralSubject(_, value) => value
case _ => ""
}
val shapePrefix = s.action match {
case Action(shapePrefix, _, _) => shapePrefix
case LiteralSubject(prefix, _) => prefix.name
}
generateIndentation(indentation) +
s.shapeName.name + " " + s.shapePrefix + "[" + shapeAction + "] {\n" +
s.shapeName.name + " " + shapePrefix + "[" + shapeAction + "] {\n" +
s.predicateObjects.map(po => print(po, indentation + 1)).mkString("") +
"}\n"
}

def print(po: PredicateObject, indentation: Int): String = {
val objectPart = po.objectOrShapeLink match {
case ObjectElement(prefix, action, literalValue, matcher, dataType, langTag, None) => literalValue match {
case ObjectElement(prefix, action, literalValue, matcher, None, dataType, langTag, None) => literalValue match {
case Some(literal) => prefix + literal + printDatatype(dataType)
case None => {
val actionString = if(action.isDefined) action.get.asInstanceOf[Var].name else ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, Schema, SimpleType, Tag, Typeable}
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, Schema, SimpleType, Tag, Typeable}

import scala.collection.mutable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.shexml.ast.{AST, Declaration, DeclarationStatement, Expression, Field, FieldQuery, Iterator, IteratorQuery, NestedIterator, Prefix, QueryClause, ShExML, Source, URL, Var, XmlPath}
import es.weso.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, ElementsHolder, Schema, Sequence, SimpleType, Typeable}
import com.herminiogarcia.shexml.ast.{AST, Declaration, DeclarationStatement, Expression, Field, FieldQuery, Iterator, IteratorQuery, NestedIterator, Prefix, QueryClause, ShExML, Source, URL, Var, XmlPath}
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, ElementsHolder, Schema, Sequence, SimpleType, Typeable}

class XMLSchema2ShExMLDeclarationsConverter(schema: Schema, implicit val varTable: Map[String, Typeable]) extends NameNormalizator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.weso.xmlschema2shex.generation
package com.herminiogarcia.xmlschema2shex.generation

import es.weso.shexml.ast.{DataTypeLiteral, ExpOrVar, ObjectElement, Predicate, PredicateObject, ShExML, Shape, ShapeLink, ShapeVar, Var}
import es.weso.xmlschema2shex.ast._
import com.herminiogarcia.shexml.ast.{Action, DataTypeLiteral, ExpOrVar, ObjectElement, Predicate, PredicateObject, ShExML, Shape, ShapeLink, ShapeVar, Var}
import com.herminiogarcia.xmlschema2shex.ast.{AttributeElement, ComplexType, Element, ElementsHolder, Schema, SimpleType, Typeable, XSDType, XSNMToken}

/**
* Created by herminio on 5/10/16.
Expand Down Expand Up @@ -42,9 +42,9 @@ class XMLSchema2ShExMLShapesGeneration(schema: Schema) extends NameNormalizator
&& po.objectOrShapeLink.isInstanceOf[ObjectElement]) match {
case Some(id) => id.objectOrShapeLink.asInstanceOf[ObjectElement].action.orNull
case None => Var("subjectAutoincrementId")

}
val shape = Shape(shapeVar, prefix, action, predicateObjects, None)
val actionObject = Action(prefix, action, None)
val shape = Shape(shapeVar, actionObject, predicateObjects, None)

for(element <- complexType.elementsHolder.elements) yield element.aType match {
case Some(nestedType) => nestedType match {
Expand Down Expand Up @@ -95,15 +95,15 @@ class XMLSchema2ShExMLShapesGeneration(schema: Schema) extends NameNormalizator
s.restriction match {
case Some(restriction) => restriction.base match {
case Some(name) =>
ObjectElement("", action, None, None, Some(DataTypeLiteral(normalizeName(name))), None, None)
case None => ObjectElement("", action, None, None, s.name.map(DataTypeLiteral), None, None)
ObjectElement("", action, None, None, None, Some(DataTypeLiteral(normalizeName(name))), None, None)
case None => ObjectElement("", action, None, None, None, s.name.map(DataTypeLiteral.apply), None, None)
}
case None => ObjectElement("", action, None, None, s.name.map(DataTypeLiteral), None, None)
case None => ObjectElement("", action, None, None, None, s.name.map(DataTypeLiteral.apply), None, None)
}
}
case x: XSDType => x match {
case p: XSNMToken => ObjectElement(getDefaultPrefix(), action, None, None, None, None, None) // that will be pattern but not supported right now in ShExML
case _ => ObjectElement("", action, None, None, Some(DataTypeLiteral(x.name)), None, None)
case p: XSNMToken => ObjectElement(getDefaultPrefix(), action, None, None, None, None, None, None) // that will be pattern but not supported right now in ShExML
case _ => ObjectElement("", action, None, None, None, Some(DataTypeLiteral(x.name)), None, None)
}
}
}
Expand Down
Loading

0 comments on commit ef8d406

Please sign in to comment.