Skip to content

Commit

Permalink
fixes split xs:sequence whose only item is nillable and unbounded. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Feb 24, 2013
1 parent 0c815de commit 75ddc8e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cli/src/main/scala/scalaxb/compiler/xsd/GenSource.scala
Expand Up @@ -430,11 +430,12 @@ abstract class GenSource(val schema: SchemaDecl,
Snippet(<source>trait {localName}{superString}</source>)
}

def makeSequence(seq: SequenceDecl): Snippet = {
def makeSequence(seq: SequenceDecl): Snippet = {
val localName = makeTypeName(context.compositorNames(seq))
val fqn = buildFullyQualifiedName(schema, localName)
val formatterName = buildFormatterName(schema.targetNamespace, localName)

logger.debug("makeSequence: emitting " + fqn)

// pass in local name for the family.
// since the sequence is already split at this point, it does not require resplitting.
val particles = flattenElements(schema.targetNamespace, List(localName), seq, 0, false)
Expand All @@ -443,7 +444,7 @@ abstract class GenSource(val schema: SchemaDecl,
(paramList.head.cardinality == Multiple) &&
(!paramList.head.attribute)
val paramsString = if (hasSequenceParam)
makeParamName(paramList.head.name, false) + ": " + buildTypeName(paramList.head.typeSymbol) + "*"
makeParamName(paramList.head.name, false) + ": " + paramList.head.singleTypeName + "*"
else paramList.map(_.toScalaCode).mkString("," + newline + indent(1))
def makeWritesXML = <source> def writes(__obj: {fqn}, __namespace: Option[String], __elementLabel: Option[String],
__scope: scala.xml.NamespaceBinding, __typeAttribute: Boolean): scala.xml.NodeSeq =
Expand Down Expand Up @@ -472,7 +473,8 @@ abstract class GenSource(val schema: SchemaDecl,
val localName = makeTypeName(context.compositorNames(group))
val fqn = buildFullyQualifiedName(schema, localName)
val formatterName = buildFormatterName(group.namespace, localName)

logger.debug("makeGroup: emitting " + fqn)

val compositor = primaryCompositor(group)
val param = buildParam(compositor)
val o = buildOccurrence(compositor).toSingle
Expand Down Expand Up @@ -514,7 +516,8 @@ abstract class GenSource(val schema: SchemaDecl,
val localName = buildTypeName(group, true)
val fqn = buildTypeName(group, false)
val formatterName = buildFormatterName(group.namespace, localName)

logger.debug("makeAttributeGroup: emitting " + fqn)

val attributes = flattenAttributes(group.attributes)
val paramList = attributes map { buildParam }
val argList = attributes map {
Expand Down
27 changes: 27 additions & 0 deletions integration/src/test/resources/general.xsd
Expand Up @@ -232,6 +232,33 @@
</xs:sequence>
</xs:complexType>

<!-- must be exactly 21 elements -->
<xs:complexType name="LongSequenceOfNillableTest">
<xs:sequence>
<xs:element name="string1" type="xs:string"/>
<xs:element name="string2" type="xs:string"/>
<xs:element name="string3" type="xs:string"/>
<xs:element name="string4" type="xs:string"/>
<xs:element name="string5" type="xs:string"/>
<xs:element name="string6" type="xs:string"/>
<xs:element name="string7" type="xs:string"/>
<xs:element name="string8" type="xs:string"/>
<xs:element name="string9" type="xs:string"/>
<xs:element name="string10" type="xs:string"/>
<xs:element name="string11" type="xs:string"/>
<xs:element name="string12" type="xs:string"/>
<xs:element name="string13" type="xs:string"/>
<xs:element name="string14" type="xs:string"/>
<xs:element name="string15" type="xs:string"/>
<xs:element name="string16" type="xs:string"/>
<xs:element name="string17" type="xs:string"/>
<xs:element name="string18" type="xs:string"/>
<xs:element name="string19" type="xs:string"/>
<xs:element name="string20" type="xs:string"/>
<xs:element name="person" type="gen:Person" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="EmptyChoiceGroupTest">
<xs:choice>
<xs:group ref="gen:emptySeqGroup"/>
Expand Down
2 changes: 2 additions & 0 deletions notes/1.0.2.markdown
Expand Up @@ -6,11 +6,13 @@
- Fixes handling of enum values that are symbols. [#191][191]
- Fixes `xs:group` references naming conflict. [#192][192]
- Fixes `xs:choice` that's made up of a foreign type. [#193][193]
- Fixes split `xs:sequence` whose only item is nillable and unbounded. [#194][194]

[188]: https://github.com/eed3si9n/scalaxb/pull/188
[189]: https://github.com/eed3si9n/scalaxb/pull/189
[190]: https://github.com/eed3si9n/scalaxb/pull/190
[191]: https://github.com/eed3si9n/scalaxb/pull/191
[192]: https://github.com/eed3si9n/scalaxb/pull/192
[193]: https://github.com/eed3si9n/scalaxb/pull/193
[194]: https://github.com/eed3si9n/scalaxb/pull/194
[@workingDog]: https://github.com/workingDog

0 comments on commit 75ddc8e

Please sign in to comment.