|
How do I use DTD's with Scala 2.3.0's XML object literals?: msg#00491lang.scala
Hi, I'm using scala's wickedly cool XML object literals (great idea - no more need for Freemarker or Velocity for XML - could we have them for other things, too, please... like a compile time templating engine!) to generate XHTML reports for rehersal. To create valid XHTML, I need to have a DTD before the first element. However, the compiler complains if I have a method like this:- private def template(category: TestCategory) = <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <head> <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/> <title>{category.name} Testing Results</title> <style type="text/css" media="all"> (SNIPPED lots of content) Removing the DTD causes it to compile. Does anybody know why? Additionally, does the compiler or API understand XML and HTML literals? Is ther a utility method I could use to convert strings? Many thanks Raph For information, the compile error (I'm using scalac in ant, with Scala 2.3.0) is:- Compiling 2 source files to /Users/raphaelcohn/ProgrammingProjects/rehersal/trunk/build/production rehersal/trunk/source/production/rehersal/results/reporters/XhtmlResultReporter.scala:16 error: in XML literal: '-' expected instead of 'D' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ^ rehersal/trunk/source/production/rehersal/results/reporters/XhtmlResultReporter.scala:16 error: in XML literal: '-' expected instead of 'O' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ^ java.util.NoSuchElementException: stack empty at scala.collection.mutable.Stack.top(Stack.scala:66) at scala.tools.nsc.ast.parser.MarkupParsers$MarkupParser.xLiteral(MarkupParsers.scala:537) at scala.tools.nsc.ast.parser.Parsers$Parser.simpleExpr(Parsers.scala:936) at scala.tools.nsc.ast.parser.Parsers$Parser.prefixExpr(Parsers.scala:913) at scala.tools.nsc.ast.parser.Parsers$Parser.postfixExpr(Parsers.scala:868) at scala.tools.nsc.ast.parser.Parsers$Parser.scala$tools$nsc$ast$parser$Parsers$Parser$$exprImpl(Parsers.scala:812) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$1.apply(Parsers.scala:719) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$1.apply(Parsers.scala:719) at scala.tools.nsc.ast.parser.Parsers$Parser.liftingScope(Parsers.scala:676) at scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:719) at scala.tools.nsc.ast.parser.Parsers$Parser.equalsExpr(Parsers.scala:685) at scala.tools.nsc.ast.parser.Parsers$Parser.funDefOrDcl(Parsers.scala:1680) at scala.tools.nsc.ast.parser.Parsers$Parser.defOrDcl(Parsers.scala:1578) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$16.apply(Parsers.scala:1921) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$16.apply(Parsers.scala:1921) at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:202) at scala.tools.nsc.ast.parser.Parsers$Parser.templateStatSeq(Parsers.scala:1921) at scala.tools.nsc.ast.parser.Parsers$Parser.templateBody(Parsers.scala:1844) at scala.tools.nsc.ast.parser.Parsers$Parser.classTemplate(Parsers.scala:1832) at scala.tools.nsc.ast.parser.Parsers$Parser.classDef(Parsers.scala:1768) at scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:1744) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$15.apply(Parsers.scala:1895) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$15.apply(Parsers.scala:1895) at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:202) at scala.tools.nsc.ast.parser.Parsers$Parser.topStatSeq(Parsers.scala:1895) at scala.tools.nsc.ast.parser.Parsers$Parser.compilationUnit(Parsers.scala:2067) at scala.tools.nsc.ast.parser.Parsers$Parser.parse(Parsers.scala:78) at scala.tools.nsc.ast.parser.SyntaxAnalyzer$ParserPhase.apply(SyntaxAnalyzer.scala:20) at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:220) at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:209) at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:209) at scala.Iterator$class.foreach(Iterator.scala:341) at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:244) at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:209) at scala.tools.nsc.Global$Run.compileSources(Global.scala:475) at scala.tools.nsc.Global$Run.compile(Global.scala:547) at scala.tools.ant.Scalac.execute(Scalac.scala:592) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) ___________________________________________________________ New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: two things about defs: 00491, Lex Spoon |
|---|---|
| Next by Date: | Re: Contracts (feature request): 00491, Raphael James Cohn |
| Previous by Thread: | Contracts (feature request)i: 00491, Henrik Huttunen |
| Next by Thread: | Re: How do I use DTD's with Scala 2.3.0's XML object literals?: 00491, Burak Emir |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |