From 2706e8f206b1fa99bafc752e84e87ca794100839 Mon Sep 17 00:00:00 2001 From: scorebot <50666204+scorebot@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:13:05 -0700 Subject: [PATCH] Fix the error of parsing some special XML --- src/main/scala/org/pmml4s/xml/pull.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/scala/org/pmml4s/xml/pull.scala b/src/main/scala/org/pmml4s/xml/pull.scala index a223771..44bf2f7 100644 --- a/src/main/scala/org/pmml4s/xml/pull.scala +++ b/src/main/scala/org/pmml4s/xml/pull.scala @@ -16,7 +16,7 @@ package org.pmml4s.xml -import javax.xml.stream.events.{Characters, Comment, EndElement, EntityReference, ProcessingInstruction, StartElement} +import javax.xml.stream.events.{Characters, Comment, EndElement, EntityReference, ProcessingInstruction, StartElement, EndDocument} import javax.xml.stream.{EventFilter, XMLInputFactory, XMLStreamConstants} import scala.io.Source import XmlImplicits._ @@ -74,6 +74,11 @@ case class EvComment(text: String) extends XMLEvent */ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBinding) +/** + * The end of document + */ +case object EvDocEnd extends XMLEvent + /** * Main entry point into creating an event-based XML parser. Treating this * as a [[scala.collection.Iterator]] will provide access to the generated events. @@ -108,6 +113,7 @@ class XMLEventReader(src: Source) EvProcInstr(ev.getTarget, ev.getData) case ev: Comment => EvComment(ev.getText) + case ev: EndDocument => EvDocEnd } }