Search code examples
xmlscalaxsddatabricksxsd-validation

XSD: Getting error while loading XSD file


val schemaParsed = XSDToSchema.read(Paths.get("/FileStore/tables/file.xsd"))

It is giving me an error FileNotFoundException: /FileStore/tables/file.xsd (No such file or directory)

But I have stored this .xsd file in this dir.already

any suggestion ?

enter image description here

"DBFS File browser enabled"

"Error"


Solution

  • Please check the existence of the file

    enter image description here

    Read the file as shown in the spark-xml github page.

    import com.databricks.spark.xml.util.XSDToSchema
    import java.nio.file.Paths
    
    val schemaParsed = XSDToSchema.read(Paths.get("/dbfs/FileStore/tables/xsd/purchase_order_sample.xsd"))
    print(schemaParsed)
    

    Please note that when used within the code, the dbfs path is mentioned as /dbfs/ instead of dbfs:/ Please go through the link to understand further...

    enter image description here