Add value to choice element

339 views
Skip to first unread message

Kees den Brees

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

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

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


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

unread,
Nov 7, 2013, 8:11:06 AM11/7/13
to sca...@googlegroups.com
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.

-eugene


--
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 scalaxb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Patrick Refondini

unread,
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
Forward
0 new messages