-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get a "missing element label" exception when a try to serialize a xsd:choise element #138
Comments
val address = Address(scalaxb.DataRecord(internalAddress)); Change the above to: val address = Address(scalaxb.DataRecord(None, Some("internalAddress"), internalAddress)); |
Thanks for the answer. However passing "internalAddress" as a string is not very safe (an error cannot be detected at compile time). How about something similar to JAXB? for instance:
however this is not a final class. or:
and you check that one and only one (internalAddres or externalAddress) is provided. or maybe the easiest and safest could be:
|
I added #141 as feature request. |
Thanks! Another related question, could scalaxb be modified so that this works: that is, can the use of DataRecord be hidden to the user in this case? is there a raison why this simple code could not work? |
scalaxb is a data binding tool, which prioritizes the schema, and XML input and output over the generated code. Basic assumption is that the schema author knew what he was doing, and I should stick to it. Otherwise, it won't be able to write back to the same XML afterwards. In this simple example, |
could you modify the example XSD above to show a case where writing that simple code would not be possible? |
Here's a sample project I created: https://github.com/eed3si9n/scalaxb-sample/tree/gh-138/gh138-sample I derived another type of Address called TypedAddress: <xsd:complexType name="TypedAddress">
<xsd:complexContent>
<xsd:extension base="ex:Address">
<xsd:sequence>
<xsd:element name="addressType" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType> This could be used as follows: val address2 = TypedAddress(scalaxb.DataRecord(None, Some("internalAddress"), internalAddress), "Billing")
val customer2 = Customer(name = "john", id = "22", address = address2) |
Great job. For the record it also works the same way for restriction on complexContent (also generate a My wsdl looks like <s:complexType name="ArrayPdfArray">
<s:complexContent>
<s:restriction base="soapenc:Array">
<s:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:ArrayPdf[]"/>
</s:restriction>
</s:complexContent>
</s:complexType> And consumer code ArrayPdfArray(
arraySequence1 = Some(ArraySequence(
any2 = scalaxb.DataRecord(None, Some("ArrayPdf"),
ArrayPdf(
//Whatever properties ArrayPdf contains
)
)
)),
attributes = Map()
) |
I get a "missing element label" exception when I try to serialize a xsd:choise element.
This is a compact example illustrating the error:
example XSD with xs:choice:
The text was updated successfully, but these errors were encountered: