Skip to content

Commit

Permalink
Update ScalaXB to generate default labels for XML elements
Browse files Browse the repository at this point in the history
See eed3si9n/scalaxb#467 for details.
  • Loading branch information
hosamaly committed Mar 13, 2018
1 parent 7e666fa commit bb130df
Show file tree
Hide file tree
Showing 9 changed files with 741 additions and 85 deletions.
3 changes: 2 additions & 1 deletion 3.3/scalaxb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ trait CanReadXML[A] {
}

trait CanWriteXML[A] {
def defaultElementLabel: Option[String] = None
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq
}
Expand Down Expand Up @@ -733,7 +734,7 @@ trait CanWriteChildNodes[A] extends CanWriteXML[A] {
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = {
val elem = scala.xml.Elem(Helper.getPrefix(namespace, scope).orNull,
elementLabel getOrElse { sys.error("missing element label.") },
elementLabel orElse defaultElementLabel getOrElse { sys.error("missing element label.") },
writesAttribute(obj, scope),
scope, true,
writesChildNodes(obj, scope): _*)
Expand Down
203 changes: 183 additions & 20 deletions 3.3/xmlprotocol.scala

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion 3.4/scalaxb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ trait CanReadXML[A] {
}

trait CanWriteXML[A] {
def defaultElementLabel: Option[String] = None
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq
}
Expand Down Expand Up @@ -733,7 +734,7 @@ trait CanWriteChildNodes[A] extends CanWriteXML[A] {
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = {
val elem = scala.xml.Elem(Helper.getPrefix(namespace, scope).orNull,
elementLabel getOrElse { sys.error("missing element label.") },
elementLabel orElse defaultElementLabel getOrElse { sys.error("missing element label.") },
writesAttribute(obj, scope),
scope, true,
writesChildNodes(obj, scope): _*)
Expand Down
203 changes: 183 additions & 20 deletions 3.4/xmlprotocol.scala

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion 3.5/scalaxb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ trait CanReadXML[A] {
}

trait CanWriteXML[A] {
def defaultElementLabel: Option[String] = None
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq
}
Expand Down Expand Up @@ -733,7 +734,7 @@ trait CanWriteChildNodes[A] extends CanWriteXML[A] {
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = {
val elem = scala.xml.Elem(Helper.getPrefix(namespace, scope).orNull,
elementLabel getOrElse { sys.error("missing element label.") },
elementLabel orElse defaultElementLabel getOrElse { sys.error("missing element label.") },
writesAttribute(obj, scope),
scope, true,
writesChildNodes(obj, scope): _*)
Expand Down
203 changes: 183 additions & 20 deletions 3.5/xmlprotocol.scala

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion 3.6/scalaxb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ trait CanReadXML[A] {
}

trait CanWriteXML[A] {
def defaultElementLabel: Option[String] = None
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq
}
Expand Down Expand Up @@ -733,7 +734,7 @@ trait CanWriteChildNodes[A] extends CanWriteXML[A] {
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = {
val elem = scala.xml.Elem(Helper.getPrefix(namespace, scope).orNull,
elementLabel getOrElse { sys.error("missing element label.") },
elementLabel orElse defaultElementLabel getOrElse { sys.error("missing element label.") },
writesAttribute(obj, scope),
scope, true,
writesChildNodes(obj, scope): _*)
Expand Down
203 changes: 183 additions & 20 deletions 3.6/xmlprotocol.scala

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The schemas used to generate the classes in this project are available in the [s
## Generated Sources

The source files were generated using an
[unreleased version of ScalaXB](https://github.com/eed3si9n/scalaxb/archive/5d0eea5a6c4d713976c9b86cc2cb691d0f83e137.zip)
[unreleased version of ScalaXB](https://github.com/eed3si9n/scalaxb/archive/a54acf3d30f081dba5c12e7217556199952b7c2d.zip)
that was built from source. Hopefully, it will be released in the main repository soon.

The following command was used to generate the files for each version:
Expand Down

0 comments on commit bb130df

Please sign in to comment.