Giter Site home page Giter Site logo

scalaxb's Introduction

scalaxb

Maven Central

scalaxb is an XML data-binding tool for Scala that supports W3C XML Schema (xsd) and Web Services Description Language (wsdl) as the input file.

From schema documents scalaxb will generate Scala source files containing case classes to represent the data and typeclass instances to turn XML documents into an object, and the object back to XML.

Modules

There are currently four ways of running scalaxb:

  • command line app scalaxb
  • sbt plugin sbt-scalaxb
  • maven plugin mvn-scalaxb
  • web API scalaxb-heroku hosted on heroku

sbt-scalaxb

To call scalaxb from sbt 1.x and sbt 0.13.x, put this in your project/scalaxb.sbt:

resolvers += Resolver.sonatypeRepo("public")
addSbtPlugin("org.scalaxb" % "sbt-scalaxb" % "X.X.X")

and this in build.sbt:

lazy val dispatchVersion = "1.1.3"
lazy val dispatch = "org.dispatchhttp" %% "dispatch-core" % dispatchVersion
lazy val jaxbApi = "javax.xml.bind" % "jaxb-api" % "2.3.0"
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0"
lazy val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"

lazy val root = (project in file(".")).
  enablePlugins(ScalaxbPlugin).
  settings(
    name := "foo-project",
    Compile / scalaxb / scalaxbPackageName := "generated",
    // Compile / scalaxb / scalaxbAutoPackages := true,
    Compile / scalaxb / scalaxbDispatchVersion := dispatchVersion,
    libraryDependencies ++= Seq(dispatch, jaxbApi, scalaParser, scalaXml)
  )

command line app scalaxb

See INSTALL.md.

mvn-scalaxb

See mvn-scalaxb.

Documents

Further info is available at scalaxb.org.

Bug Reporting

If you're having problem with scalaxb, please take a moment and read issue reporting guideline.

Licensing

It's the MIT License. See the file called LICENSE.

Contacts

scalaxb's People

Contributors

alexdupre avatar anatoliykmetyuk avatar andrevandelft avatar arkadius avatar bbarker avatar carl297r avatar coutopl avatar danslapman avatar dependabot[bot] avatar dustinchaloupka avatar eed3si9n avatar etitov avatar fltt avatar fthomas avatar hosamaly avatar jtjeferreira avatar justjoheinz avatar lamdor avatar lbruand avatar margussipria avatar martiell avatar maxaf avatar mdedetrich avatar mprihoda avatar mrdziuban avatar romainreuillon avatar sullis avatar toverney avatar xuwei-k avatar zarthross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scalaxb's Issues

doesn't support xs:anySimpleType

I'm attempting to compile the vCloud API XSD(s) found at http://communities.vmware.com/docs/DOC-13564. This is a fairly large, complex collection of XSDs and might make a good testbed. :-)

After downloading a few imported XSDs that are referred to, a

scalaxb `find . -name '*.xsd'`

fails with:

java.lang.RuntimeException: Args: Unsupported type XsAnySimpleType
at scala.Predef$.error(Predef.scala:58)
at scalaxb.compiler.xsd.Args$class.buildArg(Args.scala:178)
at scalaxb.compiler.xsd.GenSource.buildArg(GenSource.scala:30)
at scalaxb.compiler.xsd.Args$class.buildArg(Args.scala:165)
at scalaxb.compiler.xsd.GenSource.buildArg(GenSource.scala:30)
at scalaxb.compiler.xsd.GenSource.argsString$1(GenSource.scala:269)
at scalaxb.compiler.xsd.GenSource.companionCode$1(GenSource.scala:338)
at scalaxb.compiler.xsd.GenSource.makeCaseClassWithType(GenSource.scala:384)
at scalaxb.compiler.xsd.GenSource.makeType(GenSource.scala:80)
at scalaxb.compiler.xsd.GenSource$$anonfun$run$1.apply(GenSource.scala:59)
at scalaxb.compiler.xsd.GenSource$$anonfun$run$1.apply(GenSource.scala:53)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
at scala.collection.immutable.List.map(List.scala:45)
at scalaxb.compiler.xsd.GenSource.run(GenSource.scala:53)
at scalaxb.compiler.xsd.Driver.generate(Driver.scala:51)
at scalaxb.compiler.xsd.Driver.generate(Driver.scala:31)
at scalaxb.compiler.Module$$anonfun$processImportables$1$1.apply(Module.scala:228)
at scalaxb.compiler.Module$$anonfun$processImportables$1$1.apply(Module.scala:222)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
at scala.collection.immutable.List.map(List.scala:45)
at scalaxb.compiler.Module$class.processImportables$1(Module.scala:222)
at scalaxb.compiler.Module$class.processReaders(Module.scala:263)
at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:31)
at scalaxb.compiler.Module$class.processFiles(Module.scala:122)
at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:31)
at scalaxb.compiler.Main$.start(Main.scala:81)
at scalaxb.compiler.Main$.main(Main.scala:33)
at scalaxb.compiler.Main.main(Main.scala)

A look at Args.scala line 178 reveals that the exception is honestly arrived at :-) but I don't know yet what to suggest by way of changes to support xs:anySimpleType. Hopefully the issue is at least easy enough to reproduce to be helpful to you.

Example in user documentation does not work

martin@MacBook:/tmp$ cat > usaddress.xsd <<EOF
<xs:schema targetNamespace="http://www.example.com/IPO"
        xmlns="http://www.example.com/IPO"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:ipo="http://www.example.com/IPO">
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="name"   type="xs:string"/>
      <xs:element name="street" type="xs:string"/>
      <xs:element name="city"   type="xs:string"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="USAddress">
    <xs:complexContent>
      <xs:extension base="ipo:Address">
        <xs:sequence>
          <xs:element name="state" type="xs:string"/>
          <xs:element name="zip"   type="xs:positiveInteger"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
EOF
martin@MacBook:/tmp$ /opt/scala/current/bin/scalaxb 
Error: missing arguments: <schema_file>...

scalaxb 0.6.0
Usage: scalaxb [options] <schema_file>...

  -d <directory> | --outdir <directory>
        generated files will go into <directory>
  -p <package> | --package <package>
        specifies the target package
  -p:<namespaceURI>=<package> | --package:<namespaceURI>=<package>
        specifies the target package for <namespaceURI>
  --class-prefix <prefix>
        prefixes generated class names
  --param-prefix <prefix>
        prefixes generated parameter names
  --wrap-contents <complexType>
        wraps inner contents into a seperate case class
  --package-dir
        generate package directories
  -v | --verbose
        be extra verbose
  <schema_file>...
        input schema to be converted

martin@MacBook:/tmp$ /opt/scala/current/bin/scalaxb usaddress.xsd -p ipo
generated ./usaddress.scala.
generated ./usaddress_xmlprotocol.scala.
generated ./scalaxb.scala.

martin@MacBook:/tmp$ /opt/scala/current/bin/scalac *.scala
warning: there were 3 deprecation warnings; re-run with -deprecation for details
one warning found

martin@MacBook:/tmp$ /opt/scala/current/bin/scala -cp .
Welcome to Scala version 2.9.0.1 (OpenJDK 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scalaxb._
import scalaxb._

scala> import ipo._
import ipo._

scala> val subject = <shipTo xmlns="http://www.example.com/IPO">
     |   <name>Foo</name>
     |   <street>1537 Paper Street</street>
     |   <city>Wilmington</city>
     | </shipTo>
subject: scala.xml.Elem = 
<shipTo xmlns="http://www.example.com/IPO">
  <name>Foo</name>
  <street>1537 Paper Street</street>
  <city>Wilmington</city>
</shipTo>

scala>  

scala> val shipTo = scalaxb.fromXML[ipo.Address](subject)
scalaxb.ParserFailure: parser error "`scalaxb.ElemName@50e8709d' expected but scalaxb.ElemName@4c397cea found" while parsing /scalaxb.ElemName@5e0e5f1d/[email protected]@1775831escalaxb.ElemName@23f3329a
^
        at scalaxb.package$.fromXML(scalaxb.scala:10)
        at .<init>(<console>:14)
        at .<clinit>(<console>)
        at .<init>(<console>:11)
        at .<clinit>(<console>)
        at $export(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:592)
        at scala.tools.nsc.interpreter.IMain$Request$$anonfun$10.apply(IMain.scala:828)
        at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
        at scala.tools.nsc.io.package$$anon$2.run(package.scala:31)
        at java.lang.Thread.run(Thread.java:679)

value any2 is not a member

steps

$ mkdir dmtf
$ cd dmtf
$ wget http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://schemas.dmtf.org/wbem/wscim/1/common.xsd

problem

$ scalac *.scala
CIM_ResourceAllocationSettingData.scala:47: error: value any2 is not a member of dmtf.CIM_ResourceAllocationSettingData_TypeSequence3
  lazy val any2 = cim_resourceallocationsettingdata_typesequence3.any2

expectation

scalaxb produces correct code.

attributeGroup name conflict

steps

  1. compile a schema that includes an attributeGroup and a complex element that are named the same.

    <element name="gh9">
      <complexType>
        <sequence>
          <element name="name"   type="string"/>
        </sequence>
      </complexType>
    </element>
    
    <attributeGroup name="gh9">
      <annotation>
        <documentation>
        the same name as the above element.
        </documentation>
      </annotation>
      <attribute name="id" type="ID"/>
    </attributeGroup>
    

problem

generates scala code, but it does not compile because it includes case classes with the same name.

expectation

somehow handle it.

sbaz install fails

Hi,

I've just tried installing and running scalaxb for the first time but I get the error :

Exception in thread "main" java.lang.NoSuchMethodError: scala.collection.generic.Growable.$plus$plus$eq(Lscala/collection/Traversable;)Lscala/collection/generic/Growable;
at org.scalaxb.compiler.xsd.Driver$.sortByDependency(Driver.scala:86)
at org.scalaxb.compiler.Module$class.processFiles(Module.scala:81)
at org.scalaxb.compiler.xsd.Driver$.processFiles(Driver.scala:29)
at org.scalaxb.compiler.Module$class.start(Module.scala:68)
at org.scalaxb.compiler.xsd.Driver$.start(Driver.scala:29)
at org.scalaxb.compiler.Main$.main(Main.scala:30)
at org.scalaxb.compiler.Main.main(Main.scala)

I'm using the example address.xsd as described on http://scalaxb.org/intro and running with 'scalaxb address.xsd'

Even running just 'scalaxb' without any arguments gives the same error.

I'm running scala version 2.8.0.final

Any thoughts where I might have gone wrong?

Thanks

Damian.

update:

Note that the error desribed above was on the version I got from using sbaz to install. I since downloaded the source and compiled it myself and it works fine now (need to change scala-version from 2.8.0.Beta1 to 2.8.0 in the POM to get it to compile).

Seems to be working well. Thanks - really appreciate you putting this tool out into the community.

Damian.

Further Update

I noticed that the version that sbaz grabbed earlier today was 0.3.0, rather than 0.4.0. I just tried to do a sbaz upgrade now, but the scalaxb.-0.4.0.zip file it downloaded seems to be corrupt. When I try to open the zip file manually I get a 'The compressed folders ... is invalid' error.

cross-namespace choice

steps

  1. compile the following with ipo.xsd:

    <xs:schema targetNamespace="http://www.example.com/xn"
            xmlns="http://www.example.com/xn"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xn="http://www.example.com/xn"
            xmlns:xipo="http://www.example.com/IPO"
            elementFormDefault="qualified">
    
        <complexType name="Human">
            <sequence>
              <element name="name"   type="xs:string"/>
            </sequence>
        </complexType>
    
        <xs:complexType name="CrossNamespaceChoice">
            <xs:choice>
                <xs:element name="address" type="xipo:USAddress"/>
                <xs:element name="human" type="xn:Human" />
            </xs:choice>
        </xs:complexType>
    </xs:schema>
    

problem

It generates uncompilable code.

  case class CrossNamespaceChoice(crossnamespacechoiceoption: scalaxb.DataRecord[ipo.CrossNamespaceChoiceOption])

expectation

Choices across multiple namespaces generates scalaxb.DataRecord[Any].

choice should support self-named elements

Example schema:

<xs:complexType name="ProtocolType">
  <xs:choice minOccurs="1" maxOccurs="1">
    <xs:element name="HTTP"/>
    <xs:element name="TCP"/>
    <xs:element name="UDP"/>
  </xs:choice>
</xs:complexType>

should result in HTTP, TCP, and UDP case classes that can be used for any element or attribute of type "ProtocolType."

default arg for attributes

steps

  1. <xs:anyAttribute namespace="##any" processContents="lax"/> currently generates val attributes: Map[String, scalaxb.DataRecord[Any]].

expectations

it should have default arg Map().

DataRecord round trips with default namespace

steps

  1. compile a schema with single xs:any.
  2. parse an element from non-default namespace, and round trip back to xml.

problem

the element is generated with the default namespace.

expectation

the original namespace is preserved.

improve type of sequence-based NamedGroup

steps

  1. compile XMLSchema.xsd.

problem

def parseXSimpleRestrictionModelGroup(wrap: Boolean): Parser[scalaxb.DataRecord[Any]] =
  ((opt(scalaxb.ElemName(targetNamespace, "simpleType")) ~ 
  rep(parseXFacetsGroup)) ^^ 
    { case p1 ~ p2 => scalaxb.DataRecord(xmlschema.XSimpleRestrictionModelSequence(p1.headOption map { fromXML[xmlschema.XLocalSimpleType](_) },
    p2.toSeq)) })

expectations

scalaxb.DataRecord[xmlschema.XSimpleRestrictionModelSequence]?

derivation of a list

steps

  1. a schema with a derived type off of a list.

    <xs:simpleType name="ListOfBuiltInType">
      <xs:list itemType="xs:unsignedInt"/>
    </xs:simpleType>
    
    <xs:simpleType name="ListOfBuildIntTypeDerived">
      <xs:restriction base="gen:ListOfBuiltInType">
        <xs:minLength value="0"/>
        <xs:maxLength value="1"/>
      </xs:restriction>
    </xs:simpleType>
    
  2. derive it again with a complex type.

    <xs:complexType name="ComplexListOfBuiltInType">
      <xs:simpleContent>
        <xs:extension base="gen:ListOfBuildIntTypeDerived">
          <xs:attributeGroup ref="gen:coreattrs"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
    

problem

  1. reference to ListOfBuildIntTypeDerived maps to numbers7: Long.
  2. GenSource: unsupported type: ListOfBuiltInType(SimpTypListDecl(Long)

expectation

  1. numbers7: Seq[Long]
  2. compiles.

"value Tuple23 is not a member of package scala"

Steps:

  1. Prepare a schema with a complex type that has 23 child elements.
  2. Generate code.
  3. Try using the code.

Problem:

[scalac] tests/tmp/footprint.scala:255: error: value Tuple23 is not a member of package scala 
[scalac] case class VolunteerOpportunity(volunteerOpportunityID: Option[String],
[scalac]            ^
[scalac] one error found

Expectation:

  1. scalaxb generates usable code.

support MIME declaration

originally reported by @psnively.

steps

  1. compile schema with MIME declaration:

    <?xml version="1.0" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/know-type"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/know-type">
    
        <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
            schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
    
        <xs:simpleType name="JPEGPictureType" 
            xmime:expectedContentTypes="image/jpeg"> 
        <xs:restriction base="xs:base64Binary"/>
        </xs:simpleType>
    
        <xs:element name="JPEGPicture" type="tns:JPEGPictureType"/>
    </xs:schema>
    

expectation

support it

DataRecord instantiation

given:
case class EventListType(eventlisttypeoption: scalaxb.DataRecord[Any]*)

I can

for(e <- eventDoc.EPCISBody.EventList.get.eventlisttypeoption) {
  e.value match {
    case e: ObjectEventType =>
      EventDebugServices.displayObjectEvent(e)
    case e: AggregationEventType =>
      EventDebugServices.displayAggregationEvent(e)
    case e: QuantityEventType =>
      EventDebugServices.displayQuantityEvent(e)
    case e: TransactionEventType =>
      EventDebugServices.displayTransactionEvent(e)
    case u =>
      System.out.println("Unknown Event: " + u)
  }
}

Each e is of course a DataRecord.

How do I instantiate DataRecords to build back up the object graph from scratch?

If I say "DataRecord(event)" where event is say... a ObjectEventType the compiler complains with "could not find implicit value for evidence parameter of type scalaxb.CanWriteXML[com.ghx.tnt.core.event.ObjectEventType]"

thanks,

david...

xs:include crashes scalaxb

reported by Andreas Sewe.

steps

  1. compiling mathml3.xsd produces practically empty file.
  2. $ scalaxb -p mathml mathml3-common.xsd mathml3-content.xsd mathml3-strict-content.xsd mathml3-presentation.xsd

problems

$ scalaxb -p mathml mathml3-common.xsd mathml3-content.xsd mathml3-strict-content.xsd  mathml3-presentation.xsd
java.lang.RuntimeException: SchemaDecl#resolveType type not found: m:cn.content ReferenceTypeSymbol(m:cn.content,null)
    at scala.Predef$.error(Predef.scala:58)
    at scalaxb.compiler.xsd.SchemaDecl$.resolveType(Decl.scala:303)
    at scalaxb.compiler.xsd.SchemaDecl$$anonfun$resolveType$3.apply(Decl.scala:293)
    at scalaxb.compiler.xsd.SchemaDecl$$anonfun$resolveType$3.apply(Decl.scala:281)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:44)
    at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
    at scalaxb.compiler.xsd.SchemaDecl$.resolveType(Decl.scala:281)
    at scalaxb.compiler.xsd.SchemaDecl$.fromXML(Decl.scala:226)
    at scalaxb.compiler.xsd.Driver$$anon$3.toSchema(Driver.scala:61)
    at scalaxb.compiler.xsd.Driver$$anon$3.toSchema(Driver.scala:51)
    at scalaxb.compiler.Module$class.parse(Module.scala:144)
    at scalaxb.compiler.xsd.Driver.parse(Driver.scala:32)
    at scalaxb.compiler.Module$$anonfun$4.apply(Module.scala:89)
    at scalaxb.compiler.Module$$anonfun$4.apply(Module.scala:88)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:44)
    at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
    at scala.collection.mutable.ListBuffer.map(ListBuffer.scala:42)
    at scalaxb.compiler.Module$class.processReaders(Module.scala:88)
    at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:32)
    at scalaxb.compiler.Module$class.processFiles(Module.scala:63)
    at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:32)
    at scalaxb.compiler.Main$.start(Main.scala:84)
    at scalaxb.compiler.Main$.main(Main.scala:32)
    at scalaxb.compiler.Main.main(Main.scala)

expectation

handle it

attribute group ref is missing from the list of attributes

steps

  1. compile XMLSchema.xsd.

problems

it's missing stuff from <xs:attributeGroup ref="xs:defRef"/>.

trait XAttributable extends XAnnotatedable with XAttrDeclsOption1 {
  val mAnnotation: Option[org.w3.xmlschema.XAnnotation]
  val mSimpleType: Option[org.w3.xmlschema.XLocalSimpleType]
  val mId: Option[String]
  val mType: Option[javax.xml.namespace.QName]
  val mUse: org.w3.xmlschema.XUse
  val mDefault: Option[String]
  val mFixed: Option[String]
  val mForm: Option[org.w3.xmlschema.XFormChoice]
}

expectations

include them in there.

ElemName should override toString()

ElemName should have a toString() method to avoid error messages like this one from issue #46:

scalaxb.ParserFailure: parser error "`scalaxb.ElemName@50e8709d' expected but
scalaxb.ElemName@4c397cea found" while parsing
/scalaxb.ElemName@5e0e5f1d/[email protected]@1775831escalaxb.ElemName@23f3329a

xs:any should respect `namespace="##other"`

steps

  1. compile a schema with xs:any with namespace="##other" appearing in the middle of a type.

problem

it's not checking the namespace, so it keeps parsing.

expectation

namespace="##other" grabs only elements from other namespaces.

Output is not stable for a given input

reported by Andreas Sewe.

steps

  1. Compile xhtml1-strict.xs several times.

  2. Take diff:

    < acceptcharset: Option[String]) extends Formcontentable with FieldsetOption with ObjectTypeOption with MapTypeOption2 with BlockableOption with FlowableOption

    > acceptcharset: Option[String]) extends Formcontentable with FieldsetOption with MapTypeOption2 with ObjectTypeOption with BlockableOption with FlowableOption

problem

The output is not stable.

expectation

Same input. Same output.

UTF-8 BOM results in crash

originally reported by @fredferrao.

steps

  1. compile a schema that has UTF-8 BOM.

problem

$ scalaxb -p foo consReciNFe_v2.00.xsd 
org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    at scala.xml.factory.XMLLoader$class.loadXML(XMLLoader.scala:40)
    at scalaxb.compiler.CustomXML$.loadXML(Module.scala:330)
    at scala.xml.factory.XMLLoader$class.load(XMLLoader.scala:53)
    at scalaxb.compiler.CustomXML$.load(Module.scala:330)
    at scalaxb.compiler.xsd.Driver.readerToRawSchema(Driver.scala:79)
    at scalaxb.compiler.xsd.Driver.readerToRawSchema(Driver.scala:31)
    at scalaxb.compiler.Module$$anon$1.toRawSchema(Module.scala:77)
    at scalaxb.compiler.Module$$anon$1.toRawSchema(Module.scala:76)
    at scalaxb.compiler.Module$$anonfun$processReaders$1.apply(Module.scala:159)
    at scalaxb.compiler.Module$$anonfun$processReaders$1.apply(Module.scala:156)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
    at scala.collection.immutable.List.map(List.scala:45)
    at scalaxb.compiler.Module$class.processReaders(Module.scala:156)
    at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:31)
    at scalaxb.compiler.Module$class.processFiles(Module.scala:98)
    at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:31)
    at scalaxb.compiler.Main$.start(Main.scala:78)
    at scalaxb.compiler.Main$.main(Main.scala:33)
    at scalaxb.compiler.Main.main(Main.scala)

expectations

it works.

--version

command lin option to see what version of scalaxb is installed/running

scalaxb generates code that uses the _match_ keyword as variable name.

<schema targetNamespace="http://www.example.com/IPO"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:ipo="http://www.example.com/IPO">
  <complexType name="Address">
    <sequence>
  <element name="name"   type="string"/>
  <element name="street" type="string"/>
  <element name="city"   type="string"/>
  <element name="match"   type="string"/>
    </sequence>
  </complexType>
</schema>

produces:

case class Address(name: String,
  street: String,
  city: String,
 match: String)

Same issue for implicit keyword. Nice overview of keywords is here: http://programming-scala.labs.oreilly.com/ch02.html#reserved-words-table

java.lang.RuntimeException: 'ElemName(null, bar)' expected but ElemName(null, bar) found.

Using the following simple schema I'm getting a parser error with scalaxb:

xs:complexType xs:sequence /xs:sequence /xs:complexType /xs:element /xs:schema

In the console:

scala> val tst = ab
scala> Foo.fromXML(tst)
java.lang.RuntimeException: fromXML failed: `ElemName(null,bar)' expected but ElemName(null,bar) found
at scala.Predef$.error(Predef.scala:59)
at org.scalaxb.rt.ElemNameParser$class.fromXML(Helper.scala:42)
at qmed.xml.test2.Foo$.fromXML(test2.scala:19)

>22 parameters as a result of extension

steps:

  1. compile a schema that includes complex types with extension, which accumulates >22 parameters.

problem:
does not compile.

expectation:
somehow handle it.

WSDL support

steps

  1. compile wsdl file.

expectations

scalaxb generates service wrapper trait.

substitution group

steps:

  1. compile schema with substitution group.

problem:
sub groups are not implemented correctly as choices.

expectation:
sub groups are implemented similar to choices.

Validation of Case Class instances consistent with xsd

Ok. This is probably over the top :-) but it would be great if when i instantiation a case class object graph I could 'validate' it to see if it is consistent with the schema(s) rather than just finding out it doesn't when i try to render it to xml. Or, alternatively, the constructor would fail for a given case class if it didn't pass xsd(s).

david...

parser for element with substitution group is ()

  1. running
scalaxb BusinessScope.xsd -p com.company
  1. causes
> compile
[info] 
[info] == compile ==
[info]   Source analysis: 3 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[error] /Users/me/Documents/sandboxes/testy/test/src/main/scala/com/company/xmlprotocol.scala:72: not enough arguments for method rep: (p: => DefaultCompanyScopeFormat.this.Parser[T])DefaultCompanyScopeFormat.this.Parser[List[T]].
[error] Unspecified value parameter p.
[error]       rep() ^^
[error]          ^
[error] one error found
[info] == compile ==
[error] Error running compile: Compilation failed
  1. BusinessScope.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" targetNamespace="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="BusinessScope">
        <xs:sequence>
            <xs:element name="Scope" type="Scope" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Scope">
        <xs:sequence>
            <xs:group ref="ScopeAttributes"/>
            <xs:element ref="ScopeInformation" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:group name="ScopeAttributes">
        <xs:sequence>
            <xs:element name="Type" type="xs:string"/>
            <xs:element name="InstanceIdentifier" type="xs:string"/>
            <xs:element name="Identifier" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:group>
    <xs:element name="ScopeInformation" type="xs:anyType" abstract="true"/>
    <xs:element name="CorrelationInformation" type="CorrelationInformation" substitutionGroup="ScopeInformation"/>
    <xs:complexType name="CorrelationInformation">
        <xs:sequence>
            <xs:element name="RequestingDocumentCreationDateTime" type="xs:dateTime" minOccurs="0"/>
            <xs:element name="RequestingDocumentInstanceIdentifier" type="xs:string" minOccurs="0"/>
            <xs:element name="ExpectedResponseDateTime" type="xs:dateTime" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="BusinessService" type="BusinessService" substitutionGroup="ScopeInformation"/>
    <xs:complexType name="BusinessService">
        <xs:sequence>
            <xs:element name="BusinessServiceName" type="xs:string" minOccurs="0"/>
            <xs:element name="ServiceTransaction" type="ServiceTransaction" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
<xs:complexType name="ServiceTransaction">
        <xs:attribute name="TypeOfServiceTransaction" type="TypeOfServiceTransaction" use="optional"/>
        <xs:attribute name="IsNonRepudiationRequired" type="xs:string"/>
        <xs:attribute name="IsAuthenticationRequired" type="xs:string"/>
        <xs:attribute name="IsNonRepudiationOfReceiptRequired" type="xs:string"/>
        <xs:attribute name="IsIntegrityCheckRequired" type="xs:string"/>
        <xs:attribute name="IsApplicationErrorResponseRequested" type="xs:string"/>
        <xs:attribute name="TimeToAcknowledgeReceipt" type="xs:string"/>
        <xs:attribute name="TimeToAcknowledgeAcceptance" type="xs:string"/>
        <xs:attribute name="TimeToPerform" type="xs:string"/>
        <xs:attribute name="Recurrence" type="xs:string"/>
    </xs:complexType>
    <xs:simpleType name="TypeOfServiceTransaction">
        <xs:restriction base="xs:string">
            <xs:enumeration value="RequestingServiceTransaction"/>
            <xs:enumeration value="RespondingServiceTransaction"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

-- end --

thanks! david...

"found Seq[Long], required Option[Long]" compiling bindings generated from <xs:all <xs:element minOccurs="0" maxOccurs="1")

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           targetNamespace="urn:test"
           xmlns="urn:test">

    <xs:element name="foo" type="Foo"/>

    <xs:complexType name="Foo">
        <xs:all>
            <xs:element name="bar" minOccurs="0" maxOccurs="1" type="xs:unsignedInt"/>
        </xs:all>
    </xs:complexType>
</xs:schema>
// Generated by scalaxb.
package com.example.bindxb
import org.scalaxb.rt

case class Foo(bar: Option[Long])

object Foo extends rt.ImplicitXMLWriter[Foo] {
  def fromXML(seq: scala.xml.NodeSeq): Foo = seq match {
    case node: scala.xml.Node => Foo((node \ "bar") map { x => x.text.toLong })
    case _ => error("fromXML failed: seq must be scala.xml.Node")
  }
  
  def toXML(__obj: Foo, __namespace: String, __elementLabel: String): scala.xml.NodeSeq = {
    var __scope: scala.xml.NamespaceBinding = scala.xml.TopScope
    __scope = scala.xml.NamespaceBinding("xsi", "http://www.w3.org/2001/XMLSchema-instance", __scope)
    __scope = scala.xml.NamespaceBinding("xs", "http://www.w3.org/2001/XMLSchema", __scope)
    __scope = scala.xml.NamespaceBinding(null, "urn:test", __scope)
    val node = toXML(__obj, __namespace, __elementLabel, __scope)
    node match {
      case elem: scala.xml.Elem =>
        elem % new scala.xml.PrefixedAttribute(__scope.getPrefix(rt.Helper.XSI_URL),
          "type",
          "Foo", elem.attributes)
      case _ => node
    }
  }
  
  def toXML(__obj: Foo, __namespace: String, __elementLabel: String, __scope: scala.xml.NamespaceBinding): scala.xml.NodeSeq = {
    val prefix = __scope.getPrefix(__namespace)
    var attribute: scala.xml.MetaData  = scala.xml.Null
    
    scala.xml.Elem(prefix, __elementLabel,
      attribute, __scope,
      (__obj.bar match {
          case Some(x) => Seq(scala.xml.Elem(prefix, "bar", scala.xml.Null, __scope, scala.xml.Text(x.toString)))
          case None => Nil
        }): _*)
  }
  

}

trait  FooAll

Error:

[error]  found   : scala.collection.immutable.Seq[Long]
[error]  required: Option[Long]
[error]     case node: scala.xml.Node => Foo((node \ "bar") map { x => x.text.to
Long })
[error]                                                     ^
[error] one error found

complexType with simpleContent restriction based on a complexType with complexContent

By spec, a simpleContent can be a restriction of a complexType with complexContent as long as the base is mixed and emptiable. http://www.w3.org/TR/xmlschema-1/#d0e7923

$ scalaxb -p:http://www.w3.org/2001/XMLSchema=xs -p:http://www.w3.org/1999/XSL/Transform=xsl schema-for-xslt20.xsd XMLSchema.xsdjava.lang.RuntimeException: Args: Unsupported type ReferenceTypeSymbol(xsl:versioned-element-type)
    at scala.Predef$.error(Predef.scala:58)
    at scalaxb.compiler.xsd.Args$class.buildArg(Args.scala:168)
    at scalaxb.compiler.xsd.GenSource.buildArg(GenSource.scala:30)
    at scalaxb.compiler.xsd.GenSource.argsString$1(GenSource.scala:328)
    at scalaxb.compiler.xsd.GenSource.companionCode$1(GenSource.scala:396)
    at scalaxb.compiler.xsd.GenSource.makeCaseClassWithType(GenSource.scala:440)
    at scalaxb.compiler.xsd.GenSource.makeSuperType(GenSource.scala:133)
    at scalaxb.compiler.xsd.GenSource$$anonfun$run$1.apply(GenSource.scala:63)
    at scalaxb.compiler.xsd.GenSource$$anonfun$run$1.apply(GenSource.scala:59)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
    at scala.collection.immutable.List.map(List.scala:45)
    at scalaxb.compiler.xsd.GenSource.run(GenSource.scala:59)
    at scalaxb.compiler.xsd.Driver.generate(Driver.scala:49)
    at scalaxb.compiler.xsd.Driver.generate(Driver.scala:32)
    at scalaxb.compiler.Module$$anonfun$processReaders$1.apply(Module.scala:98)
    at scalaxb.compiler.Module$$anonfun$processReaders$1.apply(Module.scala:92)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:44)
    at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
    at scalaxb.compiler.Module$class.processReaders(Module.scala:92)
    at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:32)
    at scalaxb.compiler.Module$class.processFiles(Module.scala:63)
    at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:32)
    at scalaxb.compiler.Main$.start(Main.scala:84)
    at scalaxb.compiler.Main$.main(Main.scala:32)
    at scalaxb.compiler.Main.main(Main.scala)

circular xs:import crashes scalaxb

reported by Andreas Sewe.

steps

  1. compile a schema with circular imports like DocBook.

problem

$ scalaxb -p:http://www.w3.org/1999/xlink=xlink= -p:http://docbook.org/ns/docbook=docbook assembly.xsd docbook.xsd xlink.xsd
java.lang.RuntimeException: Circular import: List(scalaxb.compiler.xsd.Driver$$anon$3@5de9ac4, scalaxb.compiler.xsd.Driver$$anon$3@5982bcde, scalaxb.compiler.xsd.Driver$$anon$3@163dc0bb)
    at scala.Predef$.error(Predef.scala:58)
    at scalaxb.compiler.Module$class.sortByDependency(Module.scala:135)
    at scalaxb.compiler.xsd.Driver.sortByDependency(Driver.scala:32)
    at scalaxb.compiler.Module$class.processReaders(Module.scala:87)
    at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:32)
    at scalaxb.compiler.Module$class.processFiles(Module.scala:63)
    at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:32)
    at scalaxb.compiler.Main$.start(Main.scala:84)
    at scalaxb.compiler.Main$.main(Main.scala:32)
    at scalaxb.compiler.Main.main(Main.scala)

expectation

XML Schema allows circular imports. Handle it.

ebay FindingService xsd results in code that doesn't compile

Hi

As you asked ...

I'd really appreciate if you could run it against your favorite xsd file and let me know the result.

... here's my feedback ....

I get a few errors when I try to compile the code generated from the Ebay FindingService xsd (extracted from http://developer.ebay.com/webservices/finding/latest/FindingService.wsdl).

e.g. on line 722 of FindingService.scala:

lazy val arg5 = arg3.arg5

should be

lazy val arg5 = arg3.arg6

Also, line 2083 of xmlprotocol.scala:

ebay.ErrorMessage(p1.toSeq map { _.nilOption map { fromXMLebay.ErrorData }}: _*) }

gives the error:

type mismatch; found : Seq[Option[ebay.ErrorData]] required: Seq[ebay.ErrorData]

I tried changing the definition of class ebay.ErrorMessage to get past that, but other errors followed and I was soon out of my depth :-(

Hope that's useful.

Thanks

Damian.

problem following import

running

$ scalaxb epcglobal_1_0.xsd -p test

yields:

java.lang.RuntimeException: resolveType type not found: epcglobal:EPC ReferenceTypeSymbol(epcglobal:EPC,null)
    at scala.Predef$.error(Predef.scala:58)
    at scalaxb.compiler.xsd.ContextProcessor$class.resolveTypeSymbol$1(ContextProcessor.scala:195)
    at scalaxb.compiler.xsd.ContextProcessor$$anonfun$resolveType$1.apply(ContextProcessor.scala:201)
    at scalaxb.compiler.xsd.ContextProcessor$$anonfun$resolveType$1.apply(ContextProcessor.scala:201)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scalaxb.compiler.xsd.ContextProcessor$class.resolveType(ContextProcessor.scala:201)
    at scalaxb.compiler.xsd.Driver$$anon$3.resolveType(Driver.scala:40)
    at scalaxb.compiler.xsd.ContextProcessor$$anonfun$processContext$2.apply(ContextProcessor.scala:71)
    at scalaxb.compiler.xsd.ContextProcessor$$anonfun$processContext$2.apply(ContextProcessor.scala:68)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:44)
    at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
    at scalaxb.compiler.xsd.ContextProcessor$class.processContext(ContextProcessor.scala:68)
    at scalaxb.compiler.xsd.Driver$$anon$3.processContext(Driver.scala:40)
    at scalaxb.compiler.xsd.Driver.processContext(Driver.scala:43)
    at scalaxb.compiler.xsd.Driver.processContext(Driver.scala:33)
    at scalaxb.compiler.Module$class.processReaders(Module.scala:123)
    at scalaxb.compiler.xsd.Driver.processReaders(Driver.scala:33)
    at scalaxb.compiler.Module$class.processFiles(Module.scala:75)
    at scalaxb.compiler.xsd.Driver.processFiles(Driver.scala:33)
    at scalaxb.compiler.Main$.start(Main.scala:84)
    at scalaxb.compiler.Main$.main(Main.scala:32)
    at scalaxb.compiler.Main.main(Main.scala)

with the following two files:

epcglobal_1_0.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:epcis="urn:epcglobal:epcis:xsd:1" xmlns:sbdh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:epcglobal="urn:epcglobal:xsd:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:epcglobal:epcis:xsd:1" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="1.0">
    <xsd:annotation>
        <xsd:documentation xml:lang="en">
            <epcglobal:copyright>Copyright (C) 2006, 2005, 2004 EPCglobal Inc., All Rights Reserved.</epcglobal:copyright>
            <epcglobal:disclaimer>EPCglobal Inc., its members, officers, directors, employees, or agents shall not be liable for any injury, loss, damages, financial or otherwise, arising from, related to, or caused by the use of this document.  The use of said document shall constitute your express consent to the foregoing exculpation.</epcglobal:disclaimer>
            <epcglobal:specification>EPC INFORMATION SERVICE (EPCIS) Version 1.0</epcglobal:specification>
        </xsd:documentation>
    </xsd:annotation>
    <xsd:import namespace="urn:epcglobal:xsd:1" schemaLocation="./EPCglobal.xsd"/>
    <xsd:import namespace="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" schemaLocation="./StandardBusinessDocumentHeader.xsd"/>
    <!-- EPCIS CORE ELEMENTS -->
    <xsd:element name="EPCISDocument" type="epcis:EPCISDocumentType"/>
    <xsd:complexType name="EPCISDocumentType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            document that contains a Header and a Body.
                </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="epcglobal:Document">
                <xsd:sequence>
                    <xsd:element name="EPCISHeader" type="epcis:EPCISHeaderType" minOccurs="0"/>
                    <xsd:element name="EPCISBody" type="epcis:EPCISBodyType"/>
                    <xsd:element name="extension" type="epcis:EPCISDocumentExtensionType" minOccurs="0"/>
                    <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:anyAttribute processContents="lax"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="EPCISHeaderType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            specific header(s) including the Standard Business Document Header.
                </xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element ref="sbdh:StandardBusinessDocumentHeader"/>
            <xsd:element name="extension" type="epcis:EPCISHeaderExtensionType" minOccurs="0"/>
            <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="EPCISBodyType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            specific body that contains EPCIS related Events.
                </xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="EventList" type="epcis:EventListType" minOccurs="0"/>
            <xsd:element name="extension" type="epcis:EPCISBodyExtensionType" minOccurs="0"/>
            <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <!-- EPCIS CORE ELEMENT TYPES -->
    <xsd:complexType name="EventListType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="ObjectEvent" type="epcis:ObjectEventType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="AggregationEvent" type="epcis:AggregationEventType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="QuantityEvent" type="epcis:QuantityEventType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="TransactionEvent" type="epcis:TransactionEventType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="extension" type="epcis:EPCISEventListExtensionType"/>
            <xsd:any namespace="##other" processContents="lax"/>
        </xsd:choice>
        <!-- Note: the use of "unbounded" in both the xsd:choice element
                    and the enclosed xsd:element elements is, strictly speaking,
                    redundant. However, this was found to avoid problems with
                    certain XML processing tools, and so is retained here.
                -->
    </xsd:complexType>
    <xsd:complexType name="EPCListType">
        <xsd:sequence>
            <xsd:element name="epc" type="epcglobal:EPC" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:simpleType name="ActionType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="ADD"/>
            <xsd:enumeration value="OBSERVE"/>
            <xsd:enumeration value="DELETE"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="ParentIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <!-- Standard Vocabulary -->
    <xsd:simpleType name="BusinessStepIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <!-- Standard Vocabulary -->
    <xsd:simpleType name="DispositionIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <!-- User Vocabulary -->
    <xsd:simpleType name="EPCClassType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <!-- User Vocabulary -->
    <xsd:simpleType name="ReadPointIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <xsd:complexType name="ReadPointType">
        <xsd:sequence>
            <xsd:element name="id" type="epcis:ReadPointIDType"/>
            <xsd:element name="extension" type="epcis:ReadPointExtensionType" minOccurs="0"/>
            <!-- The wildcard below provides the extension mechanism described in Section 9.4 -->
            <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ReadPointExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <!-- User Vocabulary -->
    <xsd:simpleType name="BusinessLocationIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <xsd:complexType name="BusinessLocationType">
        <xsd:sequence>
            <xsd:element name="id" type="epcis:BusinessLocationIDType"/>
            <xsd:element name="extension" type="epcis:BusinessLocationExtensionType" minOccurs="0"/>
            <!-- The wildcard below provides the extension mechanism described in Section 9.4 -->
            <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BusinessLocationExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <!-- User Vocabulary -->
    <xsd:simpleType name="BusinessTransactionIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <!-- Standard Vocabulary -->
    <xsd:simpleType name="BusinessTransactionTypeIDType">
        <xsd:restriction base="xsd:anyURI"/>
    </xsd:simpleType>
    <xsd:complexType name="BusinessTransactionType">
        <xsd:simpleContent>
            <xsd:extension base="epcis:BusinessTransactionIDType">
                <xsd:attribute name="type" type="epcis:BusinessTransactionTypeIDType" use="optional"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
    <xsd:complexType name="BusinessTransactionListType">
        <xsd:sequence>
            <xsd:element name="bizTransaction" type="epcis:BusinessTransactionType" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <!-- items listed alphabetically by name -->
    <!-- Some element types accommodate extensibility in the manner of
        "Versioning XML Vocabularies" by David Orchard (see
        http://www.xml.com/pub/a/2003/12/03/versioning.html).

        In this approach, an optional <extension> element is defined
        for each extensible element type, where an <extension> element
        may contain future elements defined in the target namespace.

        In addition to the optional <extension> element, extensible element
        types are declared with a final xsd:any wildcard to accommodate
        future elements defined by third parties (as denoted by the ##other
        namespace).

        Finally, the xsd:anyAttribute facility is used to allow arbitrary
        attributes to be added to extensible element types. -->
    <xsd:complexType name="EPCISEventType" abstract="true">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            base type for all EPCIS events.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="eventTime" type="xsd:dateTime"/>
            <xsd:element name="recordTime" type="xsd:dateTime" minOccurs="0"/>
            <xsd:element name="eventTimeZoneOffset" type="xsd:string"/>
            <xsd:element name="baseExtension" type="epcis:EPCISEventExtensionType" minOccurs="0"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="ObjectEventType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            Object Event captures information about an event pertaining to one or more
            objects identified by EPCs.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="epcis:EPCISEventType">
                <xsd:sequence>
                    <xsd:element name="epcList" type="epcis:EPCListType"/>
                    <xsd:element name="action" type="epcis:ActionType"/>
                    <xsd:element name="bizStep" type="epcis:BusinessStepIDType" minOccurs="0"/>
                    <xsd:element name="disposition" type="epcis:DispositionIDType" minOccurs="0"/>
                    <xsd:element name="readPoint" type="epcis:ReadPointType" minOccurs="0"/>
                    <xsd:element name="bizLocation" type="epcis:BusinessLocationType" minOccurs="0"/>
                    <xsd:element name="bizTransactionList" type="epcis:BusinessTransactionListType" minOccurs="0"/>
                    <xsd:element name="extension" type="epcis:ObjectEventExtensionType" minOccurs="0"/>
                    <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:anyAttribute processContents="lax"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="AggregationEventType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            Aggregation Event captures an event that applies to objects that
            have a physical association with one another.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="epcis:EPCISEventType">
                <xsd:sequence>
                    <xsd:element name="parentID" type="epcis:ParentIDType" minOccurs="0"/>
                    <xsd:element name="childEPCs" type="epcis:EPCListType"/>
                    <xsd:element name="action" type="epcis:ActionType"/>
                    <xsd:element name="bizStep" type="epcis:BusinessStepIDType" minOccurs="0"/>
                    <xsd:element name="disposition" type="epcis:DispositionIDType" minOccurs="0"/>
                    <xsd:element name="readPoint" type="epcis:ReadPointType" minOccurs="0"/>
                    <xsd:element name="bizLocation" type="epcis:BusinessLocationType" minOccurs="0"/>
                    <xsd:element name="bizTransactionList" type="epcis:BusinessTransactionListType" minOccurs="0"/>
                    <xsd:element name="extension" type="epcis:AggregationEventExtensionType" minOccurs="0"/>
                    <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:anyAttribute processContents="lax"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="QuantityEventType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            Quantity Event captures an event that takes place with respect to a specified quantity of
            object class.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="epcis:EPCISEventType">
                <xsd:sequence>
                    <xsd:element name="epcClass" type="epcis:EPCClassType"/>
                    <xsd:element name="quantity" type="xsd:int"/>
                    <xsd:element name="bizStep" type="epcis:BusinessStepIDType" minOccurs="0"/>
                    <xsd:element name="disposition" type="epcis:DispositionIDType" minOccurs="0"/>
                    <xsd:element name="readPoint" type="epcis:ReadPointType" minOccurs="0"/>
                    <xsd:element name="bizLocation" type="epcis:BusinessLocationType" minOccurs="0"/>
                    <xsd:element name="bizTransactionList" type="epcis:BusinessTransactionListType" minOccurs="0"/>
                    <xsd:element name="extension" type="epcis:QuantityEventExtensionType" minOccurs="0"/>
                    <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:anyAttribute processContents="lax"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="TransactionEventType">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
            Transaction Event describes the association or disassociation of physical objects to one or more business
            transactions.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="epcis:EPCISEventType">
                <xsd:sequence>
                    <xsd:element name="bizTransactionList" type="epcis:BusinessTransactionListType"/>
                    <xsd:element name="parentID" type="epcis:ParentIDType" minOccurs="0"/>
                    <xsd:element name="epcList" type="epcis:EPCListType"/>
                    <xsd:element name="action" type="epcis:ActionType"/>
                    <xsd:element name="bizStep" type="epcis:BusinessStepIDType" minOccurs="0"/>
                    <xsd:element name="disposition" type="epcis:DispositionIDType" minOccurs="0"/>
                    <xsd:element name="readPoint" type="epcis:ReadPointType" minOccurs="0"/>
                    <xsd:element name="bizLocation" type="epcis:BusinessLocationType" minOccurs="0"/>
                    <xsd:element name="extension" type="epcis:TransactionEventExtensionType" minOccurs="0"/>
                    <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
                <xsd:anyAttribute processContents="lax"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="EPCISDocumentExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="EPCISHeaderExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="EPCISBodyExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="EPCISEventListExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="EPCISEventExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="ObjectEventExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="AggregationEventExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="QuantityEventExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
    <xsd:complexType name="TransactionEventExtensionType">
        <xsd:sequence>
            <xsd:any namespace="##local" processContents="lax" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:anyAttribute processContents="lax"/>
    </xsd:complexType>
</xsd:schema>

and EPCglobal.xsd:

<xsd:schema xmlns:epcglobal="urn:epcglobal:xsd:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:epcglobal:xsd:1" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="1.0">
    <xsd:annotation>
        <xsd:documentation>
            <epcglobal:copyright>Copyright (C) 2004 Epcglobal Inc., All Rights Reserved.</epcglobal:copyright>
            <epcglobal:disclaimer>EPCglobal Inc., its members, officers, directors, employees, or agents shall not be liable for any injury, loss, damages, financial or otherwise, arising from, related to, or caused by the use of this document.  The use of said document shall constitute your express consent to the foregoing exculpation.</epcglobal:disclaimer>
            <epcglobal:specification>EPCglobal common components Version 1.0</epcglobal:specification>
        </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType name="Document" abstract="true">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
         EPCglobal document properties for all messages.
      </xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="schemaVersion" type="xsd:decimal" use="required">
            <xsd:annotation>
                <xsd:documentation xml:lang="en">
           The version of the schema corresponding to which the instance conforms. 
        </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="creationDate" type="xsd:dateTime" use="required">
            <xsd:annotation>
                <xsd:documentation xml:lang="en">
           The date the message was created. Used for auditing and logging.
        </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="EPC">
        <xsd:annotation>
            <xsd:documentation xml:lang="en">
         EPC represents the Electronic Product Code.
      </xsd:documentation>
        </xsd:annotation>
        <xsd:simpleContent>
            <xsd:extension base="xsd:string"/>
        </xsd:simpleContent>
    </xsd:complexType>
</xsd:schema>

---- thanks ... david bolene

local elements are not parsed correctly when the form is unqualified

I'm not an XML expert (by choice :-) but isn't it legal to not have a default ns attribute like xmlns="someNameSpace" at the root but instead something like:
"xmlns:nsname="someNameSpace" and then prefix the root element with <nsname:RootElement>...</nsname:RootElement>?

scalaxb can't seem to handle this

A full example:

<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1" creationDate="2010-03-15T06:07:08Z"
             schemaVersion="1">
   <EPCISBody>
      <EventList>
     <ObjectEvent>
        <eventTime>2010-03-22T11:47:01-05:00</eventTime>
        <eventTimeZoneOffset>-05:00</eventTimeZoneOffset>
        <epcList>
           <epc>urn:epc:id:sgtin:0614141.012345.101</epc>
           <epc>urn:epc:id:sgtin:0614141.012345.102</epc>
        </epcList>
        <action>OBSERVE</action>
        <bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
        <disposition>urn:epcglobal:cbv:disp:in_transit</disposition>
        <readPoint>
           <id>urn:epc:id:sgln:0614141.00000.1234</id>
        </readPoint>
        <bizTransactionList>
           <bizTransaction type="urn:epcglobal:cbv:btt:po">urn:epcglobal:cbv:bt:0614141000005:XYZ123</bizTransaction>
           <bizTransaction type="urn:epcglobal:cbv:btt:desadv">urn:epcglobal:cbv:bt:0614141000005:DA123</bizTransaction>
        </bizTransactionList>
     </ObjectEvent>
      </EventList>
   </EPCISBody>
</epcis:EPCISDocument>

error: too many arguments for method apply

Compile resulting xmlprotocol.scala error (scheme: http://dump.ru/file/5061348 )

error: too many arguments for method apply: (devicessequence2: ru.efir.renoise.xml.renoisedevicechain.DevicesSequence2,devicessequence3: ru.efir.renoise.xml.renoisedevicechain.DevicesSequence3,devicessequence4: ru.efir.renoise.xml.renoisedevicechain.DevicesSequence4,devicessequence5: ru.efir.renoise.xml.renoisedevicechain.DevicesSequence5,devicessequence6: ru.efir.renoise.xml.renoisedevicechain.DevicesSequence6)ru.efir.renoise.xml.renoisedevicechain.DevicesSequence1 in object DevicesSequence1
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 ~ p7 ~ p8 ~ p9 ~ p10 ~ p11 ~ p12 ~ p13 ~ p14 ~ p15 ~ p16 ~ p17 ~ p18 ~ p19 ~ p20 ~ p21 ~ p22 ~ p23 ~ p24 ~ p25 ~ p26 ~ p27 ~ p28 ~ p29 ~ p30 ~ p31 ~ p32 ~ p33 ~ p34 ~ p35 ~ p36 ~ p37 ~ p38 ~ p39 ~ p40 ~ p41 ~ p42 ~ p43 ~ p44 ~ p45 => ru.efir.renoise.xml.renoisedevicechain.DevicesSequence1(p1.toSeq map { fromXML[ru.efir.renoise.xml.renoisedevicechain.FormulaMetaDevice](_) },

Possible naming error in codegen

Once again using the vCloud API 1.0 XSDs, generating the code, compiling it (successfully!) and attempting to use it with:

import scalaxb._
import com.vmware.vcloud._
...

results in:

[info] == test-compile ==
[info]   Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling test sources...
[error] class file needed by XMLProtocol is missing.
[error] reference type Network of package com.vmware.vcloud refers to nonexisting symbol.
[error] one error found
[info] == test-compile ==
[error] Error running test-compile: Compilation failed

There is a network.scala file, but it declares NetworkType, among other things, rather than Network.

--no-runtime or runtime jar

reported by @martiell.

steps

  1. generate code in multiple projects.
  2. link them.

problem

  1. duplicate scalaxb runtime

expectations

either --no-runtime or a separate jar.

non-single top-level sequence

steps

  1. non-single top-level sequence:

    <xs:complexType name="TopLevelMultipleSeqAnyTest" mixed="true">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:any namespace="##other" processContents="lax"/>
      </xs:sequence>
    </xs:complexType>
    

problem

it's treated as single.

expectations

respect occurrence.

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.