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.

    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 include
    Definition Classes
    xml
  • package sax
    Definition Classes
    include
  • EncodingHeuristics
  • XIncludeFilter
  • XIncluder

package sax

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class XIncludeFilter extends XMLFilterImpl

    This is a SAX filter which resolves all XInclude include elements before passing them on to the client application.

    This is a SAX filter which resolves all XInclude include elements before passing them on to the client application. Currently this class has the following known deviation from the XInclude specification:

    1. XPointer is not supported.

    Furthermore, I would definitely use a new instance of this class for each document you want to process. I doubt it can be used successfully on multiple documents. Furthermore, I can virtually guarantee that this class is not thread safe. You have been warned.

    Since this class is not designed to be subclassed, and since I have not yet considered how that might affect the methods herein or what other protected methods might be needed to support subclasses, I have declared this class final. I may remove this restriction later, though the use-case for subclassing is weak. This class is designed to have its functionality extended via a horizontal chain of filters, not a vertical hierarchy of sub and superclasses.

    To use this class:

    • Construct an XIncludeFilter object with a known base URL
    • Pass the XMLReader object from which the raw document will be read to the setParent() method of this object.
    • Pass your own ContentHandler object to the setContentHandler() method of this object. This is the object which will receive events from the parsed and included document.
    • Optional: if you wish to receive comments, set your own LexicalHandler object as the value of this object's http://xml.org/sax/properties/lexical-handler property. Also make sure your LexicalHandler asks this object for the status of each comment using insideIncludeElement before doing anything with the comment.
    • Pass the URL of the document to read to this object's parse() method

    e.g.

    val includer = new XIncludeFilter(base)
    includer setParent parser
    includer setContentHandler new SAXXIncluder(System.out)
    includer parse args(i)

    translated from Elliotte Rusty Harold's Java source.

  2. class XIncluder extends ContentHandler with LexicalHandler

    XIncluder is a SAX ContentHandler that writes its XML document onto an output stream after resolving all xinclude:include elements.

    XIncluder is a SAX ContentHandler that writes its XML document onto an output stream after resolving all xinclude:include elements.

    Based on Eliotte Rusty Harold's SAXXIncluder.

Value Members

  1. object EncodingHeuristics

    EncodingHeuristics reads from a stream (which should be buffered) and attempts to guess what the encoding of the text in the stream is.

    EncodingHeuristics reads from a stream (which should be buffered) and attempts to guess what the encoding of the text in the stream is. If it fails to determine the type of the encoding, it returns the default UTF-8.

Ungrouped