Coder Social home page Coder Social logo

reaster / schema-gen Goto Github PK

View Code? Open in Web Editor NEW
28.0 4.0 7.0 425 KB

XML Schema code generator outputting Swift, Kotlin and Java

License: Apache License 2.0

Groovy 100.00%
xml-schema kotlin swift java json schema-gen schema-generation code-generation jackson-json-processor jackson

schema-gen's Issues

Invalid `static` keyword for nested Kotlin classes

The generated Kotlin code gets the keyword static added to inner Kotlin classes. This keyword does not exist. In Kotlin, all inner classes are by default static; to have a non-static inner class, Kotlin requires the developer to add the inner keyword in front of the inner class.

Invalid enum and variable names

When generating Kotlin classes from the following schema:
https://edavki.durs.si/Documents/Schemas/Doh_KDVP_9.xsd

I encountered the following issues:

  1. TypeInventoryEnum.Unknown is used but not generated, which causes syntax error.
  2. This seems to be Jackson related, but can also be 'fixed' here: If variable has name with inverse case, for example kDVP, it is serialized to lowercase XML tag 'kdvp' regardless of property localname='KDVP'. Solution: rename var in generated code to lower case ('kdvp'). Note: It seems that XML tag is serialized as lowercase by Jackson if the first letter of var name is lower case, and the second is upper case. The rest is not important.
  3. @JsonPropertyOrder annotation is missing for sequences of XML elements to preserve element order on

serialization.
4. Property @JacksonXmlProperty(namespace=...) is not generated for elements with namespace.

class com.javagen.schema.java.JavaGen, unresolved supertypes: FieldHelper

When building the build.gradle.kts file I get an exception:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.3.0"
    id("com.javagen.schema-gen") version "0.9.1"
}

repositories {
    mavenCentral()
}

dependencies {
    compile(kotlin("stdlib-jdk8"))

    implementation("com.github.ajalt:clikt:1.3.0")
    implementation("io.github.config4k:config4k:0.4.1")
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

schemaGen {
    kotlin {
        srcDir = File("")
    }
}

The exception that is thrown is:

Script compilation error:

  Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
      class com.javagen.schema.java.JavaGen, unresolved supertypes: FieldHelper
  

1 error

Could you explain how this issue van be solved?

Unable to execute DartGenMain.groovy

I have been struggling for several days to get this running. Here is what I have tried so far:

platform: Debian GNU/Linux 10
Groovy Version: 3.0.8 JVM: 1.8.0_292 Vendor: AdoptOpenJDK OS: Linux
working directory: .../schema-gen/src/main/groovy

Direct execution

groovy -cp=com/ com/javagen/schema/dart/DartGenMain.groovy

21 Errors org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 34: unable to resolve class com.javagen.schema.model.MMethod.IncludeProperties @ line 34, column 1. import static com.javagen.schema.model.MMethod.IncludeProperties.allProperties ^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 35: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 35, column 1.
import static com.javagen.schema.model.MMethod.Stereotype.*
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 129: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 129, column 25.
XmlSchemaVisitor.super.preVisit(schema) //visit global elements, pre-create classes for type reference lookups
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 130: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 130, column 25.
XmlSchemaVisitor.super.visit(schema)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 298: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 298, column 25.
XmlSchemaVisitor.super.visit(complexType)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 365: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 365, column 25.
XmlSchemaVisitor.super.visit(all)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 430: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 430, column 33.
XmlSchemaVisitor.super.visit(choice)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 438: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 438, column 25.
XmlSchemaVisitor.super.visit(sequence)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 467: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 467, column 37.
XmlSchemaVisitor.super.visit(group)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 492: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 492, column 37.
XmlSchemaVisitor.super.visit(group)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/java/JavaGen.groovy: 517: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
@ line 517, column 25.
XmlSchemaVisitor.super.visit(simpleType)
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartToJsonCallback.groovy: 26: unable to resolve class com.javagen.schema.xml.node.Restriction.RType
@ line 26, column 1.
import static com.javagen.schema.xml.node.Restriction.RType.*
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartPreEmitter.groovy: 26: unable to resolve class com.javagen.schema.model.MMethod.IncludeProperties
@ line 26, column 1.
import static com.javagen.schema.model.MMethod.IncludeProperties.allProperties
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartPreEmitter.groovy: 27: unable to resolve class com.javagen.schema.model.MMethod.IncludeProperties
@ line 27, column 1.
import static com.javagen.schema.model.MMethod.IncludeProperties.finalProperties
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartPreEmitter.groovy: 28: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 28, column 1.
import static com.javagen.schema.model.MMethod.Stereotype.*
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartJsonEmitter.groovy: 23: unable to resolve class com.javagen.schema.model.MMethod.IncludeProperties
@ line 23, column 1.
import static com.javagen.schema.model.MMethod.IncludeProperties.allProperties
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartJsonEmitter.groovy: 24: unable to resolve class com.javagen.schema.model.MMethod.IncludeProperties
@ line 24, column 1.
import static com.javagen.schema.model.MMethod.IncludeProperties.finalProperties
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartJsonEmitter.groovy: 25: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 25, column 1.
import static com.javagen.schema.model.MMethod.Stereotype.*
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartSupportEmitter.groovy: 23: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 23, column 1.
import static com.javagen.schema.model.MMethod.Stereotype.fromJson
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartSupportEmitter.groovy: 24: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 24, column 1.
import static com.javagen.schema.model.MMethod.Stereotype.toJson
^

file:/workspaces/schema-gen/src/main/groovy/com/javagen/schema/dart/DartEmitter.groovy: 21: unable to resolve class com.javagen.schema.model.MMethod.Stereotype
@ line 21, column 1.
import com.javagen.schema.model.MMethod.Stereotype
^

21 errors

Compiled

I figured out (via googling) that to fix these errors I had to compile the classes 'bottom up' to a 'bin' folder which I then used as the classpath. This fixed the 'unable to resolve' and 'class.this' / 'class.super' errors.

groovyc -d=./bin com/javagen/schema/model/*
groovyc -d=./bin com/javagen/schema/common/*
groovyc -cp=./bin -d=./bin com/javagen/schema/xml/node/*
groovyc -cp=./bin -d=./bin com/javagen/schema/xml/*.groovy

All seems ok until I try to compile java

groovyc -cp=./bin -d=./bin com/javagen/schema/java/*.groovy
1 Error ``` org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Compilation incomplete: expected to find the class com.javagen.schema.xml.node.LIST in com/javagen/schema/java/Java14Emitter.groovy, but the file contains the classes: com.javagen.schema.java.Java14Emitter

1 error

</details>

Support for multiple xsd

The plugin support configuration of providing the single xsd file. Is there a way to provide a folder which has more than one xsds to be processed?

StackOverflowError (no error message): Don't re-load and parse a file previously loaded and parsed.

gradle gen
Parallel execution is an incubating feature.

> Task :gen FAILED
schemaGen.java.srcDir=/home/michael/git/WoS-Schema/src/main/java-gen, schemaURL=file:/home/michael/git/WoS-Schema/src/main/resources/com/clarivate/xsd/clarivate.com.schema.wok5.27.rawxml.xsd
<xs:schema targetNamespace='http://clarivate.com/schema/wok5.27/public/FullRecord'>
<xs:schema targetNamespace='http://clarivate.com/schema/wok5.27/public/FullRecord'>
 ... [bunches and bunches of times]
<xs:schema targetNamespace='http://clarivate.com/schema/wok5.27/public/FullRecord'>
<xs:schema targetNamespace='http://clarivate.com/schema/wok5.27/public/FullRecord'>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gen'.
> java.lang.StackOverflowError (no error message)

This is from trying to process "clarivate.com.schema.wok5.27.rawxml.xsd" and its children XSDs.

The output reads like the FullRecord xsd is trigguring something to pull itself in again as a new file for processing ... ad infitum till stack out of space.

The file only has an "include" for "common_types.rawxml.xsd" which includes "EWUID.rawxml.xsd" which back references "common_types.rawxml.xsd" as an include ...

<?xml version="1.0" encoding="UTF-8"?>
<!-- WoK 5.27 Raw Data Public schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
	<xs:include schemaLocation="common_types.rawxml.xsd"/>
	<xs:element name="fullrecord_metadata" type="fullrecord_metadata"/>
	<xs:complexType name="fullrecord_metadata">
 ...
<?xml version="1.0" encoding="UTF-8"?>
<!-- WoK 5.27 Raw Data Public schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
	<xs:include schemaLocation="EWUID.rawxml.xsd"/>
	<xs:element name="item" type="ItemType" abstract="false"/>
	<xs:element name="abstract" type="abstract">
 ...

So I set the gen source to "common_types ... xsd" and get the same error.

When i upgrade the gradle version to 6, below error is coming

When i upgrade the gradle version to 6, below error is coming. The samples in https://github.com/reaster/schema-gen-examples are also failing with the same error.

at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[hash, toString, equals, setter, getter, toStringBuilder, adder]' with class 'java.util.ImmutableCollections$SetN' to class 'java.util.EnumSet' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.EnumSet(com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype, com.javagen.schema.model.MMethod$Stereotype)
at com.javagen.schema.java.JavaPreEmitter.(JavaPreEmitter.groovy:54)

schemaGen {
java {
schemaURL = new URL('file:src/main/resources/atom.xsd')
packageName = 'com.sap.java'
addSuffixToEnumClass = null
anyPropertyName = 'text'
}
}

when i remove the above code, it works!!! But we need this configuration. Any help???

fractionDigits facet is not recognized

First of all, thanks for the great tool.

I have imported a rather large schema and I have encountered one issue:

The fractionDigits facet throws an exception.

XML Schema

<xsd:schema attributeFormDefault="unqualified"
            elementFormDefault="qualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="envelope">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="nest_volume" nillable="true">
                    <!-- [NV] Nest volume. The additional amount of volume for nested articles. -->
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:decimal">
                            <xsd:totalDigits value="16"/>
                            <xsd:fractionDigits value="6"/>
                            <xsd:minInclusive value="0"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Gradle output

15:22:39: Executing task 'gen'...


> Task :gen FAILED
schemaGen.kotlin.srcDir=/home/user/projects/project/src/main/kotlin-gen, schemaURL=file:/home/user/projects/project/src/main/resources/xmlschemas/test.xsd

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gen'.
> no namespace registered for prefix 'null' for name: envelope

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
1 actionable task: 1 executed
Cause: no namespace registered for prefix 'null' for name: envelope
15:22:40: Task execution finished 'gen'.

TODO -> IllegalStateException

I want to generate kotlin code from a xsd schema that is "well formed and valid". There is no registered namespace, so the XmlSlurper constructor is called with true, false. The error messages suggest that the code generation does not cover all use cases:

Warning: validation was turned on but an org.xml.sax.ErrorHandler was not
set, which is probably not what is desired. Parser will use a default
ErrorHandler to print the first 10 errors. Please call
the 'setErrorHandler' method to fix this.
Error: URI=null Line=2: Document root element "xs:schema", must match DOCTYPE root "null".
Error: URI=null Line=2: Document is invalid: no grammar found.
TODO add support to traverseElements() for node type: xs:element
Exception in thread "main" java.lang.IllegalStateException: TODO add support to gatherElements() for node type: xs:element
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:250)
at com.javagen.schema.xml.XmlSchemaNormalizer.traverseElements(XmlSchemaNormalizer.groovy:373)
at com.javagen.schema.xml.XmlSchemaNormalizer$traverseElements$2.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
at com.javagen.schema.xml.XmlSchemaNormalizer.buildSchema(XmlSchemaNormalizer.groovy:704)
at com.javagen.schema.xml.XmlSchemaNormalizer$buildSchema$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
at com.javagen.schema.xml.XmlSchemaNormalizer.buildSchema(XmlSchemaNormalizer.groovy:652)
at com.javagen.schema.xml.XmlSchemaNormalizer.buildSchema(XmlSchemaNormalizer.groovy)
at com.javagen.schema.xml.XmlSchemaNormalizer$buildSchema.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at com.javagen.schema.kotlin.KotlinGen.gen(KotlinGen.groovy:188)
at com.javagen.schema.kotlin.KotlinGen$gen.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.javagen.schema.kotlin.KotlinGenMain.main(KotlinGenMain.groovy:65)

No namespace registered for prefix

Hello,

I'm trying to use your work to generate Swift code from AIXM XSD (standard file format to define airspaces).

I'm facing the error no namespace registered for prefix 'null' for name: alpha for every single object definition in the published document.

Here is a sample part of the XSD that generate the error.

Am I doing something wrong? How should I solve this issue?

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<xsd:annotation>
		<xsd:documentation>Version: 4.5-r2</xsd:documentation>
	</xsd:annotation>
	<!-- AIXM predefined simple data types -->
	<xsd:simpleType name="alpha">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[A-Z]*"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="alphanumeric">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="([A-Z]|\d)*"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="character1">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="([A-Z]|[0-9])+([ \+\-/]*([A-Z]|[0-9])+)*"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="character2">
		<xsd:restriction base="xsd:string"/>
	</xsd:simpleType>
	<xsd:simpleType name="character3">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="([A-Z]|[0-9]|[, !&quot;&amp;#$%&apos;\(\)\*\+\-\./:;&lt;=&gt;\?@\[\\\]\^_\|\{\}])*"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:simpleType name="codeAcftEngineNoBase">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="1"/>
			<xsd:enumeration value="2"/>
			<xsd:enumeration value="3"/>
			<xsd:enumeration value="4"/>
			<xsd:enumeration value="6"/>
			<xsd:enumeration value="8"/>
			<xsd:enumeration value="C"/>
			<xsd:enumeration value="OTHER"/>
		</xsd:restriction>
	</xsd:simpleType>
	<xsd:complexType name="codeAcftEngineNo">
		<xsd:annotation>
			<xsd:documentation>A coded indication for the number of engines of an aircraft.</xsd:documentation>
		</xsd:annotation>
		<xsd:simpleContent>
			<xsd:extension base="codeAcftEngineNoBase">
				<xsd:attributeGroup ref="Changes"/>
			</xsd:extension>
		</xsd:simpleContent>
	</xsd:complexType>
	<xsd:simpleType name="codeActivityBase">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="TFC-AD"/>
			<xsd:enumeration value="TFC-HELI"/>
			<xsd:enumeration value="TRG"/>
			<xsd:enumeration value="ACROBAT"/>
			<xsd:enumeration value="AIRSHOW"/>
			<xsd:enumeration value="SPORT"/>
			<xsd:enumeration value="ULM"/>
			<xsd:enumeration value="GLIDER"/>
			<xsd:enumeration value="PARAGLIDER"/>
			<xsd:enumeration value="HANGGLIDER"/>
			<xsd:enumeration value="PARACHUTE"/>
			<xsd:enumeration value="DROP"/>
			<xsd:enumeration value="BALLOON"/>
			<xsd:enumeration value="ASCENT"/>
			<xsd:enumeration value="SPACEFLT"/>
			<xsd:enumeration value="UAV"/>
			<xsd:enumeration value="WORK"/>
			<xsd:enumeration value="DUSTING"/>
			<xsd:enumeration value="FIRE"/>
			<xsd:enumeration value="MILOPS"/>
			<xsd:enumeration value="REFUEL"/>
			<xsd:enumeration value="JETCLIMB"/>
			<xsd:enumeration value="EXERCISE"/>
			<xsd:enumeration value="TOWING"/>
			<xsd:enumeration value="NAVAL"/>
			<xsd:enumeration value="MISSILES"/>
			<xsd:enumeration value="AIRGUN"/>
			<xsd:enumeration value="ARTILERY"/>
			<xsd:enumeration value="SHOOT"/>
			<xsd:enumeration value="BLAST"/>
			<xsd:enumeration value="WATERBLAST"/>
			<xsd:enumeration value="ANTIHAIL"/>
			<xsd:enumeration value="BIRD"/>
			<xsd:enumeration value="BIRD-MGR"/>
			<xsd:enumeration value="FIREWORK"/>
			<xsd:enumeration value="HI-RADIO"/>
			<xsd:enumeration value="HI-LIGHT"/>
			<xsd:enumeration value="LASER"/>
			<xsd:enumeration value="NATURE"/>
			<xsd:enumeration value="FAUNA"/>
			<xsd:enumeration value="NO-NOISE"/>
			<xsd:enumeration value="ACCIDENT"/>
			<xsd:enumeration value="POPULATION"/>
			<xsd:enumeration value="VIP"/>
			<xsd:enumeration value="VIP-PRES"/>
			<xsd:enumeration value="VIP-VICE"/>
			<xsd:enumeration value="OIL"/>
			<xsd:enumeration value="GAZ"/>
			<xsd:enumeration value="IND-OIL"/>
			<xsd:enumeration value="IND-CHEM"/>
			<xsd:enumeration value="IND-NUCLEAR"/>
			<xsd:enumeration value="TECHNICAL"/>
			<xsd:enumeration value="ATS"/>
			<xsd:enumeration value="EQUIPMENT"/>
			<xsd:enumeration value="EQUIPMENT-RVSM"/>
			<xsd:enumeration value="EQUIPMENT-RNAV"/>
			<xsd:enumeration value="EQUIPMENT-833"/>
			<xsd:enumeration value="PROCEDURE"/>
			<xsd:enumeration value="OTHER"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>

still usable?

Hi,

I am trying to use this service, but I cannot find a working example.

When I try to use the dependency in gradle, I always get

Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/javagen/schema-gen/0.9.1/schema-gen-0.9.1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.

I cannot see anything pointing to a dependency in this repository and the gradle plugin seems not supported.
So is this still being used?

Cannot get property 'imports' on null object

I'm trying to generate Kotlin classes for my XSDs. This is the calling code:

class CodeGen extends KotlinGen {
    CodeGen(File schemaFile, File targetDir, String targetPackage) {
        super()
        schemaURL = schemaFile.toURI().toURL()
        srcDir = targetDir
        packageName = targetPackage
        addSuffixToEnumClass = null
        anyPropertyName = 'text'
    }
}

The XSD file is valid (and was used to create Java Beans via xjc before), the targetDir is valid as well and exists, the package name is non-empty. When I execute this code in my custom task, I receive the following crash:

java.lang.NullPointerException: Cannot get property 'imports' on null object
        at com.javagen.schema.model.MSource$Imports.leftShift(MSource.groovy:83)
        at com.javagen.schema.model.MSource$Imports$leftShift.call(Unknown Source)
        at com.javagen.schema.kotlin.KotlinJacksonCallback$_gen_closure1.doCall(KotlinJacksonCallback.groovy:116)              at com.javagen.schema.kotlin.KotlinJacksonCallback.gen(KotlinJacksonCallback.groovy:113)
        at com.javagen.schema.kotlin.KotlinJacksonCallback$gen.call(Unknown Source)
        at com.javagen.schema.java.JavaGen.visit(JavaGen.groovy:357)
        at com.javagen.schema.xml.XmlSchemaVisitor$visit$2.call(Unknown Source)
        at com.javagen.schema.xml.XmlSchemaVisitor$Trait$Helper.visit(XmlSchemaVisitor.groovy:37)
        at com.javagen.schema.xml.XmlSchemaVisitor$Trait$Helper$visit$1.call(Unknown Source)
        at com.javagen.schema.java.JavaGen.visit(JavaGen.groovy:143)
        at com.javagen.schema.java.JavaGen$visit.callCurrent(Unknown Source)
        at com.javagen.schema.kotlin.KotlinGen.gen(KotlinGen.groovy:186)
        at com.javagen.schema.kotlin.KotlinGen$gen.call(Unknown Source)

My Groovy-foo is not good enough to figure out whats going on here, so maybe you have an idea?

[Question]: Run without plugin

Hello!

I've encountered issue described here #10 but with different scheme. I ran schema-gen with gradle plugin. As far as I understand the problem has been fixed but I need to run schema-gen "directly" (since plugin is not supported any more).

I'm not familiar with groovy, gradle etc. Could you please elaborate what does it mean "The main entry point is com.javagen.schema.swift.SwiftGen which can be invoked directly"?

What tools I need to install?
How to build schema-gen itself?
How run schema-gen without gradle plugin?

Sample for Kotlin/JS?

Hi Richard,
I would like to use schema-gen for a Kotlin/JS project.
Do you know of any projects/samples?

Thanks in advance
-j

Complex element with choice is not generated correct anymore

This worked in V 0.9.1.

Xsd-snippet:

<xsd:complexType name="KontoForTilbakebetaling">
	<xsd:sequence>
		<xsd:choice>
			<xsd:sequence>
				<xsd:element name="norskKontonummer" type="Kontonummer"/>
			</xsd:sequence>
			<xsd:sequence>
				<xsd:element name="swiftBIC" type="Tekst"/>
				<xsd:element name="valuta" type="Valutakode"/>
				<xsd:element name="IBAN" type="Tekst"/>
			</xsd:sequence>
		</xsd:choice>
	</xsd:sequence>

used to generate (Kotlin):

  data class KontoForTilbakebetaling(
      val norskKontonummer:String? = null, 
      val swiftBIC:String? = null, 
      val valuta:String? = null, 
      val IBAN:String? = null
  )
  {
  }

And the latest code generates:

  data class KontoForTilbakebetaling(
  val norskKontonummer:String? = null, 
  )	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.