--class-prefix and --param-prefix
I added two command line options --class-prefix
and --param-prefix
to add prefixes to the generated code. It shouldn't be needed if the schema uses lower case for element names like many of the well-known schemas (slap me if you catch me say schemata or octopodes). This is because scalaxb capitalizes the class name, but leaves the params alone, so you'd end up with code like the following:
case class USAddress(name: String, street: String, city: String, usstate: USState, zip: Int) extends Addressable
Suppose the element names were also capitalized in the schema, then it would produce something like this:
case class USAddress(Name: String, Street: String, City: String, USState: USState, Zip: Int) extends Addressable
Although this is legal code, the fact that USState
can mean two things can be confusing. This is where --param-prefix
could be used to prefix the parameters. For example, if we pick m
, it would produce:
case class USAddress(mName: String, mStreet: String, mCity: String, mUSState: USState, mZip: Int) extends Addressable
If for some reason you would like to prefix the class names, you can use --class-prefix
. If we pick X
, it would produce:
case class XUSAddress(mName: String, mStreet: String, mCity: String, mUSState: XUSState, mZip: Int) extends XAddressable
There's a detail I implemented for prefixing for lower case names. scalaxb will capitalize the original name before prefixing both the param name or class name, except for the case when the prefix ends in _
. Supposed the prefix m
was chosen for the first example, then it would produce:
case class USAddress(mName: String, mStreet: String, mCity: String, mUsstate: USState, mZip: Int) extends Addressable
But if m_
was chosen, then it would produce:
case class USAddress(m_name: String, m_street: String, m_city: String, m_usstate: USState, m_zip: Int) extends Addressable