Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

ref attribute in XSDToSchema #617

@shuch3ng

Description

@shuch3ng

I tried to parse the Example 3 from https://www.w3schools.com/xml/el_element.asp

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="to"/>
      <xs:element ref="from"/>
      <xs:element ref="heading"/>
      <xs:element ref="body"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>

</xs:schema>

and got the following exception

Unsupported schema element type: null
java.lang.IllegalArgumentException: Unsupported schema element type: null
	at com.databricks.spark.xml.util.XSDToSchema$.getStructField(XSDToSchema.scala:216)
	at com.databricks.spark.xml.util.XSDToSchema$.$anonfun$getStructField$4(XSDToSchema.scala:182)
	at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:293)
	at scala.collection.Iterator.foreach(Iterator.scala:943)
	at scala.collection.Iterator.foreach$(Iterator.scala:943)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
	at scala.collection.TraversableLike.flatMap(TraversableLike.scala:293)
	at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:290)
	at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
	at com.databricks.spark.xml.util.XSDToSchema$.getStructField(XSDToSchema.scala:173)
	at com.databricks.spark.xml.util.XSDToSchema$.$anonfun$getStructType$1(XSDToSchema.scala:227)
	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
	at scala.collection.TraversableLike.map(TraversableLike.scala:286)
	at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
	at scala.collection.AbstractTraversable.map(Traversable.scala:108)
	at com.databricks.spark.xml.util.XSDToSchema$.getStructType(XSDToSchema.scala:221)
	at com.databricks.spark.xml.util.XSDToSchema$.read(XSDToSchema.scala:49)
	at com.databricks.spark.xml.util.XSDToSchema$.read(XSDToSchema.scala:61)

It's caused by the elements inside the complexType not having the schemaType and hence null is passed into the getStructField function in Line 182 XSDToSchema.scala

val baseType = getStructField(xmlSchema, e.getSchemaType).dataType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions