Packages

  • package root
    Definition Classes
    root
  • package scala
    Definition Classes
    root
  • package xml

    This library provides support for the XML literal syntax in Scala programs.

    This library provides support for the XML literal syntax in Scala programs.

    val planets: scala.xml.Elem = <planets>
      <planet id="earth">
        <title>Earth</title>
        <mass unit="kg">5.9742e24</mass>
        <radius unit="m">6378.14e3</radius>
      </planet>
      <planet id="mars">
        <title>Mars</title>
        <mass unit="kg">0.64191e24</mass>
        <radius unit="m">3397.0e3</radius>
      </planet>
    </planets>

    Additionally, you can mix Scala expressions in your XML elements by using the curly brace notation:

    val sunMass = 1.99e30
    val sunRadius = 6.96e8
    val star = <star>
      <title>Sun</title>
      <mass unit="kg">{ sunMass }</mass>
      <radius unit="m">{ sunRadius }</radius>
      <surface unit="m²">{ 4 * Math.PI * Math.pow(sunRadius, 2) }</surface>
      <volume unit="m³">{ 4/3 * Math.PI * Math.pow(sunRadius, 3) }</volume>
    </star>

    An XML element, for example <star/> and <planet/>, is represented in this library as a case class, scala.xml.Elem.

    The sub-elements of XML values share a common base class, scala.xml.Node.

    However, the non-element declarations found in XML files share a different common base class, scala.xml.dtd.Decl. Additionally, document type declarations are represented by a different trait, scala.xml.dtd.DTD.

    For reading and writing XML data to and from files, see scala.xml.XML. The default parser of XML data is the Xerces parser and is provided in Java by javax.xml.parsers.SAXParser.

    A less greedy XML reader can return data as a sequential collection of events, see scala.xml.pull.XMLEventReader.

    For more control of the input, use the parser written in Scala that is provided, scala.xml.parsing.ConstructingParser.

    For working with XHTML input, use scala.xml.parsing.XhtmlParser.

    For more control of the output, use the scala.xml.PrettyPrinter.

    Utility methods for working with XML data are provided in scala.xml.Utility.

    XML values in Scala are immutable, but you can traverse and transform XML data with a scala.xml.transform.RuleTransformer.

    Definition Classes
    scala
  • package dtd
    Definition Classes
    xml
  • package factory
    Definition Classes
    xml
  • package include
    Definition Classes
    xml
  • package parsing
    Definition Classes
    xml
  • package persistent
    Definition Classes
    xml
  • package pull

    Classes needed to view an XML document as a series of events.

    Classes needed to view an XML document as a series of events. The document is parsed by an scala.xml.pull.XMLEventReader instance. You can treat it as an scala.collection.Iterator to retrieve the events, which are all subclasses of scala.xml.pull.XMLEvent.

    scala> val source = Source.fromString("""1.0" encoding="UTF-8" standalone="yes"?>
    customvalue"?>
    BAR">
    ]>Hello&bar;>""")
    
    source: scala.io.Source = non-empty iterator
    
    scala> val reader = new XMLEventReader(source)
    reader: scala.xml.pull.XMLEventReader = non-empty iterator
    
    scala> reader.foreach{ println(_) }
    EvProcInstr(instruction,custom value="customvalue")
    EvText(
    )
    EvElemStart(null,foo,,)
    EvText(Hello)
    EvComment( this is a comment )
    EvElemStart(null,bar,,)
    EvText(BAR)
    EvElemEnd(null,bar)
    EvElemStart(null,bar,,)
    EvEntityRef(gt)
    EvElemEnd(null,bar)
    EvElemEnd(null,foo)
    EvText(
    
    )
    Definition Classes
    xml
  • EvComment
  • EvElemEnd
  • EvElemStart
  • EvEntityRef
  • EvProcInstr
  • EvText
  • ProducerConsumerIterator
  • XMLEvent
  • XMLEventReader
  • package transform
    Definition Classes
    xml
p

scala.xml

pull

package pull

Classes needed to view an XML document as a series of events. The document is parsed by an scala.xml.pull.XMLEventReader instance. You can treat it as an scala.collection.Iterator to retrieve the events, which are all subclasses of scala.xml.pull.XMLEvent.

scala> val source = Source.fromString("""1.0" encoding="UTF-8" standalone="yes"?>
customvalue"?>
BAR">
]>Hello&bar;>""")

source: scala.io.Source = non-empty iterator

scala> val reader = new XMLEventReader(source)
reader: scala.xml.pull.XMLEventReader = non-empty iterator

scala> reader.foreach{ println(_) }
EvProcInstr(instruction,custom value="customvalue")
EvText(
)
EvElemStart(null,foo,,)
EvText(Hello)
EvComment( this is a comment )
EvElemStart(null,bar,,)
EvText(BAR)
EvElemEnd(null,bar)
EvElemStart(null,bar,,)
EvEntityRef(gt)
EvElemEnd(null,bar)
EvElemEnd(null,foo)
EvText(

)
Linear Supertypes

Type Members

  1. case class EvComment(text: String) extends XMLEvent with Product with Serializable

    A comment was encountered

    A comment was encountered

    text

    the text of the comment

  2. case class EvElemEnd(pre: String, label: String) extends XMLEvent with Product with Serializable

    An Element's end tag was encountered.

    An Element's end tag was encountered.

    pre

    prefix, if any, on the element. This is the xs in <xs:string>foo</xs:string>.

    label

    the name of the element, not including the prefix

  3. case class EvElemStart(pre: String, label: String, attrs: MetaData, scope: NamespaceBinding) extends XMLEvent with Product with Serializable

    An Element's start tag was encountered.

    An Element's start tag was encountered.

    pre

    prefix, if any, on the element. This is the xs in <xs:string>foo</xs:string>.

    label

    the name of the element, not including the prefix

    attrs

    any attributes on the element

  4. case class EvEntityRef(entity: String) extends XMLEvent with Product with Serializable

    An entity reference was encountered.

    An entity reference was encountered.

    entity

    the name of the entity, e.g. gt when encountering the entity >

  5. case class EvProcInstr(target: String, text: String) extends XMLEvent with Product with Serializable

    A processing instruction was encountered.

    A processing instruction was encountered.

    target

    the "PITarget" of the processing instruction. For the instruction <?foo bar="baz"?>, the target would be foo

    text

    the remainder of the instruction. For the instruction <?foo bar="baz"?>, the text would be bar="baz"

    See also

    http://www.w3.org/TR/REC-xml/#sec-pi

  6. case class EvText(text: String) extends XMLEvent with Product with Serializable

    A text node was encountered.

    A text node was encountered.

    text

    the text that was found

  7. trait ProducerConsumerIterator[T >: Null] extends Iterator[T]
  8. trait XMLEvent extends AnyRef

    An XML event for pull parsing.

    An XML event for pull parsing. All events received during parsing will be one of the subclasses of this trait.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.1.1) Consider javax.xml.stream.events.XMLEvent instead.

  9. class XMLEventReader extends AbstractIterator[XMLEvent] with ProducerConsumerIterator[XMLEvent]

    Main entry point into creating an event-based XML parser.

    Main entry point into creating an event-based XML parser. Treating this as a scala.collection.Iterator will provide access to the generated events.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.1.1) Consider javax.xml.stream.XMLEventReader instead.

Inherited from AnyRef

Inherited from Any

Ungrouped