Skip to content

Instantly share code, notes, and snippets.

@Jacoby6000
Created March 27, 2018 20:36
Show Gist options
  • Save Jacoby6000/c13cfec665c4a10220280edf270716b4 to your computer and use it in GitHub Desktop.
Save Jacoby6000/c13cfec665c4a10220280edf270716b4 to your computer and use it in GitHub Desktop.
package scalaxb
import scala.xml.{Node, NodeSeq, NamespaceBinding, Elem, UnprefixedAttribute, PrefixedAttribute}
import javax.xml.datatype.{XMLGregorianCalendar}
import javax.xml.namespace.QName
import javax.xml.bind.DatatypeConverter
import scala.language.postfixOps
import scala.language.implicitConversions
import scala.language.existentials
object `package` {
import annotation.implicitNotFound
@implicitNotFound(msg = "Cannot find XMLFormat type class for ${A}")
def fromXML[A](seq: NodeSeq, stack: List[ElemName] = Nil)
(implicit format: XMLFormat[A]): A = format.reads(seq, stack) match {
case Right(a) => a
case Left(a) => throw new ParserFailure("Error while parsing %s: %s" format(seq.toString, a))
}
@implicitNotFound(msg = "Cannot find XMLFormat type class for ${A}")
def fromXMLEither[A](seq: NodeSeq, stack: List[ElemName] = Nil)
(implicit format: XMLFormat[A]): Either[String, A] = format.reads(seq, stack)
@implicitNotFound(msg = "Cannot find CanWriteXML type class for ${A}")
def toXML[A](obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean = false)(implicit format: CanWriteXML[A]): NodeSeq =
format.writes(obj, namespace, elementLabel, scope, typeAttribute)
@implicitNotFound(msg = "Cannot find CanWriteXML type class for ${A}")
def toXML[A](obj: A, namespace: Option[String], elementLabel: String, scope: NamespaceBinding)
(implicit format: CanWriteXML[A]): NodeSeq =
toXML(obj, namespace, Some(elementLabel), scope, false)
@implicitNotFound(msg = "Cannot find CanWriteXML type class for ${A}")
def toXML[A](obj: A, elementLabel: String, scope: NamespaceBinding)(implicit format: CanWriteXML[A]): NodeSeq =
toXML(obj, None, Some(elementLabel), scope, false)
/** @return - maps from prefix to namespace URI.
*/
def fromScope(scope: NamespaceBinding): List[(Option[String], String)] = {
def doFromScope(s: NamespaceBinding): List[(Option[String], String)] = {
lazy val parentMap: List[(Option[String], String)] = Option[NamespaceBinding](s.parent) map { doFromScope
} getOrElse { Nil }
scalaxb.Helper.nullOrEmpty(s.uri) map { uri => (scalaxb.Helper.nullOrEmpty(s.prefix) -> uri) :: parentMap } getOrElse {parentMap}
}
doFromScope(scope).reverse
}
/** @param pairs - pairs of (prefix, namespace URI)
*/
def toScope(pairs: (Option[String], String)*): NamespaceBinding =
pairs.reverse.foldLeft[NamespaceBinding](scala.xml.TopScope) { (scope, pair) =>
scala.xml.NamespaceBinding(pair._1.getOrElse{null}, pair._2, scope) }
}
trait XMLFormat[A] extends CanWriteXML[A] with CanReadXML[A]
trait CanReadXML[A] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, A]
}
trait CanWriteXML[A] {
def writes(obj: A, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq
}
object XMLStandardTypes extends XMLStandardTypes {
}
trait XMLStandardTypes {
implicit lazy val __NodeXMLFormat: XMLFormat[Node] = new XMLFormat[Node] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Node] = seq match {
case node: Node => Right(node)
case _ => Left("scala.xml.Node is required.")
}
def writes(obj: Node, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq = Helper.mergeNodeScope(obj, scope)
}
implicit lazy val __NodeSeqXMLFormat: XMLFormat[NodeSeq] = new XMLFormat[NodeSeq] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, NodeSeq] = Right(seq)
def writes(obj: NodeSeq, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq = Helper.mergeNodeSeqScope(obj, scope)
}
implicit lazy val __ElemXMLFormat: XMLFormat[Elem] = new XMLFormat[Elem] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Elem] = seq match {
case elem: Elem => Right(elem)
case _ => Left("scala.xml.Elem is required.")
}
def writes(obj: Elem, namespace: Option[String], elementLabel: Option[String],
scope: NamespaceBinding, typeAttribute: Boolean): NodeSeq = Helper.mergeNodeScope(obj, scope)
}
implicit lazy val __StringXMLFormat: XMLFormat[String] = new XMLFormat[String] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, String] = Right(seq.text)
def writes(obj: String, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj, namespace, elementLabel, scope)
}
implicit lazy val __IntXMLFormat: XMLFormat[Int] = new XMLFormat[Int] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Int] = try {
Right(seq.text.toInt) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Int, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __ByteXMLFormat: XMLFormat[Byte] = new XMLFormat[Byte] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Byte] = try {
Right(seq.text.toByte) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Byte, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __ShortXMLFormat: XMLFormat[Short] = new XMLFormat[Short] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Short] = try {
Right(seq.text.toShort) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Short, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __LongXMLFormat: XMLFormat[Long] = new XMLFormat[Long] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Long] = try {
Right(seq.text.toLong) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Long, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __BigDecimalXMLFormat: XMLFormat[BigDecimal] = new XMLFormat[BigDecimal] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, BigDecimal] = try {
Right(BigDecimal(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: BigDecimal, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.bigDecimal.toEngineeringString, namespace, elementLabel, scope)
}
implicit lazy val __BigIntXMLFormat: XMLFormat[BigInt] = new XMLFormat[BigInt] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, BigInt] = try {
Right(BigInt(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: BigInt, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __FloatXMLFormat: XMLFormat[Float] = new XMLFormat[Float] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Float] = try {
Right(seq.text.toFloat) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Float, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __DoubleXMLFormat: XMLFormat[Double] = new XMLFormat[Double] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Double] = try {
Right(seq.text.toDouble) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Double, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __BooleanXMLFormat: XMLFormat[Boolean] = new XMLFormat[Boolean] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Boolean] =
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 =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __DurationXMLFormat: XMLFormat[javax.xml.datatype.Duration] = new XMLFormat[javax.xml.datatype.Duration] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, javax.xml.datatype.Duration] =
try { Right(Helper.toDuration(seq.text)) }
catch { case e: Exception => Left(e.toString) }
def writes(obj: javax.xml.datatype.Duration, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __CalendarXMLFormat: XMLFormat[XMLGregorianCalendar] = new XMLFormat[XMLGregorianCalendar] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, XMLGregorianCalendar] = try {
Right(XMLCalendar(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: XMLGregorianCalendar, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toXMLFormat, namespace, elementLabel, scope)
}
implicit lazy val __GregorianCalendarXMLWriter: CanWriteXML[java.util.GregorianCalendar] = new CanWriteXML[java.util.GregorianCalendar] {
def writes(obj: java.util.GregorianCalendar, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(Helper.toCalendar(obj).toXMLFormat, namespace, elementLabel, scope)
}
def qnameXMLFormat(scope: scala.xml.NamespaceBinding) = new XMLFormat[javax.xml.namespace.QName] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, javax.xml.namespace.QName] =
seq match {
case node: scala.xml.Node =>
val (namespace, localPart) = Helper.splitQName(node.text, scope)
Right(new QName(namespace.orNull, localPart))
case _ => Left("scala.xml.Node is required")
}
def writes(obj: javax.xml.namespace.QName, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __QNameXMLFormat: XMLFormat[javax.xml.namespace.QName] = new XMLFormat[javax.xml.namespace.QName] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, javax.xml.namespace.QName] =
seq match {
case node: scala.xml.Node => qnameXMLFormat(node.scope).reads(node, stack)
case _ => Left("scala.xml.Node is required")
}
def writes(obj: javax.xml.namespace.QName, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __Base64BinaryXMLFormat: XMLFormat[Base64Binary] = new XMLFormat[Base64Binary] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Base64Binary] = try {
Right(Base64Binary(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: Base64Binary, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __HexBinaryXMLFormat: XMLFormat[HexBinary] = new XMLFormat[HexBinary] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, HexBinary] = try {
Right(HexBinary(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: HexBinary, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit lazy val __URIXMLFormat: XMLFormat[java.net.URI] = new XMLFormat[java.net.URI] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, java.net.URI] = try {
Right(Helper.toURI(seq.text)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: java.net.URI, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
}
implicit def seqXMLFormat[A: XMLFormat]: XMLFormat[Seq[A]] = new XMLFormat[Seq[A]] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Seq[A]] =
seq match {
case node: scala.xml.Node =>
try {
val xs = Helper.splitBySpace(node.text).toSeq
Right(xs map { x => fromXML[A](scala.xml.Elem(node.prefix, node.label, scala.xml.Null, node.scope, true, scala.xml.Text(x)), stack) })
} catch { case e: Exception => Left(e.toString) }
case _ => Left("Node expected: " + seq.toString)
}
def writes(obj: Seq[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML((obj map { x => scalaxb.toXML(x, namespace, elementLabel, scope, typeAttribute).text }).mkString(" "),
namespace, elementLabel, scope)
}
implicit def dataRecordFormat[A: XMLFormat]: XMLFormat[DataRecord[A]] = new XMLFormat[DataRecord[A]] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, DataRecord[A]] = seq match {
case node: Node =>
try {
Right(DataRecord(Some(node.namespace), Some(node.label), scalaxb.fromXML[A](node)))
} catch { case e: Exception => Left(e.toString) }
case _ => Left("scala.xml.Node is required.")
}
def writes(obj: DataRecord[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
DataRecord.toXML(obj, namespace, elementLabel, scope, typeAttribute)
}
implicit def dataRecordXMLWriter[A]: CanWriteXML[DataRecord[A]] = new CanWriteXML[DataRecord[A]] {
def writes(obj: DataRecord[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
DataRecord.toXML(obj, namespace, elementLabel, scope, typeAttribute)
}
implicit def someXMLWriter[A: CanWriteXML]: CanWriteXML[Some[A]] = new CanWriteXML[Some[A]] {
def writes(obj: Some[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
scalaxb.toXML[A](obj.get, namespace, elementLabel, scope, typeAttribute)
}
implicit def optionXMLWriter[A: CanWriteXML]: CanWriteXML[Option[A]] = new CanWriteXML[Option[A]] {
def writes(obj: Option[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = obj match {
case Some(x) => scalaxb.toXML[A](x, namespace, elementLabel, scope, typeAttribute)
case None => Helper.nilElem(namespace, elementLabel.get, scope)
}
}
implicit lazy val __NoneXMLWriter: CanWriteXML[None.type] = new CanWriteXML[None.type] {
def writes(obj: None.type, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.nilElem(namespace, elementLabel.get, scope)
}
implicit def __DataRecordAnyXMLFormat(implicit handleNonDefault: scala.xml.Elem => Option[DataRecord[Any]] = _ => None): XMLFormat[DataRecord[Any]] = new XMLFormat[DataRecord[Any]] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, DataRecord[Any]] = try {
Right(DataRecord.fromAny(seq, handleNonDefault)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: DataRecord[Any], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
DataRecord.toXML(obj, namespace, elementLabel, scope, typeAttribute)
}
implicit lazy val __DataRecordOptionAnyXMLFormat: XMLFormat[DataRecord[Option[Any]]] =
new XMLFormat[DataRecord[Option[Any]]] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, DataRecord[Option[Any]]] = try {
Right(DataRecord.fromNillableAny(seq)) } catch { case e: Exception => Left(e.toString) }
def writes(obj: DataRecord[Option[Any]], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
DataRecord.toXML(obj, namespace, elementLabel, scope, typeAttribute)
}
implicit lazy val __DataRecordMapWriter: CanWriteXML[Map[String, scalaxb.DataRecord[Any]]] =
new CanWriteXML[Map[String, scalaxb.DataRecord[Any]]] {
def writes(obj: Map[String, scalaxb.DataRecord[Any]], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
obj.valuesIterator.toList flatMap { x =>
scalaxb.toXML[DataRecord[Any]](x, x.namespace, x.key, scope, typeAttribute)
}
}
}
trait DataRecord[+A] {
val namespace: Option[String]
val key: Option[String]
val value: A
def as[B] = value.asInstanceOf[B]
override def toString: String = {
"DataRecord(" +
((namespace, key, value) match {
case (None, Some(k), _) => k + "," + value.toString
case (Some(n), Some(k), _) => "{" + n + "}" + k + "," + value.toString
case _ => value.toString
}) + ")"
}
}
object DataRecord extends XMLStandardTypes {
private case class DataWriter[+A](
namespace: Option[String],
key: Option[String],
xstypeNamespace: Option[String],
xstypeName: Option[String],
value: A,
writer: CanWriteXML[_]) extends DataRecord[A] {
override def equals(o: Any): Boolean =
o match {
case that: DataWriter[_] =>
namespace == that.namespace &&
key == that.key &&
value == that.value
case _ => false
}
override def hashCode: Int = {
var result = 17
result = result + 31 * namespace.hashCode
result = result + 31 * key.hashCode
result = result + 31 * value.hashCode
result
}
}
import Helper._
// this is for nil element.
def apply(namespace: Option[String], key: Option[String], value: None.type): DataRecord[Option[Nothing]] =
DataWriter(namespace, key, None, None, value, __NoneXMLWriter)
// this is for choice option: DataRecord(x.namespace, Some(x.name), fromXML[Address](x))
def apply[A:CanWriteXML](namespace: Option[String], key: Option[String], value: A): DataRecord[A] =
DataWriter(namespace, key, None, None, value, implicitly[CanWriteXML[A]])
def apply[A:CanWriteXML](node: Node, value: A): DataRecord[A] = node match {
case elem: Elem =>
val ns = scalaxb.Helper.nullOrEmpty(elem.scope.getURI(elem.prefix))
val key = Some(elem.label)
DataRecord(ns, key, value)
case _ => DataRecord(value)
}
// this is for long attributes
def apply[A:CanWriteXML](x: Node, parent: Node, value: A): DataRecord[A] = x match {
case _ => DataRecord(value)
}
def apply[A:CanWriteXML](value: A): DataRecord[A] =
apply(None, None, value)
def apply[A:CanWriteXML](namespace: Option[String], key: Option[String],
xstypeNamespace: Option[String], xstypeName: Option[String], value: A): DataRecord[A] =
DataWriter(namespace, key, xstypeNamespace, xstypeName, value, implicitly[CanWriteXML[A]])
// this is for any.
def apply(elemName: ElemName)(implicit handleNonDefault: scala.xml.Elem => Option[DataRecord[Any]]): DataRecord[Any] = fromAny(elemName.node, handleNonDefault)
def fromAny(seq: NodeSeq, handleNonDefault: scala.xml.Elem => Option[DataRecord[Any]]): DataRecord[Any] = {
seq match {
case elem: Elem => fromAny(elem, handleNonDefault)
case _ => DataRecord(None, None, None, None, seq.text)
}
}
def fromAny(elem: Elem, handleNonDefault: scala.xml.Elem => Option[DataRecord[Any]]): DataRecord[Any] = {
val ns = scalaxb.Helper.nullOrEmpty(elem.scope.getURI(elem.prefix))
val key = Some(elem.label)
val XS = Some(XML_SCHEMA_URI)
instanceType(elem) match {
case (XS, xstype) =>
xstype match {
case Some("int") => DataRecord(ns, key, XS, xstype, fromXML[Int](elem, Nil))
case Some("byte") => DataRecord(ns, key, XS, xstype, fromXML[Byte](elem, Nil))
case Some("short") => DataRecord(ns, key, XS, xstype, fromXML[Short](elem, Nil))
case Some("long") => DataRecord(ns, key, XS, xstype, fromXML[Long](elem, Nil))
case Some("float") => DataRecord(ns, key, XS, xstype, fromXML[Float](elem, Nil))
case Some("double") => DataRecord(ns, key, XS, xstype, fromXML[Double](elem, Nil))
case Some("integer") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("nonPositiveInteger") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("negativeInteger") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("nonNegativeInteger") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("positiveInteger") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("unsignedLong") => DataRecord(ns, key, XS, xstype, fromXML[BigInt](elem, Nil))
case Some("unsignedInt") => DataRecord(ns, key, XS, xstype, fromXML[Long](elem, Nil))
case Some("unsignedShort") => DataRecord(ns, key, XS, xstype, fromXML[Int](elem, Nil))
case Some("unsignedByte") => DataRecord(ns, key, XS, xstype, fromXML[Int](elem, Nil))
case Some("decimal") => DataRecord(ns, key, XS, xstype, fromXML[BigDecimal](elem, Nil))
case Some("boolean") => DataRecord(ns, key, XS, xstype, fromXML[Boolean](elem, Nil))
case Some("string") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("normalizedString") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("token") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("language") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("Name") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("NCName") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("NMTOKEN") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("NMTOKENS") => DataRecord(ns, key, XS, xstype, fromXML[Seq[String]](elem, Nil))
case Some("ID") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("IDREF") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("IDREFS") => DataRecord(ns, key, XS, xstype, fromXML[Seq[String]](elem, Nil))
case Some("ENTITY") => DataRecord(ns, key, XS, xstype, fromXML[String](elem, Nil))
case Some("ENTITIES") => DataRecord(ns, key, XS, xstype, fromXML[Seq[String]](elem, Nil))
case Some("hexBinary") => DataRecord(ns, key, XS, xstype, fromXML[HexBinary](elem, Nil))
case Some("base64Binary") => DataRecord(ns, key, XS, xstype, fromXML[Base64Binary](elem, Nil))
case Some("anyURI") => DataRecord(ns, key, XS, xstype, fromXML[java.net.URI](elem, Nil))
case Some("QName") => DataRecord(ns, key, XS, xstype, fromXML[javax.xml.namespace.QName](elem, Nil))
case Some("NOTATION") => DataRecord(ns, key, XS, xstype, fromXML[javax.xml.namespace.QName](elem, Nil))
case Some("duration") => DataRecord(ns, key, XS, xstype, fromXML[javax.xml.datatype.Duration](elem, Nil))
case Some("dateTime") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("time") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("gYearMonth") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("gYear") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("gMonthDay") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("gDay") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case Some("gMonth") => DataRecord(ns, key, XS, xstype, fromXML[XMLGregorianCalendar](elem, Nil))
case _ => DataRecord(ns, key, XS, xstype, elem)
}
case _ => handleNonDefault(elem).getOrElse {
val (xsns, xstype) = instanceType(elem)
DataRecord(ns, key, xsns, xstype, elem)
}
}
}
// this is for any.
def fromNillableAny(seq: NodeSeq): DataRecord[Option[Any]] = {
seq match {
case elem: Elem => fromNillableAny(elem)
case _ => DataRecord(None, None, None, None, Some(seq.text))
}
}
// this is for any.
def fromNillableAny(elem: Elem): DataRecord[Option[Any]] = {
val ns = scalaxb.Helper.nullOrEmpty(elem.scope.getURI(elem.prefix))
val key = Some(elem.label)
val XS = Some(XML_SCHEMA_URI)
if (isNil(elem)) DataRecord(ns, key, None)
else instanceType(elem) match {
case (XS, xstype) =>
xstype match {
case Some("int") => DataRecord(ns, key, XS, xstype, Some(fromXML[Int](elem, Nil)))
case Some("byte") => DataRecord(ns, key, XS, xstype, Some(fromXML[Byte](elem, Nil)))
case Some("short") => DataRecord(ns, key, XS, xstype, Some(fromXML[Short](elem, Nil)))
case Some("long") => DataRecord(ns, key, XS, xstype, Some(fromXML[Long](elem, Nil)))
case Some("float") => DataRecord(ns, key, XS, xstype, Some(fromXML[Float](elem, Nil)))
case Some("double") => DataRecord(ns, key, XS, xstype, Some(fromXML[Double](elem, Nil)))
case Some("integer") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("nonPositiveInteger") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("negativeInteger") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("nonNegativeInteger") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("positiveInteger") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("unsignedLong") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigInt](elem, Nil)))
case Some("unsignedInt") => DataRecord(ns, key, XS, xstype, Some(fromXML[Long](elem, Nil)))
case Some("unsignedShort") => DataRecord(ns, key, XS, xstype, Some(fromXML[Int](elem, Nil)))
case Some("unsignedByte") => DataRecord(ns, key, XS, xstype, Some(fromXML[Int](elem, Nil)))
case Some("decimal") => DataRecord(ns, key, XS, xstype, Some(fromXML[BigDecimal](elem, Nil)))
case Some("boolean") => DataRecord(ns, key, XS, xstype, Some(fromXML[Boolean](elem, Nil)))
case Some("string") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("normalizedString") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("token") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("language") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("Name") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("NCName") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("NMTOKEN") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("NMTOKENS") => DataRecord(ns, key, XS, xstype, Some(fromXML[Seq[String]](elem, Nil)))
case Some("ID") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("IDREF") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("IDREFS") => DataRecord(ns, key, XS, xstype, Some(fromXML[Seq[String]](elem, Nil)))
case Some("ENTITY") => DataRecord(ns, key, XS, xstype, Some(fromXML[String](elem, Nil)))
case Some("ENTITIES") => DataRecord(ns, key, XS, xstype, Some(fromXML[Seq[String]](elem, Nil)))
case Some("hexBinary") => DataRecord(ns, key, XS, xstype, Some(fromXML[HexBinary](elem, Nil)))
case Some("base64Binary") => DataRecord(ns, key, XS, xstype, Some(fromXML[Base64Binary](elem, Nil)))
case Some("anyURI") => DataRecord(ns, key, XS, xstype, Some(fromXML[java.net.URI](elem, Nil)))
case Some("QName") => DataRecord(ns, key, XS, xstype, Some(fromXML[javax.xml.namespace.QName](elem, Nil)))
case Some("NOTATION") => DataRecord(ns, key, XS, xstype, Some(fromXML[javax.xml.namespace.QName](elem, Nil)))
case Some("duration") => DataRecord(ns, key, XS, xstype, Some(fromXML[javax.xml.datatype.Duration](elem, Nil)))
case Some("dateTime") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("time") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("gYearMonth") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("gYear") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("gMonthDay") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("gDay") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case Some("gMonth") => DataRecord(ns, key, XS, xstype, Some(fromXML[XMLGregorianCalendar](elem, Nil)))
case _ => DataRecord(ns, key, XS, xstype, Some(elem))
}
case _ =>
val (xsns, xstype) = instanceType(elem)
DataRecord(ns, key, xsns, xstype, Some(elem))
}
}
def unapply[A](record: DataRecord[A]): Option[(Option[String], Option[String], A)] =
Some((record.namespace, record.key, record.value))
def toXML[A](obj: DataRecord[A], namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq = obj match {
case w: DataWriter[_] =>
obj.value match {
case seq: NodeSeq =>
w.writer.asInstanceOf[CanWriteXML[A]].writes(obj.value, namespace, elementLabel, scope, typeAttribute)
case _ =>
w.writer.asInstanceOf[CanWriteXML[A]].writes(obj.value, namespace, elementLabel, scope, false) match {
case elem: Elem if (w.xstypeName.isDefined && scope.getPrefix(XSI_URL) != null) =>
elem % scala.xml.Attribute(scope.getPrefix(Helper.XSI_URL), "type",
Helper.prefixedName(w.xstypeNamespace, w.xstypeName.get, scope), scala.xml.Null)
case x => x
}
}
case _ => sys.error("unknown DataRecord.")
}
}
case class ElemName(namespace: Option[String], name: String) {
var node: scala.xml.Node = _
def text = node.text
def nil = Helper.isNil(node)
def nilOption: Option[ElemName] = if (nil) None else Some(this)
def splitBySpace = Helper.splitBySpace(text)
override def toString = namespace match {
case Some(x) => "{%s}%s".format(x, name)
case _ => name
}
}
object ElemName {
implicit def apply(node: scala.xml.Node): ElemName = node match {
case x: scala.xml.Elem =>
val elemName = ElemName(scalaxb.Helper.nullOrEmpty(x.scope.getURI(x.prefix)), x.label)
elemName.node = x
elemName
case _ =>
val elemName = ElemName(None, "")
elemName.node = node
elemName
}
implicit def toNodeSeq(elem: ElemName): scala.xml.NodeSeq = elem.node
}
trait AnyElemNameParser extends scala.util.parsing.combinator.Parsers {
import scala.collection.mutable.ListBuffer
import scala.annotation.tailrec
type Elem = ElemName
implicit class ReaderExt(reader: scala.util.parsing.input.Reader[ElemName]) {
def erased(from: Int, to: Int): scala.util.parsing.input.Reader[ElemName] = {
reader match {
case r: ElemNameSeqReader =>
new ElemNameSeqReader(r.seq.take(from) ++ r.seq.drop(to))
case other =>
throw new UnsupportedOperationException("Incompatible reader")
}
}
}
implicit def parserViewToParserExt[T, P](current: P)(implicit ev: P => Parser[T]): ParserExt[T, P] =
new ParserExt[T, P](current, ev)
implicit def parserToParserExt[T](current: Parser[T]): ParserExt[T, Parser[T]] =
new ParserExt[T, Parser[T]](current, identity)
class ParserExt[+T, P](current: P, ev0: P => Parser[T]) {
implicit val ev: P => Parser[T] = ev0
private def parseIterable[U](source: Input, in: Input, p: Parser[U], res: ParseResult[U]): ParseResult[U] = {
res match {
case s@Success(v: Option[_], n) if v.isEmpty =>
if (!n.atEnd) parseIterable(source, in.rest, p, p(in.rest)) else s.copy(next = source)
case s@Success(v: Iterable[_], n) if v.isEmpty =>
if (!n.atEnd) parseIterable(source, in.rest, p, p(in.rest)) else s.copy(next = source)
case s@Success(v, n) =>
s.copy(next = n.erased(in.pos.column - 1, n.pos.column - 1))
case other =>
other
}
}
private def lookupSuccess[U](p: Parser[U], input: Input): ParseResult[U] = p(input) match {
case s@Success(v, next) =>
parseIterable(input, input, p, s)
case n@NoSuccess(b, next) =>
if (next.atEnd) n
else lookupSuccess(p, input.rest)
}
def ~|~[U](nextParser: => Parser[U]): Parser[~|~[T, U]] =
Parser {
in =>
lookupSuccess(current, in) match {
case s@Success(currentResult, afterFirstInput) =>
lookupSuccess(nextParser, afterFirstInput) match {
case qs@Success(nextResult, afterSecondInput) =>
Success(new ~|~(currentResult, nextResult), afterSecondInput)
case n: NoSuccess => n
}
case n: NoSuccess => n
}
}
}
case class ~|~[+A, +B](a : A, b : B) {
override def toString() = s"$a ~|~ $b"
}
// we need this so treat ElemName as NodeSeq for fromXML etc.
implicit def toNodeSeq(elem: Elem): scala.xml.NodeSeq = elem.node
def optPhrase[U](p: Parser[U]): Parser[U] = phrase(p ~|~ safeRep(any(_ => true)) ^^ {case p1 ~|~ p2 => p1})
def any(f: ElemName => Boolean): Parser[ElemName] =
accept("any", { case x: ElemName if x.name != "" && f(x) => x })
def optTextRecord(implicit format: XMLFormat[String]): Parser[Option[DataRecord[Any]]] =
opt(text ^^ (x => DataRecord(x.node.text)(format)))
def text: Parser[ElemName] =
accept("text", { case x: ElemName if x.name == "" => x })
def safeRep[T](p: => Parser[T]): Parser[List[T]] = safeRep1(p) | success(List())
def safeRep1[T](first: => Parser[T], p0: => Parser[T]): Parser[List[T]] = Parser { in =>
lazy val p = p0 // lazy argument
val elems = new ListBuffer[T]
def continue(in: Input): ParseResult[List[T]] = {
val p0 = p // avoid repeatedly re-evaluating by-name parser
@tailrec def applyp(in0: Input): ParseResult[List[T]] = p0(in0) match {
case Success(x, rest) =>
if (!(in0.pos < rest.pos) || in0.atEnd) Success(elems.toList, in0)
else {
elems += x
applyp(rest)
}
case e @ Error(_, _) => e // still have to propagate error
case _ => Success(elems.toList, in0)
}
applyp(in)
}
first(in) match {
case Success(x, rest) =>
elems += x
continue(rest)
case ns: NoSuccess => ns
}
}
def safeRep1[T](p: => Parser[T]): Parser[List[T]] = safeRep1(p, p)
}
trait CanWriteChildNodes[A] extends CanWriteXML[A] {
def targetNamespace: Option[String]
def typeName: Option[String] = None
def writesAttribute(obj: A, scope: scala.xml.NamespaceBinding): scala.xml.MetaData = scala.xml.Null
def writesChildNodes(obj: A, scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node]
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.") },
writesAttribute(obj, scope),
scope, true,
writesChildNodes(obj, scope): _*)
if (typeAttribute && typeName.isDefined && scope.getPrefix(Helper.XSI_URL) != null)
elem % scala.xml.Attribute(scope.getPrefix(Helper.XSI_URL), "type",
Helper.prefixedName(targetNamespace, typeName.get, scope), scala.xml.Null)
else elem
}
}
trait AttributeGroupFormat[A] extends scalaxb.XMLFormat[A] {
def writes(__obj: A, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = sys.error("don't call me.")
def toAttribute(__obj: A, __attr: scala.xml.MetaData, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData
}
trait ElemNameParser[A] extends AnyElemNameParser with XMLFormat[A] with CanWriteChildNodes[A] {
def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, A] = seq match {
case node: scala.xml.Node =>
parse(parser(node, stack), node.child) match {
case x: Success[_] => Right(x.get)
case x: Failure => Left(parserErrorMsg(x.msg, x.next, ElemName(node) :: stack))
case x: Error => Left(parserErrorMsg(x.msg, node))
}
case _ => Left("seq must be scala.xml.Node")
}
private def parserErrorMsg(msg: String, next: scala.util.parsing.input.Reader[Elem], stack: List[ElemName]): String =
if (msg contains "paser error ") msg
else "parser error \"" + msg + "\" while parsing " + stack.reverse.mkString("/", "/", "/") + next.pos.longString
private def parserErrorMsg(msg: String, node: scala.xml.Node): String =
if (msg contains "paser error ") msg
else "parser error \"" + msg + "\" while parsing " + node.toString
def parser(node: scala.xml.Node, stack: List[ElemName]): Parser[A]
def isMixed: Boolean = false
def parse[B](p: Parser[B], in: Seq[scala.xml.Node]): ParseResult[B] =
p(new ElemNameSeqReader(elementNames(in)))
def elementNames(in: Seq[scala.xml.Node]): Seq[ElemName] =
if (isMixed) in map { x => ElemName(x) }
else in collect { case x: scala.xml.Elem => ElemName(x) }
}
class ElemNameSeqReader(val seq: Seq[ElemName],
override val offset: Int) extends scala.util.parsing.input.Reader[ElemName] {
import scala.util.parsing.input._
def this(seq: Seq[ElemName]) = this(seq, 0)
override def first: ElemName =
if (seq.isDefinedAt(offset)) seq(offset)
else null
def rest: ElemNameSeqReader =
if (seq.isDefinedAt(offset)) new ElemNameSeqReader(seq, offset + 1)
else this
def pos: Position = new ElemNameSeqPosition(seq, offset)
def atEnd = !seq.isDefinedAt(offset)
override def drop(n: Int): ElemNameSeqReader =
new ElemNameSeqReader(seq, offset + n)
}
class ElemNameSeqPosition(val source: Seq[ElemName], val offset: Int) extends
scala.util.parsing.input.Position {
protected def lineContents =
source.mkString
override def line = 1
override def column = offset + 1
}
class HexBinary(_vector: Vector[Byte]) extends scala.collection.IndexedSeq[Byte] {
val vector = _vector
def length = vector.length
def apply(idx: Int): Byte = vector(idx)
override def toString: String = DatatypeConverter.printHexBinary(vector.toArray)
}
object HexBinary {
def apply(xs: Byte*): HexBinary = {
import scala.collection.breakOut
val vector: Vector[Byte] = (xs.toIndexedSeq map {x: Byte => x})(breakOut)
new HexBinary(vector)
}
def apply(value: String): HexBinary = {
val array = DatatypeConverter.parseHexBinary(value)
apply(array: _*)
}
def unapplySeq(x: HexBinary) = Some(x.vector)
}
class Base64Binary(_vector: Vector[Byte]) extends scala.collection.IndexedSeq[Byte] {
val vector = _vector
def length = vector.length
def apply(idx: Int): Byte = vector(idx)
override def toString: String = DatatypeConverter.printBase64Binary(vector.toArray)
}
object Base64Binary {
def apply(xs: Byte*): Base64Binary = {
import scala.collection.breakOut
val vector: Vector[Byte] = (xs.toIndexedSeq map {x: Byte => x})(breakOut)
new Base64Binary(vector)
}
def apply(value: String): Base64Binary = {
val array = DatatypeConverter.parseBase64Binary(value)
apply(array: _*)
}
def unapplySeq(x: Base64Binary) = Some(x.vector)
}
object XMLCalendar {
def apply(value: String): XMLGregorianCalendar = Helper.toCalendar(value)
def unapply(value: XMLGregorianCalendar): Option[String] = Some(value.toXMLFormat)
}
object DataTypeFactory extends ThreadLocal[javax.xml.datatype.DatatypeFactory] {
override def initialValue() = javax.xml.datatype.DatatypeFactory.newInstance()
}
object Helper {
val XML_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema"
val XSI_URL = "http://www.w3.org/2001/XMLSchema-instance"
val XSI_PREFIX = "xsi"
def toString(value: QName, scope: NamespaceBinding): String =
Option[String](scope.getPrefix(value.getNamespaceURI)) map {
"%s:%s" format (_, value.getLocalPart)} getOrElse {value.getLocalPart}
def toCalendar(value: String): XMLGregorianCalendar = {
DataTypeFactory.get().newXMLGregorianCalendar(value)
}
def toCalendar(value: java.util.GregorianCalendar): XMLGregorianCalendar = {
import javax.xml.datatype._
import java.util.{GregorianCalendar, Calendar => JCalendar}
val xmlGregorian = DataTypeFactory.get().newXMLGregorianCalendar()
if (value.getTimeZone != null) {
xmlGregorian.setTimezone(value.getTimeZone.getRawOffset / 60000)
}
if (value.isSet(JCalendar.YEAR)) xmlGregorian.setYear(if (value.get(JCalendar.ERA) == GregorianCalendar.AD) value.get(JCalendar.YEAR) else -value.get(JCalendar.YEAR))
if (value.isSet(JCalendar.MONTH)) xmlGregorian.setMonth(value.get(JCalendar.MONTH) - JCalendar.JANUARY + DatatypeConstants.JANUARY)
if (value.isSet(JCalendar.DAY_OF_MONTH)) xmlGregorian.setDay(value.get(JCalendar.DAY_OF_MONTH))
if (value.isSet(JCalendar.HOUR_OF_DAY)) xmlGregorian.setHour(value.get(JCalendar.HOUR_OF_DAY))
if (value.isSet(JCalendar.MINUTE)) xmlGregorian.setMinute(value.get(JCalendar.MINUTE))
if (value.isSet(JCalendar.SECOND)) xmlGregorian.setSecond(value.get(JCalendar.SECOND))
if (value.isSet(JCalendar.MILLISECOND) && value.get(JCalendar.MILLISECOND) > 0) xmlGregorian.setFractionalSecond(new java.math.BigDecimal(value.get(JCalendar.MILLISECOND)))
xmlGregorian
}
def toDuration(value: String) = {
DataTypeFactory.get().newDuration(value)
}
def toURI(value: String) =
java.net.URI.create(value.trim)
def isNil(node: scala.xml.Node) =
(node \ ("@{" + XSI_URL + "}nil")).headOption map { case x => x.text == "true" || x.text == "1" } getOrElse {
false
}
def nilElem(namespace: Option[String], elementLabel: String,
scope: scala.xml.NamespaceBinding) =
scala.xml.Elem(getPrefix(namespace, scope).orNull, elementLabel,
scala.xml.Attribute(scope.getPrefix(XSI_URL), "nil", "true", scala.xml.Null),
scope, true)
def splitBySpace(text: String) = text.split(' ').filter(_ != "")
def instanceType(node: scala.xml.Node): (Option[String], Option[String]) = {
val typeName = (node \ ("@{" + XSI_URL + "}type")).text
val prefix = if (typeName.contains(':')) Some(typeName.dropRight(typeName.length - typeName.indexOf(':')))
else None
val namespace = scalaxb.Helper.nullOrEmpty(node.scope.getURI(prefix.orNull))
val value = if (typeName.contains(':')) typeName.drop(typeName.indexOf(':') + 1)
else typeName
(namespace, if (value == "") None else Some(value))
}
def splitQName(value: String, scope: scala.xml.NamespaceBinding): (Option[String], String) =
if (value startsWith "{") {
val qname = javax.xml.namespace.QName.valueOf(value)
(nullOrEmpty(qname.getNamespaceURI), qname.getLocalPart)
}
else if (value contains ':') {
val prefix = value.dropRight(value.length - value.indexOf(':'))
val localPart = value.drop(value.indexOf(':') + 1)
(nullOrEmpty(scope.getURI(prefix)), localPart)
}
else (nullOrEmpty(scope.getURI(null)), value)
def nullOrEmpty(value: String): Option[String] =
value match {
case null | "" => None
case x => Some(x)
}
def getPrefix(namespace: Option[String], scope: scala.xml.NamespaceBinding) =
if (nullOrEmpty(scope.getURI(null)) == namespace) None
else nullOrEmpty(scope.getPrefix(namespace.orNull))
def prefixedName(namespace: Option[String], name: String, scope: scala.xml.NamespaceBinding) =
getPrefix(namespace, scope) map { """%s:%s""" format(_, name)
} getOrElse {name}
def stringToXML(obj: String, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding): scala.xml.NodeSeq = {
elementLabel map { label =>
scala.xml.Elem(getPrefix(namespace, scope).orNull, label,
scala.xml.Null,
scope, true, scala.xml.Text(obj.toString))
} getOrElse { scala.xml.Text(obj) }
}
// assume outer scope
def mergeNodeSeqScope(nodeseq: NodeSeq, outer: NamespaceBinding): NodeSeq =
nodeseq.toSeq flatMap { mergeNodeScope(_, outer) }
// assume outer scope
def mergeNodeScope(node: Node, outer: NamespaceBinding): Node =
node match {
case elem: Elem =>
withInnerScope(elem.scope, outer) { (innerScope, mapping) =>
val newPrefix: String = mapping.get(scalaxb.Helper.nullOrEmpty(elem.prefix)) map {_.orNull} getOrElse {elem.prefix}
val newChild = mergeNodeSeqScope(mergeNodeSeqScope(elem.child, outer), innerScope)
elem.copy(scope = innerScope, prefix = newPrefix, child = newChild)
}
case _ => node
}
def withInnerScope[A](scope: NamespaceBinding, outer: NamespaceBinding)
(f: (NamespaceBinding, Map[Option[String], Option[String]]) => A): A = {
val outerList = fromScope(outer)
def renamePrefix(prefix: Option[String], n: Int): Option[String] =
if (outerList exists { case (p, n) => p == Some((prefix getOrElse {"ns"}) + n.toString)}) renamePrefix(prefix, n + 1)
else Some((prefix getOrElse {"ns"}) + n.toString)
val xs: List[((Option[String], String), (Option[String], Option[String]))] = fromScope(scope) flatMap {
case (prefix, ns) if outerList contains (prefix -> ns) => None
case (prefix, ns) if outerList exists { case (p, n) => p == prefix && p.isDefined } =>
val renamed = renamePrefix(prefix, 2)
Some((renamed -> ns, prefix -> renamed))
case (prefix, ns) => Some((prefix -> ns, prefix -> prefix))
}
f(toScope(xs map {_._1}: _*), Map(xs map {_._2}: _*))
}
def resolveSoap11Refs(node: Node): Node = {
import scala.xml.transform._
def lookupRef(id: String): Seq[Node] =
node.child flatMap {
case elem: Elem if (elem \ "@id").text == id =>
if ((elem \ "@{http://schemas.xmlsoap.org/soap/encoding/}root").text == "1") elem
else elem.child.toSeq
case _ => Nil
}
val rule = new RewriteRule {
override def transform(n: Node): Seq[Node] = n match {
case x@Elem(prefix, label, attr, scope, _*) if attr exists(p => p.key == "href") =>
Elem(prefix, label, attr remove("href"), scope, true, lookupRef((x \ "@href").text.tail): _*)
case x@Elem(prefix, label, attr, scope, _*) if attr exists(p => p.key == "id") =>
Nil
case other => other
}
}
val rt = new RuleTransformer(rule)
var retval: Node = node
while (retval != rt(retval)) {
retval = rt(retval)
} // while
retval
}
}
class ParserFailure(message: String) extends RuntimeException(message)
// Generated by <a href="http://scalaxb.org/">scalaxb</a>.
case class Ad(adoption: Option[scalaxb.DataRecord[AdOption]] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val sequence = attributes.get("@sequence") map { _.as[BigInt]}
lazy val conditionalAd = attributes.get("@conditionalAd") map { _.as[Boolean]}
}
trait AdOption
case class VAST(vastoption: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val version = attributes("@version").as[String]
}
trait VASTOption
/** URLs to ping when icon action occurs.
*/
case class IconTrackingUri_type(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
trait Event
object Event {
def fromString(value: String, scope: scala.xml.NamespaceBinding)(implicit fmt: scalaxb.XMLFormat[Event]): Event = fmt.reads(scala.xml.Text(value), Nil) match {
case Right(x: Event) => x
case x => throw new RuntimeException(s"fromString returned unexpected value $x for input $value")
}
}
case object Mute extends Event { override def toString = "mute" }
case object Unmute extends Event { override def toString = "unmute" }
case object Pause extends Event { override def toString = "pause" }
case object Resume extends Event { override def toString = "resume" }
case object Rewind extends Event { override def toString = "rewind" }
case object Skip extends Event { override def toString = "skip" }
case object PlayerExpand extends Event { override def toString = "playerExpand" }
case object PlayerCollapse extends Event { override def toString = "playerCollapse" }
case object Start extends Event { override def toString = "start" }
case object FirstQuartile extends Event { override def toString = "firstQuartile" }
case object Midpoint extends Event { override def toString = "midpoint" }
case object ThirdQuartile extends Event { override def toString = "thirdQuartile" }
case object Complete extends Event { override def toString = "complete" }
case object AcceptInvitationLinear extends Event { override def toString = "acceptInvitationLinear" }
case object TimeSpentViewing extends Event { override def toString = "timeSpentViewing" }
case object Progress extends Event { override def toString = "progress" }
case object CreativeView extends Event { override def toString = "creativeView" }
case object AcceptInvitation extends Event { override def toString = "acceptInvitation" }
case object AdExpand extends Event { override def toString = "adExpand" }
case object AdCollapse extends Event { override def toString = "adCollapse" }
case object Minimize extends Event { override def toString = "minimize" }
case object Close extends Event { override def toString = "close" }
case object OverlayViewDuration extends Event { override def toString = "overlayViewDuration" }
case object OtherAdInteraction extends Event { override def toString = "otherAdInteraction" }
case class Tracking(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val event = attributes("@event").as[Event]
lazy val offset = attributes.get("@offset") map { _.as[String]}
}
case class TrackingEvents_type(Tracking: Seq[Tracking] = Nil)
case class ClickTracking(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
case class CustomClick(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
trait VideoClicks_Base_typable {
def ClickTracking: Seq[ClickTracking]
def CustomClick: Seq[CustomClick]
}
case class VideoClicks_Base_type(ClickTracking: Seq[ClickTracking] = Nil,
CustomClick: Seq[CustomClick] = Nil) extends VideoClicks_Base_typable
case class ClickThrough(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
case class VideoClicks_InlineChild_type(ClickTracking: Seq[ClickTracking] = Nil,
CustomClick: Seq[CustomClick] = Nil,
ClickThrough: Option[ClickThrough] = None) extends VideoClicks_Base_typable
case class Impression_type(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
case class StaticResource(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val creativeType = attributes("@creativeType").as[String]
}
/**
A base creative resource type (sec 3.13) for non-video creative content.
This specifies static, IFrame, or HTML content, or a combination thereof
*/
trait CreativeResource_NonVideo_typable {
def HTMLResource: Seq[HTMLResource_type]
def IFrameResource: Seq[java.net.URI]
def StaticResource: Seq[StaticResource]
}
/**
A base creative resource type (sec 3.13) for non-video creative content.
This specifies static, IFrame, or HTML content, or a combination thereof
*/
case class CreativeResource_NonVideo_type(HTMLResource: Seq[HTMLResource_type] = Nil,
IFrameResource: Seq[java.net.URI] = Nil,
StaticResource: Seq[StaticResource] = Nil) extends CreativeResource_NonVideo_typable
case class IconClicks(IconClickThrough: Option[java.net.URI] = None,
IconClickTracking: Seq[IconTrackingUri_type] = Nil)
case class Icon_type(HTMLResource: Seq[HTMLResource_type] = Nil,
IFrameResource: Seq[java.net.URI] = Nil,
StaticResource: Seq[StaticResource] = Nil,
IconClicks: Option[IconClicks] = None,
IconViewTracking: Seq[java.net.URI] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends CreativeResource_NonVideo_typable {
lazy val program = attributes.get("@program") map { _.as[String]}
lazy val width = attributes.get("@width") map { _.as[BigInt]}
lazy val height = attributes.get("@height") map { _.as[BigInt]}
lazy val xPosition = attributes.get("@xPosition") map { _.as[String]}
lazy val yPosition = attributes.get("@yPosition") map { _.as[String]}
lazy val duration = attributes.get("@duration") map { _.as[javax.xml.datatype.XMLGregorianCalendar]}
lazy val offset = attributes.get("@offset") map { _.as[javax.xml.datatype.XMLGregorianCalendar]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
lazy val pxratio = attributes.get("@pxratio") map { _.as[BigDecimal]}
}
case class CreativeExtension(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val typeValue = attributes.get("@type") map { _.as[String]}
}
case class CreativeExtensions_type(CreativeExtension: Seq[CreativeExtension] = Nil)
case class AdParameters_type(value: String,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val xmlEncoded = attributes.get("@xmlEncoded") map { _.as[Boolean]}
}
/**
The URI to a static creative file to be used for the ad component identified in the parent
element, which is either: <NonLinear>, <Companion>, or <Icon>.
*/
case class HTMLResource_type(value: String)
case class Icons(Icon: Option[Icon_type] = None)
trait IconsAll
/** Video formatted ad that plays linearly
*/
trait Linear_Base_typable {
def Icons: Option[Icons]
def TrackingEvents: Option[TrackingEvents_type]
def skipoffset: Option[String]
}
/** Video formatted ad that plays linearly
*/
case class Linear_Base_type(Icons: Option[Icons] = None,
TrackingEvents: Option[TrackingEvents_type] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Linear_Base_typable {
lazy val skipoffset = attributes.get("@skipoffset") map { _.as[String]}
}
/** Video formatted ad that plays linearly
*/
case class Linear_WrapperChild_type(Icons: Option[Icons] = None,
TrackingEvents: Option[TrackingEvents_type] = None,
VideoClicks: Option[VideoClicks_Base_typable] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Linear_Base_typable {
lazy val skipoffset = attributes.get("@skipoffset") map { _.as[String]}
}
trait Delivery
object Delivery {
def fromString(value: String, scope: scala.xml.NamespaceBinding)(implicit fmt: scalaxb.XMLFormat[Delivery]): Delivery = fmt.reads(scala.xml.Text(value), Nil) match {
case Right(x: Delivery) => x
case x => throw new RuntimeException(s"fromString returned unexpected value $x for input $value")
}
}
case object Streaming extends Delivery { override def toString = "streaming" }
case object Progressive extends Delivery { override def toString = "progressive" }
case class MediaFile(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val delivery = attributes("@delivery").as[Delivery]
lazy val typeValue = attributes("@type").as[String]
lazy val width = attributes("@width").as[BigInt]
lazy val height = attributes("@height").as[BigInt]
lazy val codec = attributes.get("@codec") map { _.as[String]}
lazy val bitrate = attributes.get("@bitrate") map { _.as[BigInt]}
lazy val minBitrate = attributes.get("@minBitrate") map { _.as[BigInt]}
lazy val maxBitrate = attributes.get("@maxBitrate") map { _.as[BigInt]}
lazy val scalable = attributes.get("@scalable") map { _.as[Boolean]}
lazy val maintainAspectRatio = attributes.get("@maintainAspectRatio") map { _.as[Boolean]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
}
case class InteractiveCreativeFile(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val typeValue = attributes.get("@type") map { _.as[String]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
}
case class MediaFiles(MediaFile: Seq[MediaFile] = Nil,
Mezzanine: Option[java.net.URI] = None,
InteractiveCreativeFile: Seq[InteractiveCreativeFile] = Nil)
/** Video formatted ad that plays linearly
*/
case class Linear_InlineChild_type(Icons: Option[Icons] = None,
TrackingEvents: Option[TrackingEvents_type] = None,
AdParameters: Option[AdParameters_type] = None,
Duration: javax.xml.datatype.XMLGregorianCalendar,
MediaFiles: MediaFiles,
VideoClicks: Option[VideoClicks_InlineChild_type] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Linear_Base_typable {
lazy val skipoffset = attributes.get("@skipoffset") map { _.as[String]}
}
case class NonLinearClickTracking(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
/** An ad that is overlain on top of video content during playback
*/
case class NonLinearAd_Base_type(NonLinearClickTracking: Option[NonLinearClickTracking] = None)
trait NonLinearAd_Base_typeAll
case class NonLinearClickTracking2(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
/** An ad that is overlain on top of video content during playback
*/
case class NonLinearAd_InlineChild_type(HTMLResource: Seq[HTMLResource_type] = Nil,
IFrameResource: Seq[java.net.URI] = Nil,
StaticResource: Seq[StaticResource] = Nil,
AdParameters: Option[AdParameters_type] = None,
NonLinearClickThrough: Option[java.net.URI] = None,
NonLinearClickTracking: Seq[NonLinearClickTracking2] = Nil) extends CreativeResource_NonVideo_typable
case class CompanionClickTracking(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes("@id").as[String]
}
case class CompanionAd_type(HTMLResource: Seq[HTMLResource_type] = Nil,
IFrameResource: Seq[java.net.URI] = Nil,
StaticResource: Seq[StaticResource] = Nil,
AdParameters: Option[AdParameters_type] = None,
AltText: Option[String] = None,
CompanionClickThrough: Option[java.net.URI] = None,
CompanionClickTracking: Seq[CompanionClickTracking] = Nil,
CreativeExtensions: Option[CreativeExtensions_type] = None,
TrackingEvents: Option[TrackingEvents_type] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends CreativeResource_NonVideo_typable {
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val width = attributes("@width").as[BigInt]
lazy val height = attributes("@height").as[BigInt]
lazy val assetWidth = attributes.get("@assetWidth") map { _.as[BigInt]}
lazy val assetHeight = attributes.get("@assetHeight") map { _.as[BigInt]}
lazy val expandedWidth = attributes.get("@expandedWidth") map { _.as[BigInt]}
lazy val expandedHeight = attributes.get("@expandedHeight") map { _.as[BigInt]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
lazy val adSlotID = attributes.get("@adSlotID") map { _.as[String]}
lazy val pxratio = attributes.get("@pxratio") map { _.as[BigDecimal]}
}
trait Required
object Required {
def fromString(value: String, scope: scala.xml.NamespaceBinding)(implicit fmt: scalaxb.XMLFormat[Required]): Required = fmt.reads(scala.xml.Text(value), Nil) match {
case Right(x: Required) => x
case x => throw new RuntimeException(s"fromString returned unexpected value $x for input $value")
}
}
case object AllType extends Required { override def toString = "all" }
case object AnyType extends Required { override def toString = "any" }
case object NoneType extends Required { override def toString = "none" }
case class CompanionAds_Collection_type(Companion: Seq[CompanionAd_type] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val required = attributes.get("@required") map { _.as[Required]}
}
trait Creative_Base_typable {
def sequence: Option[BigInt]
def apiFramework: Option[String]
def id: Option[String]
def adId: Option[String]
}
case class Creative_Base_type(attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Creative_Base_typable {
lazy val sequence = attributes.get("@sequence") map { _.as[BigInt]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val adId = attributes.get("@adId") map { _.as[String]}
}
case class NonLinearAds(TrackingEvents: Option[TrackingEvents_type] = None,
NonLinear: Seq[NonLinearAd_Base_type] = Nil)
case class Creative_WrapperChild_type(CompanionAds: Option[CompanionAds_Collection_type] = None,
Linear: Option[Linear_WrapperChild_type] = None,
NonLinearAds: Option[NonLinearAds] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Creative_Base_typable {
lazy val sequence = attributes.get("@sequence") map { _.as[BigInt]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val adId = attributes.get("@adId") map { _.as[String]}
}
case class NonLinearAds2(TrackingEvents: Option[TrackingEvents_type] = None,
NonLinear: Seq[NonLinearAd_InlineChild_type] = Nil)
case class UniversalAdId(value: String,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val idRegistry = attributes("@idRegistry").as[String]
lazy val idValue = attributes("@idValue").as[String]
}
case class Creative_InlineChild_type(CompanionAds: Option[CompanionAds_Collection_type] = None,
CreativeExtensions: Option[CreativeExtensions_type] = None,
Linear: Option[Linear_InlineChild_type] = None,
NonLinearAds: Option[NonLinearAds2] = None,
UniversalAdId: Option[UniversalAdId] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends Creative_Base_typable {
lazy val sequence = attributes.get("@sequence") map { _.as[BigInt]}
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
lazy val id = attributes.get("@id") map { _.as[String]}
lazy val adId = attributes.get("@adId") map { _.as[String]}
}
trait Creative_InlineChild_typeAll
case class AdSystem(value: String,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val version = attributes.get("@version") map { _.as[String]}
}
case class Extension(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val typeValue = attributes.get("@type") map { _.as[String]}
}
case class Extensions(Extension: Seq[Extension] = Nil)
trait Model
object Model {
def fromString(value: String, scope: scala.xml.NamespaceBinding)(implicit fmt: scalaxb.XMLFormat[Model]): Model = fmt.reads(scala.xml.Text(value), Nil) match {
case Right(x: Model) => x
case x => throw new RuntimeException(s"fromString returned unexpected value $x for input $value")
}
}
case object CPC extends Model { override def toString = "CPC" }
case object CPM extends Model { override def toString = "CPM" }
case object CPE extends Model { override def toString = "CPE" }
case object CPV extends Model { override def toString = "CPV" }
case object CpcValue extends Model { override def toString = "cpc" }
case object CpmValue extends Model { override def toString = "cpm" }
case object CpeValue extends Model { override def toString = "cpe" }
case object CpvValue extends Model { override def toString = "cpv" }
case class Pricing(value: BigDecimal,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val model = attributes("@model").as[Model]
lazy val currency = attributes("@currency").as[String]
}
/**
Base type structure used by Inline or Wrapper ad content element types
*/
trait AdDefinitionBase_typable {
def AdSystem: AdSystem
def Error: Option[java.net.URI]
def Extensions: Option[Extensions]
def Impression: Seq[Impression_type]
def Pricing: Option[Pricing]
def ViewableImpression: Option[ViewableImpression_type]
}
/**
Base type structure used by Inline or Wrapper ad content element types
*/
case class AdDefinitionBase_type(AdSystem: AdSystem,
Error: Option[java.net.URI] = None,
Extensions: Option[Extensions] = None,
Impression: Seq[Impression_type] = Nil,
Pricing: Option[Pricing] = None,
ViewableImpression: Option[ViewableImpression_type] = None) extends AdDefinitionBase_typable
/**
The ViewableImpression element allows for tracking URIs to report viewability
*/
case class ViewableImpression_type(Viewable: Seq[java.net.URI] = Nil,
NotViewable: Seq[java.net.URI] = Nil,
ViewUndetermined: Seq[java.net.URI] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
case class ViewableImpression(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
/**
Verification elements are nested under AdVerifications. The Verification element is used to contain the
JavaScript or Flash code used to collect data. Multiple Verification elements may be used in
cases where more than one verification vendor needs to collect data or when different API
frameworks are used.
*/
case class Verification_Wrapper_type(ViewableImpression: Option[ViewableImpression] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val vendor = attributes.get("@vendor") map { _.as[String]}
}
case class FlashResource(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
}
case class JavaScriptResource(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val apiFramework = attributes.get("@apiFramework") map { _.as[String]}
}
case class ViewableImpression2(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val id = attributes.get("@id") map { _.as[String]}
}
/**
Verification elements are nested under AdVerifications. The Verification element is used to contain the
JavaScript or Flash code used to collect data. Multiple Verification elements may be used in
cases where more than one verification vendor needs to collect data or when different API
frameworks are used.
When included, verification contents must be executed (if possible) BEFORE the
media file or interactive creative file is executed, to ensure verification can track ad
play as intended.
*/
case class Verification_Inline_type(FlashResource: Seq[FlashResource] = Nil,
JavaScriptResource: Seq[JavaScriptResource] = Nil,
ViewableImpression: Option[ViewableImpression2] = None,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val vendor = attributes.get("@vendor") map { _.as[String]}
}
/**
The AdVerification element is used to initiate a controlled container where code can be
executed for collecting data to verify ad playback details.
*/
case class AdVerifications_Wrapper_type(Verification: Seq[Verification_Wrapper_type] = Nil)
/**
The AdVerification element is used to initiate a controlled container where code can be
executed for collecting data to verify ad playback details.
*/
case class AdVerifications_Inline_type(Verification: Seq[Verification_Inline_type] = Nil)
case class Creatives(Creative: Seq[Creative_WrapperChild_type] = Nil)
case class Wrapper_type(AdSystem: AdSystem,
Error: Option[java.net.URI] = None,
Extensions: Option[Extensions] = None,
Impression: Seq[Impression_type] = Nil,
Pricing: Option[Pricing] = None,
ViewableImpression: Option[ViewableImpression_type] = None,
AdVerifications: Option[AdVerifications_Wrapper_type] = None,
Creatives: Option[Creatives] = None,
VASTAdTagURI: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) extends AdDefinitionBase_typable with AdOption {
lazy val followAdditionalWrappers = attributes.get("@followAdditionalWrappers") map { _.as[Boolean]}
lazy val allowMultipleAds = attributes.get("@allowMultipleAds") map { _.as[Boolean]}
lazy val fallbackOnNoAd = attributes.get("@fallbackOnNoAd") map { _.as[Boolean]}
}
case class Category(value: String,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val authority = attributes("@authority").as[java.net.URI]
}
case class Creatives2(Creative: Seq[Creative_InlineChild_type] = Nil)
case class Survey(value: java.net.URI,
attributes: Map[String, scalaxb.DataRecord[Any]] = Map()) {
lazy val typeValue = attributes.get("@type") map { _.as[String]}
}
case class Inline_type(AdSystem: AdSystem,
Error: Option[java.net.URI] = None,
Extensions: Option[Extensions] = None,
Impression: Seq[Impression_type] = Nil,
Pricing: Option[Pricing] = None,
ViewableImpression: Option[ViewableImpression_type] = None,
AdTitle: String,
AdVerifications: Option[AdVerifications_Inline_type] = None,
Advertiser: Option[String] = None,
Category: Seq[Category] = Nil,
Creatives: Creatives2,
Description: Option[String] = None,
Survey: Option[Survey] = None) extends AdDefinitionBase_typable with AdOption
// Generated by <a href="http://scalaxb.org/">scalaxb</a>.
import scala.concurrent.Future
/**
usage:
val obj = scalaxb.fromXML[.Foo](node)
val document = scalaxb.toXML[.Foo](obj, "foo", .defaultScope)
**/
object `package` extends XMLProtocol { }
trait XMLProtocol extends scalaxb.XMLStandardTypes {
implicit lazy val executionContext = scala.concurrent.ExecutionContext.Implicits.global
val defaultScope = scalaxb.toScope(None -> "http://www.iab.com/VAST",
Some("vast") -> "http://www.iab.com/VAST",
Some("xs") -> "http://www.w3.org/2001/XMLSchema",
Some("xsi") -> "http://www.w3.org/2001/XMLSchema-instance")
implicit lazy val _AdFormat: scalaxb.XMLFormat[Ad] = new Default_AdFormat {}
implicit lazy val _VASTFormat: scalaxb.XMLFormat[VAST] = new Default_VASTFormat {}
implicit lazy val _IconTrackingUri_typeFormat: scalaxb.XMLFormat[IconTrackingUri_type] = new Default_IconTrackingUri_typeFormat {}
implicit lazy val _EventFormat: scalaxb.XMLFormat[Event] = new Default_EventFormat {}
implicit lazy val _TrackingFormat: scalaxb.XMLFormat[Tracking] = new Default_TrackingFormat {}
implicit lazy val _TrackingEvents_typeFormat: scalaxb.XMLFormat[TrackingEvents_type] = new Default_TrackingEvents_typeFormat {}
implicit lazy val _ClickTrackingFormat: scalaxb.XMLFormat[ClickTracking] = new Default_ClickTrackingFormat {}
implicit lazy val _CustomClickFormat: scalaxb.XMLFormat[CustomClick] = new Default_CustomClickFormat {}
implicit lazy val _VideoClicks_Base_typableFormat: scalaxb.XMLFormat[VideoClicks_Base_typable] = new Default_VideoClicks_Base_typableFormat {}
implicit lazy val _VideoClicks_Base_typeFormat: scalaxb.XMLFormat[VideoClicks_Base_type] = new Default_VideoClicks_Base_typeFormat {}
implicit lazy val _ClickThroughFormat: scalaxb.XMLFormat[ClickThrough] = new Default_ClickThroughFormat {}
implicit lazy val _VideoClicks_InlineChild_typeFormat: scalaxb.XMLFormat[VideoClicks_InlineChild_type] = new Default_VideoClicks_InlineChild_typeFormat {}
implicit lazy val _Impression_typeFormat: scalaxb.XMLFormat[Impression_type] = new Default_Impression_typeFormat {}
implicit lazy val _StaticResourceFormat: scalaxb.XMLFormat[StaticResource] = new Default_StaticResourceFormat {}
implicit lazy val _CreativeResource_NonVideo_typableFormat: scalaxb.XMLFormat[CreativeResource_NonVideo_typable] = new Default_CreativeResource_NonVideo_typableFormat {}
implicit lazy val _CreativeResource_NonVideo_typeFormat: scalaxb.XMLFormat[CreativeResource_NonVideo_type] = new Default_CreativeResource_NonVideo_typeFormat {}
implicit lazy val _IconClicksFormat: scalaxb.XMLFormat[IconClicks] = new Default_IconClicksFormat {}
implicit lazy val _Icon_typeFormat: scalaxb.XMLFormat[Icon_type] = new Default_Icon_typeFormat {}
implicit lazy val _CreativeExtensionFormat: scalaxb.XMLFormat[CreativeExtension] = new Default_CreativeExtensionFormat {}
implicit lazy val _CreativeExtensions_typeFormat: scalaxb.XMLFormat[CreativeExtensions_type] = new Default_CreativeExtensions_typeFormat {}
implicit lazy val _AdParameters_typeFormat: scalaxb.XMLFormat[AdParameters_type] = new Default_AdParameters_typeFormat {}
implicit lazy val _HTMLResource_typeFormat: scalaxb.XMLFormat[HTMLResource_type] = new Default_HTMLResource_typeFormat {}
implicit lazy val _IconsFormat: scalaxb.XMLFormat[Icons] = new Default_IconsFormat {}
implicit lazy val _Linear_Base_typableFormat: scalaxb.XMLFormat[Linear_Base_typable] = new Default_Linear_Base_typableFormat {}
implicit lazy val _Linear_Base_typeFormat: scalaxb.XMLFormat[Linear_Base_type] = new Default_Linear_Base_typeFormat {}
implicit lazy val _Linear_WrapperChild_typeFormat: scalaxb.XMLFormat[Linear_WrapperChild_type] = new Default_Linear_WrapperChild_typeFormat {}
implicit lazy val _DeliveryFormat: scalaxb.XMLFormat[Delivery] = new Default_DeliveryFormat {}
implicit lazy val _MediaFileFormat: scalaxb.XMLFormat[MediaFile] = new Default_MediaFileFormat {}
implicit lazy val _InteractiveCreativeFileFormat: scalaxb.XMLFormat[InteractiveCreativeFile] = new Default_InteractiveCreativeFileFormat {}
implicit lazy val _MediaFilesFormat: scalaxb.XMLFormat[MediaFiles] = new Default_MediaFilesFormat {}
implicit lazy val _Linear_InlineChild_typeFormat: scalaxb.XMLFormat[Linear_InlineChild_type] = new Default_Linear_InlineChild_typeFormat {}
implicit lazy val _NonLinearClickTrackingFormat: scalaxb.XMLFormat[NonLinearClickTracking] = new Default_NonLinearClickTrackingFormat {}
implicit lazy val _NonLinearAd_Base_typeFormat: scalaxb.XMLFormat[NonLinearAd_Base_type] = new Default_NonLinearAd_Base_typeFormat {}
implicit lazy val _NonLinearClickTracking2Format: scalaxb.XMLFormat[NonLinearClickTracking2] = new Default_NonLinearClickTracking2Format {}
implicit lazy val _NonLinearAd_InlineChild_typeFormat: scalaxb.XMLFormat[NonLinearAd_InlineChild_type] = new Default_NonLinearAd_InlineChild_typeFormat {}
implicit lazy val _CompanionClickTrackingFormat: scalaxb.XMLFormat[CompanionClickTracking] = new Default_CompanionClickTrackingFormat {}
implicit lazy val _CompanionAd_typeFormat: scalaxb.XMLFormat[CompanionAd_type] = new Default_CompanionAd_typeFormat {}
implicit lazy val _RequiredFormat: scalaxb.XMLFormat[Required] = new Default_RequiredFormat {}
implicit lazy val _CompanionAds_Collection_typeFormat: scalaxb.XMLFormat[CompanionAds_Collection_type] = new Default_CompanionAds_Collection_typeFormat {}
implicit lazy val _Creative_Base_typableFormat: scalaxb.XMLFormat[Creative_Base_typable] = new Default_Creative_Base_typableFormat {}
implicit lazy val _Creative_Base_typeFormat: scalaxb.XMLFormat[Creative_Base_type] = new Default_Creative_Base_typeFormat {}
implicit lazy val _NonLinearAdsFormat: scalaxb.XMLFormat[NonLinearAds] = new Default_NonLinearAdsFormat {}
implicit lazy val _Creative_WrapperChild_typeFormat: scalaxb.XMLFormat[Creative_WrapperChild_type] = new Default_Creative_WrapperChild_typeFormat {}
implicit lazy val _NonLinearAds2Format: scalaxb.XMLFormat[NonLinearAds2] = new Default_NonLinearAds2Format {}
implicit lazy val _UniversalAdIdFormat: scalaxb.XMLFormat[UniversalAdId] = new Default_UniversalAdIdFormat {}
implicit lazy val _Creative_InlineChild_typeFormat: scalaxb.XMLFormat[Creative_InlineChild_type] = new Default_Creative_InlineChild_typeFormat {}
implicit lazy val _AdSystemFormat: scalaxb.XMLFormat[AdSystem] = new Default_AdSystemFormat {}
implicit lazy val _ExtensionFormat: scalaxb.XMLFormat[Extension] = new Default_ExtensionFormat {}
implicit lazy val _ExtensionsFormat: scalaxb.XMLFormat[Extensions] = new Default_ExtensionsFormat {}
implicit lazy val _ModelFormat: scalaxb.XMLFormat[Model] = new Default_ModelFormat {}
implicit lazy val _PricingFormat: scalaxb.XMLFormat[Pricing] = new Default_PricingFormat {}
implicit lazy val _AdDefinitionBase_typableFormat: scalaxb.XMLFormat[AdDefinitionBase_typable] = new Default_AdDefinitionBase_typableFormat {}
implicit lazy val _AdDefinitionBase_typeFormat: scalaxb.XMLFormat[AdDefinitionBase_type] = new Default_AdDefinitionBase_typeFormat {}
implicit lazy val _ViewableImpression_typeFormat: scalaxb.XMLFormat[ViewableImpression_type] = new Default_ViewableImpression_typeFormat {}
implicit lazy val _ViewableImpressionFormat: scalaxb.XMLFormat[ViewableImpression] = new Default_ViewableImpressionFormat {}
implicit lazy val _Verification_Wrapper_typeFormat: scalaxb.XMLFormat[Verification_Wrapper_type] = new Default_Verification_Wrapper_typeFormat {}
implicit lazy val _FlashResourceFormat: scalaxb.XMLFormat[FlashResource] = new Default_FlashResourceFormat {}
implicit lazy val _JavaScriptResourceFormat: scalaxb.XMLFormat[JavaScriptResource] = new Default_JavaScriptResourceFormat {}
implicit lazy val _ViewableImpression2Format: scalaxb.XMLFormat[ViewableImpression2] = new Default_ViewableImpression2Format {}
implicit lazy val _Verification_Inline_typeFormat: scalaxb.XMLFormat[Verification_Inline_type] = new Default_Verification_Inline_typeFormat {}
implicit lazy val _AdVerifications_Wrapper_typeFormat: scalaxb.XMLFormat[AdVerifications_Wrapper_type] = new Default_AdVerifications_Wrapper_typeFormat {}
implicit lazy val _AdVerifications_Inline_typeFormat: scalaxb.XMLFormat[AdVerifications_Inline_type] = new Default_AdVerifications_Inline_typeFormat {}
implicit lazy val _CreativesFormat: scalaxb.XMLFormat[Creatives] = new Default_CreativesFormat {}
implicit lazy val _Wrapper_typeFormat: scalaxb.XMLFormat[Wrapper_type] = new Default_Wrapper_typeFormat {}
implicit lazy val _CategoryFormat: scalaxb.XMLFormat[Category] = new Default_CategoryFormat {}
implicit lazy val _Creatives2Format: scalaxb.XMLFormat[Creatives2] = new Default_Creatives2Format {}
implicit lazy val _SurveyFormat: scalaxb.XMLFormat[Survey] = new Default_SurveyFormat {}
implicit lazy val _Inline_typeFormat: scalaxb.XMLFormat[Inline_type] = new Default_Inline_typeFormat {}
implicit val fromAnySchemaType: scala.xml.Elem => Option[scalaxb.DataRecord[Any]] = {elem =>
import scalaxb.{Helper, DataRecord, fromXML}
val ns = Helper.nullOrEmpty(elem.scope.getURI(elem.prefix))
val key = Some(elem.label)
val (xsns, xstype) = Helper.instanceType(elem)
(key, ns) match {
case (Some("VAST"), Some("http://www.iab.com/VAST") | None) => Some(DataRecord(ns, key, xsns, xstype, fromXML[VAST](elem)))
case _ => None
}
}
trait Default_AdFormat extends scalaxb.ElemNameParser[Ad] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Ad] =
phrase(opt(((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "InLine")) ^^
(x => scalaxb.DataRecord(x.namespace, Some(x.name), scalaxb.fromXML[Inline_type](x, scalaxb.ElemName(node) :: stack)))) |
((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Wrapper")) ^^
(x => scalaxb.DataRecord(x.namespace, Some(x.name), scalaxb.fromXML[Wrapper_type](x, scalaxb.ElemName(node) :: stack))))) ^^
{ case p1 =>
Ad(p1,
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@sequence").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@sequence" -> _ },
(node \ "@conditionalAd").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@conditionalAd" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Ad, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@sequence", _) => __obj.sequence foreach { x => attr = scala.xml.Attribute(null, "sequence", x.toString, attr) }
case ("@conditionalAd", _) => __obj.conditionalAd foreach { x => attr = scala.xml.Attribute(null, "conditionalAd", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Ad, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.adoption map { x => scalaxb.toXML[scalaxb.DataRecord[AdOption]](x, x.namespace, x.key, __scope, false) } getOrElse {Nil})
}
trait Default_VASTFormat extends scalaxb.ElemNameParser[VAST] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[VAST] =
phrase(safeRep(((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Ad")) ^^
(x => scalaxb.DataRecord(x.namespace, Some(x.name), scalaxb.fromXML[Ad](x, scalaxb.ElemName(node) :: stack)))) |
((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Error")) ^^
(x => scalaxb.DataRecord(x.namespace, Some(x.name), scalaxb.fromXML[java.net.URI](x, scalaxb.ElemName(node) :: stack))))) ^^
{ case p1 =>
VAST(p1,
scala.collection.immutable.ListMap(List(
(node \ "@version").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@version" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: VAST, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@version", _) => attr = scala.xml.Attribute(null, "version", __obj.version.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: VAST, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.vastoption flatMap { x => scalaxb.toXML[scalaxb.DataRecord[Any]](x, x.namespace, x.key, __scope, false) })
}
trait Default_IconTrackingUri_typeFormat extends scalaxb.XMLFormat[IconTrackingUri_type] with scalaxb.CanWriteChildNodes[IconTrackingUri_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, IconTrackingUri_type] = seq match {
case node: scala.xml.Node => Right(IconTrackingUri_type(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: IconTrackingUri_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: IconTrackingUri_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
def build_EventFormat = new Default_EventFormat {}
trait Default_EventFormat extends scalaxb.XMLFormat[Event] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def fromString(value: String, scope: scala.xml.NamespaceBinding): Event = scalaxb.fromXML[String](scala.xml.Text(value)) match {
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("mute")) => Mute
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("unmute")) => Unmute
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("pause")) => Pause
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("resume")) => Resume
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("rewind")) => Rewind
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("skip")) => Skip
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("playerExpand")) => PlayerExpand
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("playerCollapse")) => PlayerCollapse
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("start")) => Start
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("firstQuartile")) => FirstQuartile
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("midpoint")) => Midpoint
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("thirdQuartile")) => ThirdQuartile
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("complete")) => Complete
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("acceptInvitationLinear")) => AcceptInvitationLinear
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("timeSpentViewing")) => TimeSpentViewing
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("progress")) => Progress
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("creativeView")) => CreativeView
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("acceptInvitation")) => AcceptInvitation
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("adExpand")) => AdExpand
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("adCollapse")) => AdCollapse
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("minimize")) => Minimize
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("close")) => Close
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("overlayViewDuration")) => OverlayViewDuration
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("otherAdInteraction")) => OtherAdInteraction
}
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Event] = seq match {
case elem: scala.xml.Elem => Right(fromString(elem.text, elem.scope))
case _ => Right(fromString(seq.text, scala.xml.TopScope))
}
def writes(__obj: Event, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq =
scala.xml.Elem(scalaxb.Helper.getPrefix(__namespace, __scope).orNull,
__elementLabel getOrElse { sys.error("missing element label.") },
scala.xml.Null, __scope, true, scala.xml.Text(__obj.toString))
}
trait Default_TrackingFormat extends scalaxb.XMLFormat[Tracking] with scalaxb.CanWriteChildNodes[Tracking] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Tracking] = seq match {
case node: scala.xml.Node => Right(Tracking(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@event").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Event](x, scalaxb.ElemName(node) :: stack)) } map { "@event" -> _ },
(node \ "@offset").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@offset" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Tracking, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@event", _) => attr = scala.xml.Attribute(null, "event", __obj.event.toString, attr)
case ("@offset", _) => __obj.offset foreach { x => attr = scala.xml.Attribute(null, "offset", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Tracking, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_TrackingEvents_typeFormat extends scalaxb.ElemNameParser[TrackingEvents_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("TrackingEvents_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[TrackingEvents_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Tracking")) ^^
{ case p1 =>
TrackingEvents_type(p1 map { scalaxb.fromXML[Tracking](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: TrackingEvents_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Tracking flatMap { scalaxb.toXML[Tracking](_, Some("http://www.iab.com/VAST"), Some("Tracking"), __scope, false) })
}
trait Default_ClickTrackingFormat extends scalaxb.XMLFormat[ClickTracking] with scalaxb.CanWriteChildNodes[ClickTracking] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, ClickTracking] = seq match {
case node: scala.xml.Node => Right(ClickTracking(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: ClickTracking, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: ClickTracking, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_CustomClickFormat extends scalaxb.XMLFormat[CustomClick] with scalaxb.CanWriteChildNodes[CustomClick] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, CustomClick] = seq match {
case node: scala.xml.Node => Right(CustomClick(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: CustomClick, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: CustomClick, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_VideoClicks_Base_typableFormat extends scalaxb.XMLFormat[VideoClicks_Base_typable] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, VideoClicks_Base_typable] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.iab.com/VAST"), Some("VideoClicks_InlineChild_type")) => Right(scalaxb.fromXML[VideoClicks_InlineChild_type](node, stack))
case _ => Right(scalaxb.fromXML[VideoClicks_Base_type](node, stack))
}
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writes(__obj: VideoClicks_Base_typable, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = __obj match {
case x: VideoClicks_InlineChild_type => scalaxb.toXML[VideoClicks_InlineChild_type](x, __namespace, __elementLabel, __scope, true)
case x: VideoClicks_Base_type => scalaxb.toXML[VideoClicks_Base_type](x, __namespace, __elementLabel, __scope, false)
}
}
trait Default_VideoClicks_Base_typeFormat extends scalaxb.ElemNameParser[VideoClicks_Base_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("VideoClicks_Base_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[VideoClicks_Base_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ClickTracking")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CustomClick")) ^^
{ case p1 ~ p2 =>
VideoClicks_Base_type(p1 map { scalaxb.fromXML[ClickTracking](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[CustomClick](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: VideoClicks_Base_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.ClickTracking flatMap { scalaxb.toXML[ClickTracking](_, Some("http://www.iab.com/VAST"), Some("ClickTracking"), __scope, false) },
__obj.CustomClick flatMap { scalaxb.toXML[CustomClick](_, Some("http://www.iab.com/VAST"), Some("CustomClick"), __scope, false) })
}
trait Default_ClickThroughFormat extends scalaxb.XMLFormat[ClickThrough] with scalaxb.CanWriteChildNodes[ClickThrough] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, ClickThrough] = seq match {
case node: scala.xml.Node => Right(ClickThrough(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: ClickThrough, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: ClickThrough, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_VideoClicks_InlineChild_typeFormat extends scalaxb.ElemNameParser[VideoClicks_InlineChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("VideoClicks_InlineChild_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[VideoClicks_InlineChild_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ClickTracking")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CustomClick")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ClickThrough")) ^^
{ case p1 ~ p2 ~ p3 =>
VideoClicks_InlineChild_type(p1 map { scalaxb.fromXML[ClickTracking](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[CustomClick](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[ClickThrough](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: VideoClicks_InlineChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.ClickTracking flatMap { scalaxb.toXML[ClickTracking](_, Some("http://www.iab.com/VAST"), Some("ClickTracking"), __scope, false) },
__obj.CustomClick flatMap { scalaxb.toXML[CustomClick](_, Some("http://www.iab.com/VAST"), Some("CustomClick"), __scope, false) },
__obj.ClickThrough map { scalaxb.toXML[ClickThrough](_, Some("http://www.iab.com/VAST"), Some("ClickThrough"), __scope, false) } getOrElse {Nil})
}
trait Default_Impression_typeFormat extends scalaxb.XMLFormat[Impression_type] with scalaxb.CanWriteChildNodes[Impression_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Impression_type] = seq match {
case node: scala.xml.Node => Right(Impression_type(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Impression_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Impression_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_StaticResourceFormat extends scalaxb.XMLFormat[StaticResource] with scalaxb.CanWriteChildNodes[StaticResource] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, StaticResource] = seq match {
case node: scala.xml.Node => Right(StaticResource(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@creativeType").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@creativeType" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: StaticResource, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@creativeType", _) => attr = scala.xml.Attribute(null, "creativeType", __obj.creativeType.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: StaticResource, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_CreativeResource_NonVideo_typableFormat extends scalaxb.XMLFormat[CreativeResource_NonVideo_typable] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, CreativeResource_NonVideo_typable] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.iab.com/VAST"), Some("NonLinearAd_InlineChild_type")) => Right(scalaxb.fromXML[NonLinearAd_InlineChild_type](node, stack))
case (Some("http://www.iab.com/VAST"), Some("Icon_type")) => Right(scalaxb.fromXML[Icon_type](node, stack))
case (Some("http://www.iab.com/VAST"), Some("CompanionAd_type")) => Right(scalaxb.fromXML[CompanionAd_type](node, stack))
case _ => Right(scalaxb.fromXML[CreativeResource_NonVideo_type](node, stack))
}
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writes(__obj: CreativeResource_NonVideo_typable, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = __obj match {
case x: NonLinearAd_InlineChild_type => scalaxb.toXML[NonLinearAd_InlineChild_type](x, __namespace, __elementLabel, __scope, true)
case x: Icon_type => scalaxb.toXML[Icon_type](x, __namespace, __elementLabel, __scope, true)
case x: CompanionAd_type => scalaxb.toXML[CompanionAd_type](x, __namespace, __elementLabel, __scope, true)
case x: CreativeResource_NonVideo_type => scalaxb.toXML[CreativeResource_NonVideo_type](x, __namespace, __elementLabel, __scope, false)
}
}
trait Default_CreativeResource_NonVideo_typeFormat extends scalaxb.ElemNameParser[CreativeResource_NonVideo_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("CreativeResource_NonVideo_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[CreativeResource_NonVideo_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "HTMLResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IFrameResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "StaticResource")) ^^
{ case p1 ~ p2 ~ p3 =>
CreativeResource_NonVideo_type(p1 map { scalaxb.fromXML[HTMLResource_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[StaticResource](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: CreativeResource_NonVideo_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.HTMLResource flatMap { scalaxb.toXML[HTMLResource_type](_, Some("http://www.iab.com/VAST"), Some("HTMLResource"), __scope, false) },
__obj.IFrameResource flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IFrameResource"), __scope, false) },
__obj.StaticResource flatMap { scalaxb.toXML[StaticResource](_, Some("http://www.iab.com/VAST"), Some("StaticResource"), __scope, false) })
}
trait Default_IconClicksFormat extends scalaxb.ElemNameParser[IconClicks] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[IconClicks] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IconClickThrough")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IconClickTracking")) ^^
{ case p1 ~ p2 =>
IconClicks(p1.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[IconTrackingUri_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: IconClicks, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.IconClickThrough map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IconClickThrough"), __scope, false) } getOrElse {Nil},
__obj.IconClickTracking flatMap { scalaxb.toXML[IconTrackingUri_type](_, Some("http://www.iab.com/VAST"), Some("IconClickTracking"), __scope, false) })
}
trait Default_Icon_typeFormat extends scalaxb.ElemNameParser[Icon_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Icon_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Icon_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "HTMLResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IFrameResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "StaticResource")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IconClicks")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IconViewTracking")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 =>
Icon_type(p1 map { scalaxb.fromXML[HTMLResource_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[StaticResource](_, scalaxb.ElemName(node) :: stack) },
p4.headOption map { scalaxb.fromXML[IconClicks](_, scalaxb.ElemName(node) :: stack) },
p5 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@program").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@program" -> _ },
(node \ "@width").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@width" -> _ },
(node \ "@height").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@height" -> _ },
(node \ "@xPosition").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@xPosition" -> _ },
(node \ "@yPosition").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@yPosition" -> _ },
(node \ "@duration").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[javax.xml.datatype.XMLGregorianCalendar](x, scalaxb.ElemName(node) :: stack)) } map { "@duration" -> _ },
(node \ "@offset").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[javax.xml.datatype.XMLGregorianCalendar](x, scalaxb.ElemName(node) :: stack)) } map { "@offset" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ },
(node \ "@pxratio").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigDecimal](x, scalaxb.ElemName(node) :: stack)) } map { "@pxratio" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Icon_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@program", _) => __obj.program foreach { x => attr = scala.xml.Attribute(null, "program", x.toString, attr) }
case ("@width", _) => __obj.width foreach { x => attr = scala.xml.Attribute(null, "width", x.toString, attr) }
case ("@height", _) => __obj.height foreach { x => attr = scala.xml.Attribute(null, "height", x.toString, attr) }
case ("@xPosition", _) => __obj.xPosition foreach { x => attr = scala.xml.Attribute(null, "xPosition", x.toString, attr) }
case ("@yPosition", _) => __obj.yPosition foreach { x => attr = scala.xml.Attribute(null, "yPosition", x.toString, attr) }
case ("@duration", _) => __obj.duration foreach { x => attr = scala.xml.Attribute(null, "duration", x.toString, attr) }
case ("@offset", _) => __obj.offset foreach { x => attr = scala.xml.Attribute(null, "offset", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case ("@pxratio", _) => __obj.pxratio foreach { x => attr = scala.xml.Attribute(null, "pxratio", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Icon_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.HTMLResource flatMap { scalaxb.toXML[HTMLResource_type](_, Some("http://www.iab.com/VAST"), Some("HTMLResource"), __scope, false) },
__obj.IFrameResource flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IFrameResource"), __scope, false) },
__obj.StaticResource flatMap { scalaxb.toXML[StaticResource](_, Some("http://www.iab.com/VAST"), Some("StaticResource"), __scope, false) },
__obj.IconClicks map { scalaxb.toXML[IconClicks](_, Some("http://www.iab.com/VAST"), Some("IconClicks"), __scope, false) } getOrElse {Nil},
__obj.IconViewTracking flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IconViewTracking"), __scope, false) })
}
trait Default_CreativeExtensionFormat extends scalaxb.ElemNameParser[CreativeExtension] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[CreativeExtension] =
phrase(safeRep(any(_ => true)) ^^
{ case p1 =>
CreativeExtension(p1 map { scalaxb.fromXML[scalaxb.DataRecord[Any]](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@type").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@type" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])] ::: (node match {
case elem: scala.xml.Elem =>
elem.attributes.toList flatMap {
case scala.xml.UnprefixedAttribute(key, value, _) if key == "type" => Nil
case scala.xml.UnprefixedAttribute(key, value, _) =>
List(("@" + key, scalaxb.DataRecord(None, Some(key), value.text)))
case scala.xml.PrefixedAttribute(pre, key, value, _) =>
val ns = elem.scope.getURI(pre)
List(("@{" + ns + "}" + key, scalaxb.DataRecord(Option[String](ns), Some(key), value.text)))
case _ => Nil
}
case _ => Nil
}): _*)) })
override def writesAttribute(__obj: CreativeExtension, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@type", _) => __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: CreativeExtension, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.any flatMap { x => scalaxb.toXML[scalaxb.DataRecord[Any]](x, x.namespace, x.key, __scope, true) })
}
trait Default_CreativeExtensions_typeFormat extends scalaxb.ElemNameParser[CreativeExtensions_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("CreativeExtensions_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[CreativeExtensions_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CreativeExtension")) ^^
{ case p1 =>
CreativeExtensions_type(p1 map { scalaxb.fromXML[CreativeExtension](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: CreativeExtensions_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.CreativeExtension flatMap { scalaxb.toXML[CreativeExtension](_, Some("http://www.iab.com/VAST"), Some("CreativeExtension"), __scope, false) })
}
trait Default_AdParameters_typeFormat extends scalaxb.XMLFormat[AdParameters_type] with scalaxb.CanWriteChildNodes[AdParameters_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, AdParameters_type] = seq match {
case node: scala.xml.Node => Right(AdParameters_type(scalaxb.fromXML[String](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@xmlEncoded").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@xmlEncoded" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: AdParameters_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@xmlEncoded", _) => __obj.xmlEncoded foreach { x => attr = scala.xml.Attribute(null, "xmlEncoded", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: AdParameters_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_HTMLResource_typeFormat extends scalaxb.XMLFormat[HTMLResource_type] with scalaxb.CanWriteChildNodes[HTMLResource_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, HTMLResource_type] = seq match {
case node: scala.xml.Node => Right(HTMLResource_type(scalaxb.fromXML[String](node, scalaxb.ElemName(node) :: stack)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writesChildNodes(__obj: HTMLResource_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_IconsFormat extends scalaxb.XMLFormat[Icons] with scalaxb.CanWriteChildNodes[Icons] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Icons] = seq match {
case node: scala.xml.Node => Right(Icons((node \ "Icon").headOption map { scalaxb.fromXML[Icon_type](_, scalaxb.ElemName(node) :: stack) }))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writesChildNodes(__obj: Icons, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Icon map { scalaxb.toXML[Icon_type](_, Some("http://www.iab.com/VAST"), Some("Icon"), __scope, false) } getOrElse {Nil})
}
trait Default_Linear_Base_typableFormat extends scalaxb.XMLFormat[Linear_Base_typable] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Linear_Base_typable] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.iab.com/VAST"), Some("Linear_InlineChild_type")) => Right(scalaxb.fromXML[Linear_InlineChild_type](node, stack))
case (Some("http://www.iab.com/VAST"), Some("Linear_WrapperChild_type")) => Right(scalaxb.fromXML[Linear_WrapperChild_type](node, stack))
case _ => Right(scalaxb.fromXML[Linear_Base_type](node, stack))
}
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writes(__obj: Linear_Base_typable, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = __obj match {
case x: Linear_InlineChild_type => scalaxb.toXML[Linear_InlineChild_type](x, __namespace, __elementLabel, __scope, true)
case x: Linear_WrapperChild_type => scalaxb.toXML[Linear_WrapperChild_type](x, __namespace, __elementLabel, __scope, true)
case x: Linear_Base_type => scalaxb.toXML[Linear_Base_type](x, __namespace, __elementLabel, __scope, false)
}
}
trait Default_Linear_Base_typeFormat extends scalaxb.ElemNameParser[Linear_Base_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Linear_Base_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Linear_Base_type] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Icons")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ^^
{ case p1 ~ p2 =>
Linear_Base_type(p1.headOption map { scalaxb.fromXML[Icons](_, scalaxb.ElemName(node) :: stack) },
p2.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@skipoffset").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@skipoffset" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Linear_Base_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@skipoffset", _) => __obj.skipoffset foreach { x => attr = scala.xml.Attribute(null, "skipoffset", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Linear_Base_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.Icons map { scalaxb.toXML[Icons](_, Some("http://www.iab.com/VAST"), Some("Icons"), __scope, false) } getOrElse {Nil},
__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil})
}
trait Default_Linear_WrapperChild_typeFormat extends scalaxb.ElemNameParser[Linear_WrapperChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Linear_WrapperChild_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Linear_WrapperChild_type] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Icons")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "VideoClicks")) ^^
{ case p1 ~ p2 ~ p3 =>
Linear_WrapperChild_type(p1.headOption map { scalaxb.fromXML[Icons](_, scalaxb.ElemName(node) :: stack) },
p2.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[VideoClicks_Base_typable](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@skipoffset").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@skipoffset" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Linear_WrapperChild_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@skipoffset", _) => __obj.skipoffset foreach { x => attr = scala.xml.Attribute(null, "skipoffset", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Linear_WrapperChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.Icons map { scalaxb.toXML[Icons](_, Some("http://www.iab.com/VAST"), Some("Icons"), __scope, false) } getOrElse {Nil},
__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil},
__obj.VideoClicks map { scalaxb.toXML[VideoClicks_Base_typable](_, Some("http://www.iab.com/VAST"), Some("VideoClicks"), __scope, false) } getOrElse {Nil})
}
def build_DeliveryFormat = new Default_DeliveryFormat {}
trait Default_DeliveryFormat extends scalaxb.XMLFormat[Delivery] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def fromString(value: String, scope: scala.xml.NamespaceBinding): Delivery = scalaxb.fromXML[String](scala.xml.Text(value)) match {
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("streaming")) => Streaming
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("progressive")) => Progressive
}
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Delivery] = seq match {
case elem: scala.xml.Elem => Right(fromString(elem.text, elem.scope))
case _ => Right(fromString(seq.text, scala.xml.TopScope))
}
def writes(__obj: Delivery, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq =
scala.xml.Elem(scalaxb.Helper.getPrefix(__namespace, __scope).orNull,
__elementLabel getOrElse { sys.error("missing element label.") },
scala.xml.Null, __scope, true, scala.xml.Text(__obj.toString))
}
trait Default_MediaFileFormat extends scalaxb.XMLFormat[MediaFile] with scalaxb.CanWriteChildNodes[MediaFile] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, MediaFile] = seq match {
case node: scala.xml.Node => Right(MediaFile(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@delivery").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Delivery](x, scalaxb.ElemName(node) :: stack)) } map { "@delivery" -> _ },
(node \ "@type").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@type" -> _ },
(node \ "@width").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@width" -> _ },
(node \ "@height").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@height" -> _ },
(node \ "@codec").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@codec" -> _ },
(node \ "@bitrate").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@bitrate" -> _ },
(node \ "@minBitrate").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@minBitrate" -> _ },
(node \ "@maxBitrate").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@maxBitrate" -> _ },
(node \ "@scalable").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@scalable" -> _ },
(node \ "@maintainAspectRatio").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@maintainAspectRatio" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: MediaFile, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@delivery", _) => attr = scala.xml.Attribute(null, "delivery", __obj.delivery.toString, attr)
case ("@type", _) => attr = scala.xml.Attribute(null, "type", __obj.typeValue.toString, attr)
case ("@width", _) => attr = scala.xml.Attribute(null, "width", __obj.width.toString, attr)
case ("@height", _) => attr = scala.xml.Attribute(null, "height", __obj.height.toString, attr)
case ("@codec", _) => __obj.codec foreach { x => attr = scala.xml.Attribute(null, "codec", x.toString, attr) }
case ("@bitrate", _) => __obj.bitrate foreach { x => attr = scala.xml.Attribute(null, "bitrate", x.toString, attr) }
case ("@minBitrate", _) => __obj.minBitrate foreach { x => attr = scala.xml.Attribute(null, "minBitrate", x.toString, attr) }
case ("@maxBitrate", _) => __obj.maxBitrate foreach { x => attr = scala.xml.Attribute(null, "maxBitrate", x.toString, attr) }
case ("@scalable", _) => __obj.scalable foreach { x => attr = scala.xml.Attribute(null, "scalable", x.toString, attr) }
case ("@maintainAspectRatio", _) => __obj.maintainAspectRatio foreach { x => attr = scala.xml.Attribute(null, "maintainAspectRatio", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: MediaFile, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_InteractiveCreativeFileFormat extends scalaxb.XMLFormat[InteractiveCreativeFile] with scalaxb.CanWriteChildNodes[InteractiveCreativeFile] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, InteractiveCreativeFile] = seq match {
case node: scala.xml.Node => Right(InteractiveCreativeFile(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@type").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@type" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: InteractiveCreativeFile, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@type", _) => __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: InteractiveCreativeFile, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_MediaFilesFormat extends scalaxb.ElemNameParser[MediaFiles] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[MediaFiles] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "MediaFile")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Mezzanine")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "InteractiveCreativeFile")) ^^
{ case p1 ~ p2 ~ p3 =>
MediaFiles(p1 map { scalaxb.fromXML[MediaFile](_, scalaxb.ElemName(node) :: stack) },
p2.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[InteractiveCreativeFile](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: MediaFiles, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.MediaFile flatMap { scalaxb.toXML[MediaFile](_, Some("http://www.iab.com/VAST"), Some("MediaFile"), __scope, false) },
__obj.Mezzanine map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("Mezzanine"), __scope, false) } getOrElse {Nil},
__obj.InteractiveCreativeFile flatMap { scalaxb.toXML[InteractiveCreativeFile](_, Some("http://www.iab.com/VAST"), Some("InteractiveCreativeFile"), __scope, false) })
}
trait Default_Linear_InlineChild_typeFormat extends scalaxb.ElemNameParser[Linear_InlineChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Linear_InlineChild_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Linear_InlineChild_type] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Icons")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdParameters")) ~
(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Duration")) ~
(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "MediaFiles")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "VideoClicks")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 =>
Linear_InlineChild_type(p1.headOption map { scalaxb.fromXML[Icons](_, scalaxb.ElemName(node) :: stack) },
p2.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[AdParameters_type](_, scalaxb.ElemName(node) :: stack) },
scalaxb.fromXML[javax.xml.datatype.XMLGregorianCalendar](p4, scalaxb.ElemName(node) :: stack),
scalaxb.fromXML[MediaFiles](p5, scalaxb.ElemName(node) :: stack),
p6.headOption map { scalaxb.fromXML[VideoClicks_InlineChild_type](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@skipoffset").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@skipoffset" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Linear_InlineChild_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@skipoffset", _) => __obj.skipoffset foreach { x => attr = scala.xml.Attribute(null, "skipoffset", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Linear_InlineChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.Icons map { scalaxb.toXML[Icons](_, Some("http://www.iab.com/VAST"), Some("Icons"), __scope, false) } getOrElse {Nil},
__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil},
__obj.AdParameters map { scalaxb.toXML[AdParameters_type](_, Some("http://www.iab.com/VAST"), Some("AdParameters"), __scope, false) } getOrElse {Nil},
scalaxb.toXML[javax.xml.datatype.XMLGregorianCalendar](__obj.Duration, Some("http://www.iab.com/VAST"), Some("Duration"), __scope, false),
scalaxb.toXML[MediaFiles](__obj.MediaFiles, Some("http://www.iab.com/VAST"), Some("MediaFiles"), __scope, false),
__obj.VideoClicks map { scalaxb.toXML[VideoClicks_InlineChild_type](_, Some("http://www.iab.com/VAST"), Some("VideoClicks"), __scope, false) } getOrElse {Nil})
}
trait Default_NonLinearClickTrackingFormat extends scalaxb.XMLFormat[NonLinearClickTracking] with scalaxb.CanWriteChildNodes[NonLinearClickTracking] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, NonLinearClickTracking] = seq match {
case node: scala.xml.Node => Right(NonLinearClickTracking(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: NonLinearClickTracking, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: NonLinearClickTracking, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_NonLinearAd_Base_typeFormat extends scalaxb.XMLFormat[NonLinearAd_Base_type] with scalaxb.CanWriteChildNodes[NonLinearAd_Base_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, NonLinearAd_Base_type] = seq match {
case node: scala.xml.Node => Right(NonLinearAd_Base_type((node \ "NonLinearClickTracking").headOption map { scalaxb.fromXML[NonLinearClickTracking](_, scalaxb.ElemName(node) :: stack) }))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writesChildNodes(__obj: NonLinearAd_Base_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.NonLinearClickTracking map { scalaxb.toXML[NonLinearClickTracking](_, Some("http://www.iab.com/VAST"), Some("NonLinearClickTracking"), __scope, false) } getOrElse {Nil})
}
trait Default_NonLinearClickTracking2Format extends scalaxb.XMLFormat[NonLinearClickTracking2] with scalaxb.CanWriteChildNodes[NonLinearClickTracking2] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, NonLinearClickTracking2] = seq match {
case node: scala.xml.Node => Right(NonLinearClickTracking2(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: NonLinearClickTracking2, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: NonLinearClickTracking2, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_NonLinearAd_InlineChild_typeFormat extends scalaxb.ElemNameParser[NonLinearAd_InlineChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("NonLinearAd_InlineChild_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[NonLinearAd_InlineChild_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "HTMLResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IFrameResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "StaticResource")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdParameters")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NonLinearClickThrough")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NonLinearClickTracking")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 =>
NonLinearAd_InlineChild_type(p1 map { scalaxb.fromXML[HTMLResource_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[StaticResource](_, scalaxb.ElemName(node) :: stack) },
p4.headOption map { scalaxb.fromXML[AdParameters_type](_, scalaxb.ElemName(node) :: stack) },
p5.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p6 map { scalaxb.fromXML[NonLinearClickTracking2](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: NonLinearAd_InlineChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.HTMLResource flatMap { scalaxb.toXML[HTMLResource_type](_, Some("http://www.iab.com/VAST"), Some("HTMLResource"), __scope, false) },
__obj.IFrameResource flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IFrameResource"), __scope, false) },
__obj.StaticResource flatMap { scalaxb.toXML[StaticResource](_, Some("http://www.iab.com/VAST"), Some("StaticResource"), __scope, false) },
__obj.AdParameters map { scalaxb.toXML[AdParameters_type](_, Some("http://www.iab.com/VAST"), Some("AdParameters"), __scope, false) } getOrElse {Nil},
__obj.NonLinearClickThrough map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("NonLinearClickThrough"), __scope, false) } getOrElse {Nil},
__obj.NonLinearClickTracking flatMap { scalaxb.toXML[NonLinearClickTracking2](_, Some("http://www.iab.com/VAST"), Some("NonLinearClickTracking"), __scope, false) })
}
trait Default_CompanionClickTrackingFormat extends scalaxb.XMLFormat[CompanionClickTracking] with scalaxb.CanWriteChildNodes[CompanionClickTracking] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, CompanionClickTracking] = seq match {
case node: scala.xml.Node => Right(CompanionClickTracking(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: CompanionClickTracking, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => attr = scala.xml.Attribute(null, "id", __obj.id.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: CompanionClickTracking, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_CompanionAd_typeFormat extends scalaxb.ElemNameParser[CompanionAd_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("CompanionAd_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[CompanionAd_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "HTMLResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "IFrameResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "StaticResource")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdParameters")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AltText")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CompanionClickThrough")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CompanionClickTracking")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CreativeExtensions")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 ~ p7 ~ p8 ~ p9 =>
CompanionAd_type(p1 map { scalaxb.fromXML[HTMLResource_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[StaticResource](_, scalaxb.ElemName(node) :: stack) },
p4.headOption map { scalaxb.fromXML[AdParameters_type](_, scalaxb.ElemName(node) :: stack) },
p5.headOption map { scalaxb.fromXML[String](_, scalaxb.ElemName(node) :: stack) },
p6.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p7 map { scalaxb.fromXML[CompanionClickTracking](_, scalaxb.ElemName(node) :: stack) },
p8.headOption map { scalaxb.fromXML[CreativeExtensions_type](_, scalaxb.ElemName(node) :: stack) },
p9.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@width").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@width" -> _ },
(node \ "@height").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@height" -> _ },
(node \ "@assetWidth").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@assetWidth" -> _ },
(node \ "@assetHeight").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@assetHeight" -> _ },
(node \ "@expandedWidth").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@expandedWidth" -> _ },
(node \ "@expandedHeight").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@expandedHeight" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ },
(node \ "@adSlotID").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@adSlotID" -> _ },
(node \ "@pxratio").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigDecimal](x, scalaxb.ElemName(node) :: stack)) } map { "@pxratio" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: CompanionAd_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@width", _) => attr = scala.xml.Attribute(null, "width", __obj.width.toString, attr)
case ("@height", _) => attr = scala.xml.Attribute(null, "height", __obj.height.toString, attr)
case ("@assetWidth", _) => __obj.assetWidth foreach { x => attr = scala.xml.Attribute(null, "assetWidth", x.toString, attr) }
case ("@assetHeight", _) => __obj.assetHeight foreach { x => attr = scala.xml.Attribute(null, "assetHeight", x.toString, attr) }
case ("@expandedWidth", _) => __obj.expandedWidth foreach { x => attr = scala.xml.Attribute(null, "expandedWidth", x.toString, attr) }
case ("@expandedHeight", _) => __obj.expandedHeight foreach { x => attr = scala.xml.Attribute(null, "expandedHeight", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case ("@adSlotID", _) => __obj.adSlotID foreach { x => attr = scala.xml.Attribute(null, "adSlotID", x.toString, attr) }
case ("@pxratio", _) => __obj.pxratio foreach { x => attr = scala.xml.Attribute(null, "pxratio", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: CompanionAd_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.HTMLResource flatMap { scalaxb.toXML[HTMLResource_type](_, Some("http://www.iab.com/VAST"), Some("HTMLResource"), __scope, false) },
__obj.IFrameResource flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("IFrameResource"), __scope, false) },
__obj.StaticResource flatMap { scalaxb.toXML[StaticResource](_, Some("http://www.iab.com/VAST"), Some("StaticResource"), __scope, false) },
__obj.AdParameters map { scalaxb.toXML[AdParameters_type](_, Some("http://www.iab.com/VAST"), Some("AdParameters"), __scope, false) } getOrElse {Nil},
__obj.AltText map { scalaxb.toXML[String](_, Some("http://www.iab.com/VAST"), Some("AltText"), __scope, false) } getOrElse {Nil},
__obj.CompanionClickThrough map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("CompanionClickThrough"), __scope, false) } getOrElse {Nil},
__obj.CompanionClickTracking flatMap { scalaxb.toXML[CompanionClickTracking](_, Some("http://www.iab.com/VAST"), Some("CompanionClickTracking"), __scope, false) },
__obj.CreativeExtensions map { scalaxb.toXML[CreativeExtensions_type](_, Some("http://www.iab.com/VAST"), Some("CreativeExtensions"), __scope, false) } getOrElse {Nil},
__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil})
}
def build_RequiredFormat = new Default_RequiredFormat {}
trait Default_RequiredFormat extends scalaxb.XMLFormat[Required] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def fromString(value: String, scope: scala.xml.NamespaceBinding): Required = scalaxb.fromXML[String](scala.xml.Text(value)) match {
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("all")) => AllType
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("any")) => AnyType
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("none")) => NoneType
}
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Required] = seq match {
case elem: scala.xml.Elem => Right(fromString(elem.text, elem.scope))
case _ => Right(fromString(seq.text, scala.xml.TopScope))
}
def writes(__obj: Required, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq =
scala.xml.Elem(scalaxb.Helper.getPrefix(__namespace, __scope).orNull,
__elementLabel getOrElse { sys.error("missing element label.") },
scala.xml.Null, __scope, true, scala.xml.Text(__obj.toString))
}
trait Default_CompanionAds_Collection_typeFormat extends scalaxb.ElemNameParser[CompanionAds_Collection_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("CompanionAds_Collection_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[CompanionAds_Collection_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Companion")) ^^
{ case p1 =>
CompanionAds_Collection_type(p1 map { scalaxb.fromXML[CompanionAd_type](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@required").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Required](x, scalaxb.ElemName(node) :: stack)) } map { "@required" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: CompanionAds_Collection_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@required", _) => __obj.required foreach { x => attr = scala.xml.Attribute(null, "required", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: CompanionAds_Collection_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Companion flatMap { scalaxb.toXML[CompanionAd_type](_, Some("http://www.iab.com/VAST"), Some("Companion"), __scope, false) })
}
trait Default_Creative_Base_typableFormat extends scalaxb.XMLFormat[Creative_Base_typable] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Creative_Base_typable] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.iab.com/VAST"), Some("Creative_WrapperChild_type")) => Right(scalaxb.fromXML[Creative_WrapperChild_type](node, stack))
case (Some("http://www.iab.com/VAST"), Some("Creative_InlineChild_type")) => Right(scalaxb.fromXML[Creative_InlineChild_type](node, stack))
case _ => Right(scalaxb.fromXML[Creative_Base_type](node, stack))
}
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writes(__obj: Creative_Base_typable, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = __obj match {
case x: Creative_WrapperChild_type => scalaxb.toXML[Creative_WrapperChild_type](x, __namespace, __elementLabel, __scope, true)
case x: Creative_InlineChild_type => scalaxb.toXML[Creative_InlineChild_type](x, __namespace, __elementLabel, __scope, true)
case x: Creative_Base_type => scalaxb.toXML[Creative_Base_type](x, __namespace, __elementLabel, __scope, false)
}
}
trait Default_Creative_Base_typeFormat extends scalaxb.XMLFormat[Creative_Base_type] with scalaxb.CanWriteChildNodes[Creative_Base_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Creative_Base_type] = seq match {
case node: scala.xml.Node => Right(Creative_Base_type(scala.collection.immutable.ListMap(List(
(node \ "@sequence").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@sequence" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ },
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@adId").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@adId" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Creative_Base_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@sequence", _) => __obj.sequence foreach { x => attr = scala.xml.Attribute(null, "sequence", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@adId", _) => __obj.adId foreach { x => attr = scala.xml.Attribute(null, "adId", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Creative_Base_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Nil
}
trait Default_NonLinearAdsFormat extends scalaxb.ElemNameParser[NonLinearAds] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[NonLinearAds] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NonLinear")) ^^
{ case p1 ~ p2 =>
NonLinearAds(p1.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[NonLinearAd_Base_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: NonLinearAds, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil},
__obj.NonLinear flatMap { scalaxb.toXML[NonLinearAd_Base_type](_, Some("http://www.iab.com/VAST"), Some("NonLinear"), __scope, false) })
}
trait Default_Creative_WrapperChild_typeFormat extends scalaxb.ElemNameParser[Creative_WrapperChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Creative_WrapperChild_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Creative_WrapperChild_type] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "CompanionAds")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Linear")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NonLinearAds")) ^^
{ case p1 ~ p2 ~ p3 =>
Creative_WrapperChild_type(p1.headOption map { scalaxb.fromXML[CompanionAds_Collection_type](_, scalaxb.ElemName(node) :: stack) },
p2.headOption map { scalaxb.fromXML[Linear_WrapperChild_type](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[NonLinearAds](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@sequence").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@sequence" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ },
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@adId").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@adId" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Creative_WrapperChild_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@sequence", _) => __obj.sequence foreach { x => attr = scala.xml.Attribute(null, "sequence", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@adId", _) => __obj.adId foreach { x => attr = scala.xml.Attribute(null, "adId", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Creative_WrapperChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.CompanionAds map { scalaxb.toXML[CompanionAds_Collection_type](_, Some("http://www.iab.com/VAST"), Some("CompanionAds"), __scope, false) } getOrElse {Nil},
__obj.Linear map { scalaxb.toXML[Linear_WrapperChild_type](_, Some("http://www.iab.com/VAST"), Some("Linear"), __scope, false) } getOrElse {Nil},
__obj.NonLinearAds map { scalaxb.toXML[NonLinearAds](_, Some("http://www.iab.com/VAST"), Some("NonLinearAds"), __scope, false) } getOrElse {Nil})
}
trait Default_NonLinearAds2Format extends scalaxb.ElemNameParser[NonLinearAds2] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[NonLinearAds2] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "TrackingEvents")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NonLinear")) ^^
{ case p1 ~ p2 =>
NonLinearAds2(p1.headOption map { scalaxb.fromXML[TrackingEvents_type](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[NonLinearAd_InlineChild_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: NonLinearAds2, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.TrackingEvents map { scalaxb.toXML[TrackingEvents_type](_, Some("http://www.iab.com/VAST"), Some("TrackingEvents"), __scope, false) } getOrElse {Nil},
__obj.NonLinear flatMap { scalaxb.toXML[NonLinearAd_InlineChild_type](_, Some("http://www.iab.com/VAST"), Some("NonLinear"), __scope, false) })
}
trait Default_UniversalAdIdFormat extends scalaxb.XMLFormat[UniversalAdId] with scalaxb.CanWriteChildNodes[UniversalAdId] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, UniversalAdId] = seq match {
case node: scala.xml.Node => Right(UniversalAdId(scalaxb.fromXML[String](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@idRegistry").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@idRegistry" -> _ },
(node \ "@idValue").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@idValue" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: UniversalAdId, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@idRegistry", _) => attr = scala.xml.Attribute(null, "idRegistry", __obj.idRegistry.toString, attr)
case ("@idValue", _) => attr = scala.xml.Attribute(null, "idValue", __obj.idValue.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: UniversalAdId, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_Creative_InlineChild_typeFormat extends scalaxb.XMLFormat[Creative_InlineChild_type] with scalaxb.CanWriteChildNodes[Creative_InlineChild_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Creative_InlineChild_type] = seq match {
case node: scala.xml.Node => Right(Creative_InlineChild_type((node \ "CompanionAds").headOption map { scalaxb.fromXML[CompanionAds_Collection_type](_, scalaxb.ElemName(node) :: stack) },
(node \ "CreativeExtensions").headOption map { scalaxb.fromXML[CreativeExtensions_type](_, scalaxb.ElemName(node) :: stack) },
(node \ "Linear").headOption map { scalaxb.fromXML[Linear_InlineChild_type](_, scalaxb.ElemName(node) :: stack) },
(node \ "NonLinearAds").headOption map { scalaxb.fromXML[NonLinearAds2](_, scalaxb.ElemName(node) :: stack) },
(node \ "UniversalAdId").headOption map { scalaxb.fromXML[UniversalAdId](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@sequence").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[BigInt](x, scalaxb.ElemName(node) :: stack)) } map { "@sequence" -> _ },
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ },
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ },
(node \ "@adId").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@adId" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Creative_InlineChild_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@sequence", _) => __obj.sequence foreach { x => attr = scala.xml.Attribute(null, "sequence", x.toString, attr) }
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case ("@adId", _) => __obj.adId foreach { x => attr = scala.xml.Attribute(null, "adId", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Creative_InlineChild_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.CompanionAds map { scalaxb.toXML[CompanionAds_Collection_type](_, Some("http://www.iab.com/VAST"), Some("CompanionAds"), __scope, false) } getOrElse {Nil},
__obj.CreativeExtensions map { scalaxb.toXML[CreativeExtensions_type](_, Some("http://www.iab.com/VAST"), Some("CreativeExtensions"), __scope, false) } getOrElse {Nil},
__obj.Linear map { scalaxb.toXML[Linear_InlineChild_type](_, Some("http://www.iab.com/VAST"), Some("Linear"), __scope, false) } getOrElse {Nil},
__obj.NonLinearAds map { scalaxb.toXML[NonLinearAds2](_, Some("http://www.iab.com/VAST"), Some("NonLinearAds"), __scope, false) } getOrElse {Nil},
__obj.UniversalAdId map { scalaxb.toXML[UniversalAdId](_, Some("http://www.iab.com/VAST"), Some("UniversalAdId"), __scope, false) } getOrElse {Nil})
}
trait Default_AdSystemFormat extends scalaxb.XMLFormat[AdSystem] with scalaxb.CanWriteChildNodes[AdSystem] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, AdSystem] = seq match {
case node: scala.xml.Node => Right(AdSystem(scalaxb.fromXML[String](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@version").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@version" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: AdSystem, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@version", _) => __obj.version foreach { x => attr = scala.xml.Attribute(null, "version", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: AdSystem, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_ExtensionFormat extends scalaxb.ElemNameParser[Extension] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Extension] =
phrase(safeRep(any(_ => true)) ^^
{ case p1 =>
Extension(p1 map { scalaxb.fromXML[scalaxb.DataRecord[Any]](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@type").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@type" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Extension, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@type", _) => __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Extension, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.any flatMap { x => scalaxb.toXML[scalaxb.DataRecord[Any]](x, x.namespace, x.key, __scope, true) })
}
trait Default_ExtensionsFormat extends scalaxb.ElemNameParser[Extensions] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Extensions] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Extension")) ^^
{ case p1 =>
Extensions(p1 map { scalaxb.fromXML[Extension](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: Extensions, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Extension flatMap { scalaxb.toXML[Extension](_, Some("http://www.iab.com/VAST"), Some("Extension"), __scope, false) })
}
def build_ModelFormat = new Default_ModelFormat {}
trait Default_ModelFormat extends scalaxb.XMLFormat[Model] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def fromString(value: String, scope: scala.xml.NamespaceBinding): Model = scalaxb.fromXML[String](scala.xml.Text(value)) match {
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("CPC")) => CPC
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("CPM")) => CPM
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("CPE")) => CPE
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("CPV")) => CPV
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("cpc")) => CpcValue
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("cpm")) => CpmValue
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("cpe")) => CpeValue
case x: String if x == scalaxb.fromXML[String](scala.xml.Text("cpv")) => CpvValue
}
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Model] = seq match {
case elem: scala.xml.Elem => Right(fromString(elem.text, elem.scope))
case _ => Right(fromString(seq.text, scala.xml.TopScope))
}
def writes(__obj: Model, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq =
scala.xml.Elem(scalaxb.Helper.getPrefix(__namespace, __scope).orNull,
__elementLabel getOrElse { sys.error("missing element label.") },
scala.xml.Null, __scope, true, scala.xml.Text(__obj.toString))
}
trait Default_PricingFormat extends scalaxb.XMLFormat[Pricing] with scalaxb.CanWriteChildNodes[Pricing] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Pricing] = seq match {
case node: scala.xml.Node => Right(Pricing(scalaxb.fromXML[BigDecimal](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@model").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Model](x, scalaxb.ElemName(node) :: stack)) } map { "@model" -> _ },
(node \ "@currency").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@currency" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Pricing, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@model", _) => attr = scala.xml.Attribute(null, "model", __obj.model.toString, attr)
case ("@currency", _) => attr = scala.xml.Attribute(null, "currency", __obj.currency.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Pricing, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_AdDefinitionBase_typableFormat extends scalaxb.XMLFormat[AdDefinitionBase_typable] {
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, AdDefinitionBase_typable] = seq match {
case node: scala.xml.Node =>
scalaxb.Helper.instanceType(node) match {
case (Some("http://www.iab.com/VAST"), Some("Wrapper_type")) => Right(scalaxb.fromXML[Wrapper_type](node, stack))
case (Some("http://www.iab.com/VAST"), Some("Inline_type")) => Right(scalaxb.fromXML[Inline_type](node, stack))
case _ => Right(scalaxb.fromXML[AdDefinitionBase_type](node, stack))
}
case _ => Left("reads failed: seq must be scala.xml.Node")
}
def writes(__obj: AdDefinitionBase_typable, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq = __obj match {
case x: Wrapper_type => scalaxb.toXML[Wrapper_type](x, __namespace, __elementLabel, __scope, true)
case x: Inline_type => scalaxb.toXML[Inline_type](x, __namespace, __elementLabel, __scope, true)
case x: AdDefinitionBase_type => scalaxb.toXML[AdDefinitionBase_type](x, __namespace, __elementLabel, __scope, false)
}
}
trait Default_AdDefinitionBase_typeFormat extends scalaxb.ElemNameParser[AdDefinitionBase_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("AdDefinitionBase_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[AdDefinitionBase_type] =
phrase((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdSystem")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Error")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Extensions")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Impression")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Pricing")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewableImpression")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 =>
AdDefinitionBase_type(scalaxb.fromXML[AdSystem](p1, scalaxb.ElemName(node) :: stack),
p2.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[Extensions](_, scalaxb.ElemName(node) :: stack) },
p4 map { scalaxb.fromXML[Impression_type](_, scalaxb.ElemName(node) :: stack) },
p5.headOption map { scalaxb.fromXML[Pricing](_, scalaxb.ElemName(node) :: stack) },
p6.headOption map { scalaxb.fromXML[ViewableImpression_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: AdDefinitionBase_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(scalaxb.toXML[AdSystem](__obj.AdSystem, Some("http://www.iab.com/VAST"), Some("AdSystem"), __scope, false),
__obj.Error map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("Error"), __scope, false) } getOrElse {Nil},
__obj.Extensions map { scalaxb.toXML[Extensions](_, Some("http://www.iab.com/VAST"), Some("Extensions"), __scope, false) } getOrElse {Nil},
__obj.Impression flatMap { scalaxb.toXML[Impression_type](_, Some("http://www.iab.com/VAST"), Some("Impression"), __scope, false) },
__obj.Pricing map { scalaxb.toXML[Pricing](_, Some("http://www.iab.com/VAST"), Some("Pricing"), __scope, false) } getOrElse {Nil},
__obj.ViewableImpression map { scalaxb.toXML[ViewableImpression_type](_, Some("http://www.iab.com/VAST"), Some("ViewableImpression"), __scope, false) } getOrElse {Nil})
}
trait Default_ViewableImpression_typeFormat extends scalaxb.ElemNameParser[ViewableImpression_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("ViewableImpression_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[ViewableImpression_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Viewable")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "NotViewable")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewUndetermined")) ^^
{ case p1 ~ p2 ~ p3 =>
ViewableImpression_type(p1 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3 map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: ViewableImpression_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: ViewableImpression_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.Viewable flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("Viewable"), __scope, false) },
__obj.NotViewable flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("NotViewable"), __scope, false) },
__obj.ViewUndetermined flatMap { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("ViewUndetermined"), __scope, false) })
}
trait Default_ViewableImpressionFormat extends scalaxb.XMLFormat[ViewableImpression] with scalaxb.CanWriteChildNodes[ViewableImpression] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, ViewableImpression] = seq match {
case node: scala.xml.Node => Right(ViewableImpression(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: ViewableImpression, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: ViewableImpression, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_Verification_Wrapper_typeFormat extends scalaxb.ElemNameParser[Verification_Wrapper_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Verification_Wrapper_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Verification_Wrapper_type] =
phrase(opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewableImpression")) ^^
{ case p1 =>
Verification_Wrapper_type(p1.headOption map { scalaxb.fromXML[ViewableImpression](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@vendor").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@vendor" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Verification_Wrapper_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@vendor", _) => __obj.vendor foreach { x => attr = scala.xml.Attribute(null, "vendor", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Verification_Wrapper_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.ViewableImpression map { scalaxb.toXML[ViewableImpression](_, Some("http://www.iab.com/VAST"), Some("ViewableImpression"), __scope, false) } getOrElse {Nil})
}
trait Default_FlashResourceFormat extends scalaxb.XMLFormat[FlashResource] with scalaxb.CanWriteChildNodes[FlashResource] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, FlashResource] = seq match {
case node: scala.xml.Node => Right(FlashResource(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: FlashResource, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: FlashResource, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_JavaScriptResourceFormat extends scalaxb.XMLFormat[JavaScriptResource] with scalaxb.CanWriteChildNodes[JavaScriptResource] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, JavaScriptResource] = seq match {
case node: scala.xml.Node => Right(JavaScriptResource(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@apiFramework").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@apiFramework" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: JavaScriptResource, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@apiFramework", _) => __obj.apiFramework foreach { x => attr = scala.xml.Attribute(null, "apiFramework", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: JavaScriptResource, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_ViewableImpression2Format extends scalaxb.XMLFormat[ViewableImpression2] with scalaxb.CanWriteChildNodes[ViewableImpression2] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, ViewableImpression2] = seq match {
case node: scala.xml.Node => Right(ViewableImpression2(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@id").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@id" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: ViewableImpression2, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@id", _) => __obj.id foreach { x => attr = scala.xml.Attribute(null, "id", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: ViewableImpression2, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_Verification_Inline_typeFormat extends scalaxb.ElemNameParser[Verification_Inline_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Verification_Inline_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Verification_Inline_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "FlashResource")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "JavaScriptResource")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewableImpression")) ^^
{ case p1 ~ p2 ~ p3 =>
Verification_Inline_type(p1 map { scalaxb.fromXML[FlashResource](_, scalaxb.ElemName(node) :: stack) },
p2 map { scalaxb.fromXML[JavaScriptResource](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[ViewableImpression2](_, scalaxb.ElemName(node) :: stack) },
scala.collection.immutable.ListMap(List(
(node \ "@vendor").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@vendor" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Verification_Inline_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@vendor", _) => __obj.vendor foreach { x => attr = scala.xml.Attribute(null, "vendor", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Verification_Inline_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(__obj.FlashResource flatMap { scalaxb.toXML[FlashResource](_, Some("http://www.iab.com/VAST"), Some("FlashResource"), __scope, false) },
__obj.JavaScriptResource flatMap { scalaxb.toXML[JavaScriptResource](_, Some("http://www.iab.com/VAST"), Some("JavaScriptResource"), __scope, false) },
__obj.ViewableImpression map { scalaxb.toXML[ViewableImpression2](_, Some("http://www.iab.com/VAST"), Some("ViewableImpression"), __scope, false) } getOrElse {Nil})
}
trait Default_AdVerifications_Wrapper_typeFormat extends scalaxb.ElemNameParser[AdVerifications_Wrapper_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("AdVerifications_Wrapper_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[AdVerifications_Wrapper_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Verification")) ^^
{ case p1 =>
AdVerifications_Wrapper_type(p1 map { scalaxb.fromXML[Verification_Wrapper_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: AdVerifications_Wrapper_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Verification flatMap { scalaxb.toXML[Verification_Wrapper_type](_, Some("http://www.iab.com/VAST"), Some("Verification"), __scope, false) })
}
trait Default_AdVerifications_Inline_typeFormat extends scalaxb.ElemNameParser[AdVerifications_Inline_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("AdVerifications_Inline_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[AdVerifications_Inline_type] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Verification")) ^^
{ case p1 =>
AdVerifications_Inline_type(p1 map { scalaxb.fromXML[Verification_Inline_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: AdVerifications_Inline_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Verification flatMap { scalaxb.toXML[Verification_Inline_type](_, Some("http://www.iab.com/VAST"), Some("Verification"), __scope, false) })
}
trait Default_CreativesFormat extends scalaxb.ElemNameParser[Creatives] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Creatives] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Creative")) ^^
{ case p1 =>
Creatives(p1 map { scalaxb.fromXML[Creative_WrapperChild_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: Creatives, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Creative flatMap { scalaxb.toXML[Creative_WrapperChild_type](_, Some("http://www.iab.com/VAST"), Some("Creative"), __scope, false) })
}
trait Default_Wrapper_typeFormat extends scalaxb.ElemNameParser[Wrapper_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Wrapper_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Wrapper_type] =
phrase((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdSystem")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Error")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Extensions")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Impression")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Pricing")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewableImpression")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdVerifications")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Creatives")) ~
(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "VASTAdTagURI")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 ~ p7 ~ p8 ~ p9 =>
Wrapper_type(scalaxb.fromXML[AdSystem](p1, scalaxb.ElemName(node) :: stack),
p2.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[Extensions](_, scalaxb.ElemName(node) :: stack) },
p4 map { scalaxb.fromXML[Impression_type](_, scalaxb.ElemName(node) :: stack) },
p5.headOption map { scalaxb.fromXML[Pricing](_, scalaxb.ElemName(node) :: stack) },
p6.headOption map { scalaxb.fromXML[ViewableImpression_type](_, scalaxb.ElemName(node) :: stack) },
p7.headOption map { scalaxb.fromXML[AdVerifications_Wrapper_type](_, scalaxb.ElemName(node) :: stack) },
p8.headOption map { scalaxb.fromXML[Creatives](_, scalaxb.ElemName(node) :: stack) },
scalaxb.fromXML[java.net.URI](p9, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@followAdditionalWrappers").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@followAdditionalWrappers" -> _ },
(node \ "@allowMultipleAds").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@allowMultipleAds" -> _ },
(node \ "@fallbackOnNoAd").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[Boolean](x, scalaxb.ElemName(node) :: stack)) } map { "@fallbackOnNoAd" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)) })
override def writesAttribute(__obj: Wrapper_type, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@followAdditionalWrappers", _) => __obj.followAdditionalWrappers foreach { x => attr = scala.xml.Attribute(null, "followAdditionalWrappers", x.toString, attr) }
case ("@allowMultipleAds", _) => __obj.allowMultipleAds foreach { x => attr = scala.xml.Attribute(null, "allowMultipleAds", x.toString, attr) }
case ("@fallbackOnNoAd", _) => __obj.fallbackOnNoAd foreach { x => attr = scala.xml.Attribute(null, "fallbackOnNoAd", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Wrapper_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(scalaxb.toXML[AdSystem](__obj.AdSystem, Some("http://www.iab.com/VAST"), Some("AdSystem"), __scope, false),
__obj.Error map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("Error"), __scope, false) } getOrElse {Nil},
__obj.Extensions map { scalaxb.toXML[Extensions](_, Some("http://www.iab.com/VAST"), Some("Extensions"), __scope, false) } getOrElse {Nil},
__obj.Impression flatMap { scalaxb.toXML[Impression_type](_, Some("http://www.iab.com/VAST"), Some("Impression"), __scope, false) },
__obj.Pricing map { scalaxb.toXML[Pricing](_, Some("http://www.iab.com/VAST"), Some("Pricing"), __scope, false) } getOrElse {Nil},
__obj.ViewableImpression map { scalaxb.toXML[ViewableImpression_type](_, Some("http://www.iab.com/VAST"), Some("ViewableImpression"), __scope, false) } getOrElse {Nil},
__obj.AdVerifications map { scalaxb.toXML[AdVerifications_Wrapper_type](_, Some("http://www.iab.com/VAST"), Some("AdVerifications"), __scope, false) } getOrElse {Nil},
__obj.Creatives map { scalaxb.toXML[Creatives](_, Some("http://www.iab.com/VAST"), Some("Creatives"), __scope, false) } getOrElse {Nil},
scalaxb.toXML[java.net.URI](__obj.VASTAdTagURI, Some("http://www.iab.com/VAST"), Some("VASTAdTagURI"), __scope, false))
}
trait Default_CategoryFormat extends scalaxb.XMLFormat[Category] with scalaxb.CanWriteChildNodes[Category] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Category] = seq match {
case node: scala.xml.Node => Right(Category(scalaxb.fromXML[String](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@authority").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[java.net.URI](x, scalaxb.ElemName(node) :: stack)) } map { "@authority" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Category, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@authority", _) => attr = scala.xml.Attribute(null, "authority", __obj.authority.toString, attr)
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Category, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_Creatives2Format extends scalaxb.ElemNameParser[Creatives2] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Creatives2] =
phrase(safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Creative")) ^^
{ case p1 =>
Creatives2(p1 map { scalaxb.fromXML[Creative_InlineChild_type](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: Creatives2, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
(__obj.Creative flatMap { scalaxb.toXML[Creative_InlineChild_type](_, Some("http://www.iab.com/VAST"), Some("Creative"), __scope, false) })
}
trait Default_SurveyFormat extends scalaxb.XMLFormat[Survey] with scalaxb.CanWriteChildNodes[Survey] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
import scalaxb.ElemName._
def reads(seq: scala.xml.NodeSeq, stack: List[scalaxb.ElemName]): Either[String, Survey] = seq match {
case node: scala.xml.Node => Right(Survey(scalaxb.fromXML[java.net.URI](node, scalaxb.ElemName(node) :: stack),
scala.collection.immutable.ListMap(List(
(node \ "@type").headOption map { x => scalaxb.DataRecord(x, node, scalaxb.fromXML[String](x, scalaxb.ElemName(node) :: stack)) } map { "@type" -> _ }
).flatten[(String, scalaxb.DataRecord[Any])]: _*)))
case _ => Left("reads failed: seq must be scala.xml.Node")
}
override def writesAttribute(__obj: Survey, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.attributes.toList map {
case ("@type", _) => __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", x.toString, attr) }
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr)
}
attr
}
def writesChildNodes(__obj: Survey, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq(scala.xml.Text(__obj.value.toString))
}
trait Default_Inline_typeFormat extends scalaxb.ElemNameParser[Inline_type] {
val targetNamespace: Option[String] = Some("http://www.iab.com/VAST")
override def typeName: Option[String] = Some("Inline_type")
def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[Inline_type] =
phrase((scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdSystem")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Error")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Extensions")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Impression")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Pricing")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "ViewableImpression")) ~
(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdTitle")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "AdVerifications")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Advertiser")) ~
safeRep(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Category")) ~
(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Creatives")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Description")) ~
opt(scalaxb.ElemName(Some("http://www.iab.com/VAST"), "Survey")) ^^
{ case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 ~ p7 ~ p8 ~ p9 ~ p10 ~ p11 ~ p12 ~ p13 =>
Inline_type(scalaxb.fromXML[AdSystem](p1, scalaxb.ElemName(node) :: stack),
p2.headOption map { scalaxb.fromXML[java.net.URI](_, scalaxb.ElemName(node) :: stack) },
p3.headOption map { scalaxb.fromXML[Extensions](_, scalaxb.ElemName(node) :: stack) },
p4 map { scalaxb.fromXML[Impression_type](_, scalaxb.ElemName(node) :: stack) },
p5.headOption map { scalaxb.fromXML[Pricing](_, scalaxb.ElemName(node) :: stack) },
p6.headOption map { scalaxb.fromXML[ViewableImpression_type](_, scalaxb.ElemName(node) :: stack) },
scalaxb.fromXML[String](p7, scalaxb.ElemName(node) :: stack),
p8.headOption map { scalaxb.fromXML[AdVerifications_Inline_type](_, scalaxb.ElemName(node) :: stack) },
p9.headOption map { scalaxb.fromXML[String](_, scalaxb.ElemName(node) :: stack) },
p10 map { scalaxb.fromXML[Category](_, scalaxb.ElemName(node) :: stack) },
scalaxb.fromXML[Creatives2](p11, scalaxb.ElemName(node) :: stack),
p12.headOption map { scalaxb.fromXML[String](_, scalaxb.ElemName(node) :: stack) },
p13.headOption map { scalaxb.fromXML[Survey](_, scalaxb.ElemName(node) :: stack) }) })
def writesChildNodes(__obj: Inline_type, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
Seq.concat(scalaxb.toXML[AdSystem](__obj.AdSystem, Some("http://www.iab.com/VAST"), Some("AdSystem"), __scope, false),
__obj.Error map { scalaxb.toXML[java.net.URI](_, Some("http://www.iab.com/VAST"), Some("Error"), __scope, false) } getOrElse {Nil},
__obj.Extensions map { scalaxb.toXML[Extensions](_, Some("http://www.iab.com/VAST"), Some("Extensions"), __scope, false) } getOrElse {Nil},
__obj.Impression flatMap { scalaxb.toXML[Impression_type](_, Some("http://www.iab.com/VAST"), Some("Impression"), __scope, false) },
__obj.Pricing map { scalaxb.toXML[Pricing](_, Some("http://www.iab.com/VAST"), Some("Pricing"), __scope, false) } getOrElse {Nil},
__obj.ViewableImpression map { scalaxb.toXML[ViewableImpression_type](_, Some("http://www.iab.com/VAST"), Some("ViewableImpression"), __scope, false) } getOrElse {Nil},
scalaxb.toXML[String](__obj.AdTitle, Some("http://www.iab.com/VAST"), Some("AdTitle"), __scope, false),
__obj.AdVerifications map { scalaxb.toXML[AdVerifications_Inline_type](_, Some("http://www.iab.com/VAST"), Some("AdVerifications"), __scope, false) } getOrElse {Nil},
__obj.Advertiser map { scalaxb.toXML[String](_, Some("http://www.iab.com/VAST"), Some("Advertiser"), __scope, false) } getOrElse {Nil},
__obj.Category flatMap { scalaxb.toXML[Category](_, Some("http://www.iab.com/VAST"), Some("Category"), __scope, false) },
scalaxb.toXML[Creatives2](__obj.Creatives, Some("http://www.iab.com/VAST"), Some("Creatives"), __scope, false),
__obj.Description map { scalaxb.toXML[String](_, Some("http://www.iab.com/VAST"), Some("Description"), __scope, false) } getOrElse {Nil},
__obj.Survey map { scalaxb.toXML[Survey](_, Some("http://www.iab.com/VAST"), Some("Survey"), __scope, false) } getOrElse {Nil})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment