|
8 | 8 |
|
9 | 9 | package scala
|
10 | 10 |
|
| 11 | +/** |
| 12 | + * This library provides support for the XML literal syntax in Scala programs. |
| 13 | + * {{{ |
| 14 | + * val planets: scala.xml.Elem = <planets> |
| 15 | + * <planet id="earth"> |
| 16 | + * <title>Earth</title> |
| 17 | + * <mass unit="kg">5.9742e24</mass> |
| 18 | + * <radius unit="m">6378.14e3</radius> |
| 19 | + * </planet> |
| 20 | + * <planet id="mars"> |
| 21 | + * <title>Mars</title> |
| 22 | + * <mass unit="kg">0.64191e24</mass> |
| 23 | + * <radius unit="m">3397.0e3</radius> |
| 24 | + * </planet> |
| 25 | + * </planets> |
| 26 | + * }}} |
| 27 | + * |
| 28 | + * Additionally, you can mix Scala expressions in your XML elements by |
| 29 | + * using the curly brace notation: |
| 30 | + * |
| 31 | + * {{{ |
| 32 | + * val sunMass = 1.99e30 |
| 33 | + * val sunRadius = 6.96e8 |
| 34 | + * val star = <star> |
| 35 | + * <title>Sun</title> |
| 36 | + * <mass unit="kg">{ sunMass }</mass> |
| 37 | + * <radius unit="m">{ sunRadius }</radius> |
| 38 | + * <surface unit="m²">{ 4 * Math.PI * Math.pow(sunRadius, 2) }</surface> |
| 39 | + * <volume unit="m³">{ 4/3 * Math.PI * Math.pow(sunRadius, 3) }</volume> |
| 40 | + * </star> |
| 41 | + * }}} |
| 42 | + * |
| 43 | + * An XML element, for example `<star/>` and `<planet/>`, is |
| 44 | + * represented in this library as a case class, [[scala.xml.Elem]]. |
| 45 | + * |
| 46 | + * The sub-elements of XML values share a common base class, |
| 47 | + * [[scala.xml.Node]]. |
| 48 | + * |
| 49 | + * However, the non-element declarations found in XML files share a |
| 50 | + * different common base class, [[scala.xml.dtd.Decl]]. Additionally, |
| 51 | + * document type declarations are represented by a different trait, |
| 52 | + * [[scala.xml.dtd.DTD]]. |
| 53 | + * |
| 54 | + * For reading and writing XML data to and from files, see |
| 55 | + * [[scala.xml.XML]]. The default parser of XML data is the |
| 56 | + * [[http://xerces.apache.org/ Xerces]] parser and is provided in Java |
| 57 | + * by [[javax.xml.parsers.SAXParser]]. |
| 58 | + * |
| 59 | + * A less greedy XML reader can return data as a sequential collection |
| 60 | + * of events, see [[scala.xml.pull.XMLEventReader]]. |
| 61 | + * |
| 62 | + * For more control of the input, use the parser written in Scala that |
| 63 | + * is provided, [[scala.xml.parsing.ConstructingParser]]. |
| 64 | + * |
| 65 | + * For working with XHTML input, use [[scala.xml.parsing.XhtmlParser]]. |
| 66 | + * |
| 67 | + * For more control of the output, use the [[scala.xml.PrettyPrinter]]. |
| 68 | + * |
| 69 | + * Utility methods for working with XML data are provided in |
| 70 | + * [[scala.xml.Utility]]. |
| 71 | + * |
| 72 | + * XML values in Scala are immutable, but you can traverse and |
| 73 | + * transform XML data with a [[scala.xml.transform.RuleTransformer]]. |
| 74 | + */ |
11 | 75 | package object xml {
|
12 | 76 | val XercesClassName = "org.apache.xerces.parsers.SAXParser"
|
13 | 77 |
|
|
0 commit comments