scalaxb generate XML element with attributes

813 Views Asked by At

scalaxb has generated the following case class definition based on my XSD:

case class Identifier(
   value: String,
   attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
   lazy val typeValue = attributes("@type").as[String]
 }

I'm struggling with how to instance this case class (especially how to add to its attributes). Tried the below option

Identifier("name", Map("@attribute" -> scalaxb.DataRecord("attributeStringVal"))

When i tried to create a Map and pass it on to Identifier object, I am getting the below error while compiling the scala code

"could not find implicit value for evidence parameter of type scalaxb.CanWriteXML[String]".

Anyone faced similar issue?

1

There are 1 best solutions below

0
On

I had a similar error. In order to implicit scalaxb.CanWriteXML[String] to be available, you need to import the scalaxbPackageName. It can be found in xmlProtocol.scala trait. Assuming scalaxbPackageName is com.package.subpackage then you need to import com.package.subpackage._