Bastl | 4 May 2012 11:03

parsing list of files

Hi

this is a repost of my question at stackoverflow http://stackoverflow.com/questions/10444188/parsing-a-list-of-xml-files-with-scala.

As I guess that something weird is going on, asking the experts might be better. Here we go:

----

I have a list of files (produced by find). I read this file, line by line, and call XML.loadFile(line) and subsequently my own simple "fromXML" method on the resulting XML-element.

The for/yield that goes through the lines dies with "The processing instruction target matching "[xX][mM][lL]" is not allowed." for one of the files (reproducible). Note, that the xml-file in question works fine (with XML.loadFile and fromXML) when treated individually.

To me this sounds like a nasty side-effect in otherwise pure code. Could it be that some InputStream is reused somehow ?

Thanks, Sebastian.
 
Exception in thread "main" org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
  at com
.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
  at com
.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
  at com
.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
  at com
.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
  at com
.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(XMLScanner.java:701)
  at com
.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(XMLDocumentFragmentScannerImpl.java:1020)
  at com
.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(XMLScanner.java:669)
  at com
.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:954)
  at com
.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
  at com
.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
  at com
.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
  at com
.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
  at com
.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
  at com
.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
  at javax
.xml.parsers.SAXParser.parse(SAXParser.java:395)
  at scala
.xml.factory.XMLLoader$class.loadXML(XMLLoader.scala:40)
  at scala
.xml.XML$.loadXML(XML.scala:40)
  at scala
.xml.factory.XMLLoader$class.loadFile(XMLLoader.scala:49)
  at scala
.xml.XML$.loadFile(XML.scala:40)
  at de
.company.scala.mvndeps.Cli$$anonfun$fs2ms$1.apply(Cli.scala:17)
  at de
.company.scala.mvndeps.Cli$$anonfun$fs2ms$1.apply(Cli.scala:16)
  at scala
.collection.Iterator$$anon$19.next(Iterator.scala:401)
  at scala
.collection.Iterator$$anon$19.next(Iterator.scala:401)
  at scala
.collection.Iterator$class.foreach(Iterator.scala:772)
  at scala
.collection.Iterator$$anon$19.foreach(Iterator.scala:399)
  at scala
.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
  at scala
.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:130)
  at scala
.collection.TraversableOnce$class.toList(TraversableOnce.scala:242)
  at scala
.collection.Iterator$$anon$19.toList(Iterator.scala:399)
  at de
.company.scala.mvndeps.Cli$.fs2ms(Cli.scala:23)
  at de
.company.scala.mvndeps.Cli$delayedInit$body.apply(Cli.scala:26)
  at scala
.Function0$class.apply$mcV$sp(Function0.scala:34)
Scala Mailing Lists | 21 May 2012 15:32
Picon
Picon
Favicon

Mailing list reminder: Scala-xml

Welcome to the "Scala-xml" mailing list.

This automatic reminder is sent once a month to the list,
to keep subscribers up-to-date with the mailing list services,
and to help keeping the list on topic.

-------------------------------------------------------------------

The "Scala-xml" mailing list:

This is the main interest list for coders interested in using
the XML manipulation capabilities of Scala.

Topics appropriate to this list include:

 * The Scala XML infrastructure, bugs, development
 * How to use the Scala XML features while writing code

Use this list to discuss any topic related to the Scala/XML
interoperability.

-------------------------------------------------------------------

Other information:

There are several Scala lists devoted to individual topics (and
more may be created in the future). For the full list, please
see: http://www.scala-lang.org/node/199

Try to avoid cross-posting whenever possible. If you can, select
the list that is closer to your topic and post in that list only.
In any case, never cross-post replies.

If you ever want to unsubscribe from this list, just visit this
page: http://groups.google.com/group/scala-xml/subscribe
or send an email to scala-xml+unsubscribe@...

Thank you!
The Scala Team


Gmane