New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple types with enumeration restriction should preserve their types #208

Open
eed3si9n opened this Issue Apr 13, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@eed3si9n
Owner

eed3si9n commented Apr 13, 2013

steps

  1. compile a restriction of QName with enumeration.
  <xs:simpleType name="faultcodeEnum">
    <xs:restriction base="xs:QName">
      <xs:enumeration value="tns:DataEncodingUnknown"/>
      <xs:enumeration value="tns:MustUnderstand"/>
      <xs:enumeration value="tns:Receiver"/>
      <xs:enumeration value="tns:Sender"/>
      <xs:enumeration value="tns:VersionMismatch"/>
    </xs:restriction>
  </xs:simpleType>

problem

scalaxb 1.0 parses all values from String and maps them to case objects:

trait FaultcodeEnum

object FaultcodeEnum {
  def fromString(value: String): FaultcodeEnum = value match {
    case "tns:DataEncodingUnknown" => TnsDataEncodingUnknown
    case "tns:MustUnderstand" => TnsMustUnderstand
    case "tns:Receiver" => TnsReceiver
    case "tns:Sender" => TnsSender
    case "tns:VersionMismatch" => TnsVersionMismatch

  }
}

case object TnsDataEncodingUnknown extends FaultcodeEnum { override def toString = "tns:DataEncodingUnknown" }
case object TnsMustUnderstand extends FaultcodeEnum { override def toString = "tns:MustUnderstand" }
case object TnsReceiver extends FaultcodeEnum { override def toString = "tns:Receiver" }
case object TnsSender extends FaultcodeEnum { override def toString = "tns:Sender" }
case object TnsVersionMismatch extends FaultcodeEnum { override def toString = "tns:VersionMismatch" }

This is incorrect for QName since the prefix binding could be any value.

expectation

  1. Ideally FaultcodeEnum should map to its natural mapped type javax.xml.namespace.QName. During parsing time, it should check if the presented value is one of the enumerated values.
  2. In the short term, at least provide a workaround for QName.

eed3si9n added a commit that referenced this issue Apr 13, 2013

eed3si9n added a commit that referenced this issue Apr 14, 2013

eed3si9n added a commit that referenced this issue Apr 18, 2013

eed3si9n added a commit that referenced this issue May 20, 2013

eed3si9n added a commit that referenced this issue May 20, 2013

eed3si9n added a commit that referenced this issue May 26, 2013

eed3si9n added a commit that referenced this issue May 26, 2013

eed3si9n added a commit that referenced this issue Jul 18, 2013

eed3si9n added a commit that referenced this issue Jul 18, 2013

eed3si9n added a commit that referenced this issue Jul 28, 2013

eed3si9n added a commit that referenced this issue Jul 28, 2013

eed3si9n added a commit that referenced this issue Sep 12, 2013

eed3si9n added a commit that referenced this issue Sep 12, 2013

eed3si9n added a commit that referenced this issue Nov 8, 2014

eed3si9n added a commit that referenced this issue Nov 8, 2014

eed3si9n added a commit that referenced this issue Jul 7, 2016

eed3si9n added a commit that referenced this issue Jul 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment