Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:54:43+00:00 2026-06-08T21:54:43+00:00

The documentation for scala.xml.pull.XMLEventReader mentions it can be used as an Iterator[XMLEvent] . However,

  • 0

The documentation for scala.xml.pull.XMLEventReader mentions it can be used as an Iterator[XMLEvent]. However, when doing so, XML errors lead to method calls not terminating. For example:

scala> new xml.pull.XMLEventReader(io.Source.fromString("<a><b></a>")).toArray
Exception in thread "XMLEventReader" scala.xml.parsing.FatalError: expected closing tag of b
    at scala.xml.parsing.MarkupParser$class.errorNoEnd(MarkupParser.scala:41)
    at scala.xml.pull.XMLEventReader$Parser.errorNoEnd(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParserCommon$class.xEndTag(MarkupParserCommon.scala:93)
    at scala.xml.pull.XMLEventReader$Parser.xEndTag(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.element1(MarkupParser.scala:543)
    at scala.xml.pull.XMLEventReader$Parser.element1(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.content1(MarkupParser.scala:396)
    at scala.xml.pull.XMLEventReader$Parser.content1(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.content(MarkupParser.scala:417)
    at scala.xml.pull.XMLEventReader$Parser.content(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.element1(MarkupParser.scala:542)
    at scala.xml.pull.XMLEventReader$Parser.element1(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.content1(MarkupParser.scala:396)
    at scala.xml.pull.XMLEventReader$Parser.content1(XMLEventReader.scala:56)
    at scala.xml.parsing.MarkupParser$class.document(MarkupParser.scala:216)
    at scala.xml.pull.XMLEventReader$Parser.document(XMLEventReader.scala:56)
    at scala.xml.pull.XMLEventReader$Parser$$anonfun$run$1.apply(XMLEventReader.scala:90)
    at scala.xml.pull.XMLEventReader$Parser$$anonfun$run$1.apply(XMLEventReader.scala:90)
    at scala.xml.pull.ProducerConsumerIterator$class.interruptibly(XMLEventReader.scala:113)
    at scala.xml.pull.XMLEventReader.interruptibly(XMLEventReader.scala:26)
    at scala.xml.pull.XMLEventReader$Parser.run(XMLEventReader.scala:90)
    at java.lang.Thread.run(Thread.java:680)

This call never terminates. We see here that the parse exception is printed but it doesn’t appear to interrupt the call to toArray. This seems to be because the actual parsing happens in a separate thread, which is terminated, however the error is never reported to the calling thread (this is described in the issue SI-4267). Is it possible to somehow have these exceptions re-raised on the calling thread? Is this class even intended to be used, or is there another pull parser I should be using?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:54:45+00:00Added an answer on June 8, 2026 at 9:54 pm

    If you are looking for pull parsing and Scala you should probably checkout Scales Xml.

    In particular for this case pull parsing is driven by actual pull parsers (jdk stax) and the actual XMLInputFactory used can be plugged in allowing you to customise error handling or document processing as per the stax standard api.

    Add to that the ability to parse by both Iterator and Iteratee and you’ve got a lot of flexibility on how you handle a document.

    The next version 0.5 will also attempt to use Aalto XML to provide fully asynchronous processing.

    Your actual example converts to:

    import scales.xml._
    import ScalesXml._
    
    try{
      val s = pullXml(new java.io.StringReader("<a><b></a>")).toArray
    } finally {
      println("Same thread")
    }
    

    and runs as (saved in experiments.scalaScript and loaded via the repl):

    scala> :load .\experiments.scalaScript
    Loading .\experiments.scalaScript...
    import scales.xml._
    import ScalesXml._
    Same thread
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,9]
    Message: The element type "b" must be terminated by the matching end-tag "</b>".
            at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:594)
    

    For more examples of pull parsing see here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Documentation for data.xml/parse says The data is returned as defrecords and can be manipulated
I am trying to find the documentation for the Scala operator method #:: .
Can Scala be used to script a Java application? I need to load a
I can't seem to find documentation regarding the ability to scale axes in a
The documentation states: Precision can range from 1 to 38. Scale can range from
I'd love some advice on how best to autogenerate documentation for a mixed Java/Scala
One of the nice advantages of Scala is the way you can be type
I noticed that scala.xml.Atom takes a type parameter A , even though all of
There are many ways functions can be defined in Scala, which leads to confusion
In Matlab documentation for function fminsearch(fun,x0) , x0 can be a scalar, vector, or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.