scalaxb

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.

status

The latest is 1.2.1.
Many things still may not work. I'd really appreciate if you could run it against your favorite xsd file and let me know the result.

usage

$ scalaxb [options] <schema_file>...
 
  -d <directory> | --outdir <directory>
        generated files will go into <directory>
  -p <package> | --default-package <package>
        specifies the target package
  --package:<namespaceURI>=<package>
        specifies the target package for <namespaceURI>
  --class-prefix <prefix>
        prefixes generated class names
  --param-prefix <prefix>
        prefixes generated parameter names
  --prepend-family
        prepends family name to class names
  --wrap-contents <complexType>
        wraps inner contents into a seperate case class
  --contents-limit <size>
        defines long contents to be segmented (default: 20)
  --chunk-size <size>
        segments long sequences into chunks (default: 10)
  --package-dir
        generates package directories
  --protocol-file <name.scala>
        protocol file name (xmlprotocol.scala)
  --protocol-package <package>
        package for protocols
  --no-runtime
        skips runtime files
  --lax-any
        relaxes namespace constraints of xs:any
  --blocking
        generates blocking SOAP client
  --dispatch-version <version>
        version of Dispatch (default: 0.11.1)
  -v | --verbose
        be extra verbose
  --help
        display this message
  --version
        display version info
  <schema_file>...
        input schema to be converted

sponsors

Thanks to YourKit for supporting scalaxb! YourKit Java Profiler works great for profiling Scala applications.

scalaxb with Scala 2.11

Starting scalaxb 1.2.0 it supports Scala 2.11.x. Since Scala 2.11 modularizes XML and parser combinators, it requires additional setup on your part. Here's using sbt 0.13's multi-project build.sbt syntax:

import ScalaxbKeys._
 
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.2"
lazy val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1"
lazy val dispatchV = "0.11.2" // change this to appropriate dispatch version
lazy val dispatch = "net.databinder.dispatch" %% "dispatch-core" % dispatchV
 
lazy val root = (project in file(".")).

scalaxb 1.2.1

This is a bug fix release focused on fixing the SOAP code generation. See using SOAP for more details.

SOAP bug fixes

  • Fixes xs:AnyType handling. #265
  • Fixes asFault not Throwable error. #264 reported by @romainreuillon
  • Fixes the generated code for multipart SOAP message. #267 reported by @tomhaigh
  • Fixes the definition of HttpClientsAsync to use concurrent.Future. #269 reported by @hedefalk
  • Adds --blocking command line option to generate blocking SOAP client.

minor enhancements

  • Masks scalaxb package that's used internally to generate code.

scalaxb 1.2.0

non-blocking SOAP

scalaxb 1.2.0 generates non-blocking SOAP code by default. Instead of Either[X, A], the SOAP call returns Future[A] and the fault, if any, is thrown as Future's failure semantics.

// default
def getQuote(symbol: Option[String]): Future[stockquote.GetQuoteResponse]
 
// async in (Compile, scalaxb) := false
def getQuote(symbol: Option[String]): Either[scalaxb.Fault[Any], stockquote.GetQuoteResponse]

This feature was contributed by @jlavallee and @hoff2 as #213/#259. See using soap for more details.

SOAP bug fixes

  • Escapes reserve words appearing as a parameter in SOAP. #252/#256 contributed by @romainreuillon
  • Escapes reserve words appearing as an operation name in SOAP. #241 reported by @rcgoodfellow
  • Fixes handling of nillable elements appearing in SOAP. #229 reported by @barnesjd
  • Fixes string encoding problems while posting SOAP. #231 reported by @hedefalk
  • Supports Dispatch 0.11.1.
  • Fixes response parsing for literal RPC style. #260 reported by @romainreuillon

bug fixes and minor enhancements

  • Drops Scala 2.9.0 and removing deprecated warnings.
  • Caches DatatypeFactory instance to ThreadLocal. #243 contributed by @malaporte
  • Fixes handing of zero-length prefix. #253/#255 contributed by @romainreuillon
  • Fixes mixed attribute not being inherited when extending a complex type. #228 reported by @choffmeister
  • Fixes non-terminating parser when unbounded is nested. #230 reported by @FranklinChen
  • Fixes handling of xs:element with default with minOccurs = 1. #245 reported by @alboko
  • Fixes handling of very long xs:enumeration value. #247 reported by @jcranky
  • Fixes handling of xs:element names with symbols when --class-prefix is passed. #251 reported by @romangarcia
  • Fixes xs:group parser getting inherited twice. #238 reported by @choeger

scalaxb 1.1.2

bug fixes and minor enhancements

  • Fixes blank xs:enumeration value generating broken case object. #220 reported by @FranklinChen and others.
  • Fixes generated field for an attribute named value conflicting with the value field for xs:simpleContent. #221 reported by @lyle-janrain

scalaxb 1.1.1

breaking change to commandline

scalaxb cli used -p and --package to specify both the default package name and namespace-specific package names. scalaxb 1.1.1 uses -p and --default-package for the default package; and --package for namespace-specific package names.

bug fixes and minor enhancements

  • Avoids type names that only differs in case. #215 reported by @drdozer
  • Fixes handling of xs:all with minOccurs=0 and nillable. #216 reported by @minettiandrea
  • Fixes xsi:nil="1" not parsed as nil. #217 reported by @aoprisan
  • Improves handling of chameleon schema. #102
  • Configures dispatchVersion to 0.10.1 by default.
  • Updates sbt-scalaxb for sbt 0.13.

scalaxb 1.1.0

breaking changes

  • scalaxb now generates sys.error, so the generated code will no longer be compilable under Scala 2.8. #115 reported by @idot and others.

dispatchVersion

A new key dispatchVersion was added to generate Dispatch 0.10.x compatible code #210:

dispatchVersion in scalaxb in Compile := "0.10.0"

libraryDependencies <+=(dispatchVersion in scalaxb in Compile) { dv =>
  "net.databinder.dispatch" %% "dispatch-core" % dv
}

bug fixes and minor enhancements

  • Includes offending data in ParserFailure message. #206 requested by @caoilte
  • Fixes handling of QName enums. #208
  • sbt-scalaxb sorts *.xsd to avoid platform variance. #207 reported by @caoilte
  • sbt-scalaxb generates code only when the xsd files are modified. #199 requested by @fommil

scalaxb 1.0.2

bug fixes

  • Fixes handling of large groups. #188 reported by @workingDog
  • Fixes handling of xs:any with namespace constraints. #189
  • Removes upper limit on duplicate name resolution. #190
  • Fixes handling of enum values that are symbols. #191
  • Fixes xs:group references naming conflict. #192
  • Fixes handling of xs:choice that's made up of a foreign type. #193
  • Fixes handling of split xs:sequence whose only item is nillable and unbounded. #194
  • Fixes handling of xs:choice that includes a substitution group. #195
  • Fixes handling of complex types containing foreign xs:sequence. #196
  • Fixes handling of xs:group or a mixed complex type that includes an optional substitution group. #197
  • Fixes handling of complex types that directly or indirectly derives from xs:anySimpleType. #200/#203 reported by @sagarcjoshi
  • Fixes handling of mixed complex type that extends simple type. #205
  • Fixes DispatchHttpClients not handling non-200 results. reported and fixed by @dportabella in #204

scalaxb 1.0.1

bug fixes and minor enhancements

Syndicate content