Add value to choice element

Skip to first unread message

Kees den Brees

Nov 6, 2013, 3:53:27 PM11/6/13
I'm trying to create xml using the following relevent part of the xsd

    <xs:complexType name="ServiceLevel8Choice">
<xs:element name="Cd" type="ExternalServiceLevel1Code"/>
<xs:element name="Prtry" type="Max35Text"/>

    <xs:simpleType name="ExternalServiceLevel1Code">
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="4"/>

With generated scalaxb code I am trying to generate this element:
val elm = ServiceLevel8Choice(scalaxb.DataRecord(None, Some("Cd"), "code"))
which then gives me the following compile error
could not find implicit value for evidence parameter of type scalaxb.CanWriteXML[String] 

This seems caused by the String "code", which should be an element. But there is no such thing as an ExternalServiceLevel1Code object.
Note that these are my first steps on the scala language, which is probably the cause of this question. Hope you can give me a pointer in the right direction.

eugene yokota

Nov 7, 2013, 8:11:06 AM11/7/13
Like the error message says, it's likely missing the implicit value for evidence parameter in the scope.
This is a typical error message you see when something is using typeclass pattern.

To fix this you need to import an implicit value that implements scalaxb.CanWriteXML[String].
By default they are defined under the package object the target package you selected, which is generated in xmlprotocol.scala.


You received this message because you are subscribed to the Google Groups "scalaxb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Patrick Refondini

Feb 2, 2017, 10:20:00 AM2/2/17
to scalaxb

Using scalaxb 1.5.0.

Facing similar compilation error, given scalaxbPackageName is "ch.mypackge.mysubpackage" I had to:
import ch.mypackge.mysubpackage._
in order for the necessary implicits scalaxb.CanWriteXML[XXX]  to be available.
They are found in xmlprotocol.scala trait XMLProtocol.

@eugene yokota thanks for your helpful explanations.
Reply all
Reply to author
0 new messages