/* * Copyright (C) 2007-2016 Artima, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Automatically generated Scala interpreter transcript from: * * Programming in Scala (Third Edition) * by Martin Odersky, Lex Spoon, Bill Venners * * http://booksites.artima.com/programming_in_scala_3ed */ scala> import scala.xml._ :7: error: object xml is not a member of package scala import scala.xml._ ^ scala> This is some XML. Here is a tag: :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. ^ scala> {"hello" + ", world"} :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. {"hello" + ", world"} ^ scala> val yearMade = 1955 yearMade: Int = 1955 scala> { if (yearMade < 2000) {yearMade} else xml.NodeSeq.Empty } :9: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. { if (yearMade < 2000) {yearMade} ^ scala> {3 + 4} :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. {3 + 4} ^ scala> {"potential security hole"} :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. {"potential security hole"} ^ scala> "" + "potential security hole" + "" res5: String = potential security hole scala> abstract class CCTherm { val description: String val yearMade: Int val dateObtained: String val bookPrice: Int // in US cents val purchasePrice: Int // in US cents val condition: Int // 1 to 10 override def toString = description def toXML = {description} {yearMade} {dateObtained} {bookPrice} {purchasePrice} {condition} } :19: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. ^ scala> val therm = new CCTherm { val description = "hot dog #5" val yearMade = 1952 val dateObtained = "March 14, 2006" val bookPrice = 2199 val purchasePrice = 500 val condition = 9 } :7: error: not found: type CCTherm val therm = new CCTherm { ^ scala> therm.toXML :8: error: not found: value therm therm.toXML ^ scala> {{{{brace yourself!}}}} :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. {{{{brace yourself!}}}} ^ scala> Sounds good.text :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. Sounds good.text ^ scala> input ---> output .text :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. input ---> output .text ^ scala> hello \ "b" :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. hello \ "b" ^ scala> hello \ "c" :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. hello \ "c" ^ scala> hello \\ "c" :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. hello \\ "c" ^ scala> hello \ "a" :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. hello \ "a" ^ scala> hello \\ "a" :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. hello \\ "a" ^ scala> val joe = :7: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. val joe = joe \ "@name" :8: error: not found: value joe joe \ "@name" ^ scala> joe \ "@serial" :8: error: not found: value joe joe \ "@serial" ^ scala> def fromXML(node: scala.xml.Node): CCTherm = new CCTherm { val description = (node \ "description").text val yearMade = (node \ "yearMade").text.toInt val dateObtained = (node \ "dateObtained").text val bookPrice = (node \ "bookPrice").text.toInt val purchasePrice = (node \ "purchasePrice").text.toInt val condition = (node \ "condition").text.toInt } :7: error: not found: type CCTherm def fromXML(node: scala.xml.Node): CCTherm = ^ :7: error: object xml is not a member of package scala def fromXML(node: scala.xml.Node): CCTherm = ^ :8: error: not found: type CCTherm new CCTherm { ^ scala> val node = therm.toXML :7: error: not found: value therm val node = therm.toXML ^ scala> fromXML(node) :8: error: not found: value fromXML fromXML(node) ^ :8: error: not found: value node fromXML(node) ^ scala> def proc(node: scala.xml.Node): String = node match { case {contents} => "It's an a: " + contents case {contents} => "It's a b: " + contents case _ => "It's something else." } :9: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. case {contents} => "It's an a: " + contents ^ scala> proc(apple) :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc(apple) ^ scala> proc(banana) :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc(banana) ^ scala> proc(cherry) :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc(cherry) ^ scala> proc(a red apple) :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc(a red apple) ^ scala> proc() :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc() ^ scala> def proc(node: scala.xml.Node): String = node match { case {contents @ _*} => "It's an a: " + contents case {contents @ _*} => "It's a b: " + contents case _ => "It's something else." } :9: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. case {contents @ _*} => "It's an a: " + contents ^ scala> proc(a red apple) :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc(a red apple) ^ scala> proc() :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. proc() ^ scala> val catalog = hot dog #5 1952 March 14, 2006 2199 500 9 Sprite Boy 1964 April 28, 2003 1695 595 5 :8: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. ^ scala> catalog match { case {therms @ _*} => for (therm <- therms) println("processing: " + (therm \ "description").text) } :9: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. case {therms @ _*} => ^ scala> catalog match { case {therms @ _*} => for (therm @ {_*} <- therms) println("processing: " + (therm \ "description").text) } :9: error: To compile XML syntax, the scala.xml package must be on the classpath. Please see http://docs.scala-lang.org/overviews/core/scala-2.11.html#scala-xml. case {therms @ _*} => ^