Thanks for your interest in scalaxb!
> case class BaseProperty(Definition:
> Option[Option[PropertyDefinition]])
> case class PropertyDefinition(test: String)
>
> This use of nested options seems to be redundant, is there a way to
> avoid it?
No, blame the schema for redundancy. There are some situations where
one needs to clearly distinguish the difference between nill value and
lack of an element, so double Option is necessary from my point of
view.
For example, as a mandate of data binding tool scalaxb needs to
support round trips:
Start out with an XML document -> turn it into case class -> turn it
back into the original document.
Suppose we now encode nillable and optional (minOccurs = 0) element as
plain Option[PropertyDefinition]. You parse a document that has nil
value, it turns into None.
Now, when someone calls toXML to turn it back into XML document, how
would I know if it was nil or simply missing?
> In addition i think it would be nice if generated classes where using
> default argument, so ideally it would look like
> case class BaseProperty(Definition: Option[PropertyDefinition] = None)
>
> Is this possible?
I would have to think about this one.
For attributes, I think None are already supplied as default argument,
but I am not sure if it would make sense for elements as well.
-eugene
-eugene
On Mon, Nov 7, 2011 at 4:21 PM, OlegYch <oleg...@gmail.com> wrote:
> Hi Eugene.
>
> Thanks for the explanation. I'm really surprised how thoroughly you
> handle such subtleties.
>
> The thing is, that wsdl piece is generated by .NET server and I really
> doubt it can be corrected or if the underlying serializer
> differentiates between nil value and no element. E.g. the code
> generated by Axis2 for same piece just outputs nil value and doesn't
> care if it's nil or no element when parsing. I would suggest to add an
> option to flatten options in generate code, otherwise pattern matching
> can become cumbersome.
>
> As for default arguments for optional elements I don't see any
> correctness implications, would be great if you could share you
> thoughts on this.
>
> Thanks, Oleg.