Adding attribute to case class

196 views
Skip to first unread message

Jason Boorn

unread,
Sep 28, 2015, 4:28:39 PM9/28/15
to scalaxb
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).  I looked around and could not find an example where a case class with attribute is constructed, something like . . .

Identifier(value="xxx", attributes=???)

or am I missing something in my approach?

Thanks

John Dimeo

unread,
Oct 14, 2015, 10:31:44 PM10/14/15
to scalaxb
I'm having the same problem. When I use the online scalaxb (http://scalaxb.org/online) it works great (case class Identifier(type: String) according to the example below), but I when I'm running locally, it produces similar problematic output. Thanks
  -John

Jason Boorn

unread,
Oct 15, 2015, 7:31:05 AM10/15/15
to scalaxb
Not sure if this helps you but I ended up using something like this to construct the Identifier:

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

Kir Vondreth

unread,
Jul 6, 2016, 1:42:14 AM7/6/16
to scalaxb
Hello,

I am looking for the same thing, but, for me, the solution you mention only leads to:
"could not find implicit value for evidence parameter of type scalaxb.CanWriteXML[String]".
In other posts, it is said there must be an implicit implementing "scalaxb.CanWriteXML[String]" imported.
I don't find any. Is there a working example of this?
(using sbt-scalaxb 1.4.0)

Naren S

unread,
Jun 8, 2018, 11:43:41 AM6/8/18
to scalaxb

Hi All,

I am also facing same issue. Any Luck and solution pls.

Regards, Naren

Naren S

unread,
Jun 13, 2018, 8:24:23 AM6/13/18
to scalaxb
Hello Team,

I am also looking for the same solution. Any pointers or solutions would be of great help.
 "could not find implicit value for evidence parameter of type scalaxb.CanWriteXML[String]"

Please let us know how to generate an XML along with attributes using scalaxb.

Regards,
Naren
Reply all
Reply to author
Forward
0 new messages