ConstructingParser: Could not load valid XML document from File

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ConstructingParser: Could not load valid XML document from File

Harit Himanshu
my XML looks like

 $cat /tmp/person.xml
 <root xmlns="http://www.nyorg.com/metadata/config" xmlns:core="http://www.myorg.com/metadata/commonschematypes" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xschema/AppConfig.xsd">
    <!-- This is important comment about person-->
    <person>
      <firstName>John</firstName>
      <lastName>Doe</lastName>
      <email>[hidden email]</email>
      <city>SomeWhere</city>
      <property name="myName" value="someValue" />
    </person>
  </root>

I try to load it as

val source = io.Source.fromURL(new java.io.File("/tmp/person.xml").toURL)
val d = scala.xml.parsing.ConstructingParser.fromSource(source, preserveWS = true)
val doc = d.document()
What I see is

:1:1: < expected<root xmlns="http://www.nyorg.com/metadata/config" xmlns:core="http://www.myorg.com/metadata/commonschematypes" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xschema/AppConfig.xsd">^
doc: scala.xml.Document = null


On the other hand when I try to load it with XML.loadFile, it works

val doc = XML.loadFile("/tmp/person.xml")
println(doc)  

I see

<root xsi:noNamespaceSchemaLocation="../xschema/AppConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:core="http://www.myorg.com/metadata/commonschematypes" xmlns="http://www.nyorg.com/metadata/config">

    <person>
      <firstName>John</firstName>
      <lastName>Doe</lastName>
      <email>[hidden email]</email>
      <city>SomeWhere</city>
      <property value="someValue" name="myName"/>
    </person>
  </root>

What am I doing wrong with ConstructingParser?


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.