Permalink
Browse files

added lexical representation of boolean

  • Loading branch information...
1 parent f1525dc commit d46478f17fc0bdf0cc35e11006172edbe3ca1dcc @rssh committed Dec 14, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 cli/src/main/resources/scalaxb.scala.template
@@ -175,7 +175,11 @@ trait XMLStandardTypes {
implicit lazy val __BooleanXMLFormat: XMLFormat[Boolean] = new XMLFormat[Boolean] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Boolean] = try {
- Right(seq.text.toBoolean) } catch { case e: Exception => Left(e.toString) }
+ seq.text match {
+ case "1" | "true" => Right(true)
+ case "0" | "false" => Right(false)
+ case x => Left("Invalid boolean: "+x)
+ }
def writes(obj: Boolean, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =

0 comments on commit d46478f

Please sign in to comment.