From 70347b78966f5867137c89f4aad5d996dbc774df Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 6 Jan 2009 15:46:05 +0000 Subject: fixed ticket #1620 --- src/library/scala/xml/Utility.scala | 26 ++++--- src/library/scala/xml/dtd/ContentModel.scala | 18 ++--- src/library/scala/xml/dtd/ContentModelParser.scala | 45 +++++------- src/library/scala/xml/dtd/DTD.scala | 17 +---- src/library/scala/xml/dtd/Decl.scala | 33 ++++----- src/library/scala/xml/dtd/DocType.scala | 2 +- src/library/scala/xml/dtd/DtdTypeSymbol.scala | 8 +-- src/library/scala/xml/dtd/ElementValidator.scala | 82 ++++++++++------------ src/library/scala/xml/dtd/ExternalID.scala | 53 +++++++------- src/library/scala/xml/dtd/Scanner.scala | 20 ++---- src/library/scala/xml/dtd/Tokens.scala | 24 +++---- .../scala/xml/dtd/ValidationException.scala | 17 ++--- 12 files changed, 151 insertions(+), 194 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index b44614fbf9..3c8a3e6cbd 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -31,13 +31,13 @@ object Utility extends AnyRef with parsing.TokenTests { * * precondition: node is not a text node (it might be trimmed) */ - - def trim(x:Node): Node = x match { - case Elem(pre,lab,md,scp,child@_*) => - Elem(pre,lab,md,scp, (child flatMap trimProper):_*) + def trim(x: Node): Node = x match { + case Elem(pre, lab, md, scp, child@_*) => + Elem(pre, lab, md, scp, (child flatMap trimProper):_*) } - /** trim a child of an element. Attribute values and Atom nodes that are not Text nodes are unaffected + /** trim a child of an element. Attribute values and + * Atom nodes that are not Text nodes are unaffected. */ def trimProper(x:Node): Seq[Node] = x match { case Elem(pre,lab,md,scp,child@_*) => @@ -301,7 +301,7 @@ object Utility extends AnyRef with parsing.TokenTests { */ def publicLiteralToString(s: String): String = { val sb = new StringBuilder() - systemLiteralToString(sb, s) + publicLiteralToString(sb, s) sb.toString() } @@ -314,6 +314,12 @@ object Utility extends AnyRef with parsing.TokenTests { sb.append("PUBLIC \"").append(s).append('"') } + def appendQuoted(s: String): String = { + val sb = new StringBuilder() + appendQuoted(s, sb) + sb.toString() + } + /** * Appends "s" if string s does not contain ", * 's' otherwise. @@ -442,7 +448,7 @@ object Utility extends AnyRef with parsing.TokenTests { else nb += x } - return nb + nb } /** @@ -459,7 +465,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @param reportSyntaxError ... * @return ... */ - def parseCharRef(ch: () => Char, nextch: () => Unit, reportSyntaxError:(String) => Unit): String = { + def parseCharRef(ch: () => Char, nextch: () => Unit, reportSyntaxError: String => Unit): String = { val hex = (ch() == 'x') && { nextch(); true } val base = if (hex) 16 else 10 var i = 0 @@ -479,7 +485,7 @@ object Utility extends AnyRef with parsing.TokenTests { } nextch() } - new String(io.UTF8Codec.encode(i),"utf8") + new String(io.UTF8Codec.encode(i), "utf8") } } diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala index 740c9df175..498a121f53 100644 --- a/src/library/scala/xml/dtd/ContentModel.scala +++ b/src/library/scala/xml/dtd/ContentModel.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -19,14 +19,9 @@ object ContentModel extends WordExp { type _regexpT = RegExp object Translator extends WordBerrySethi { - override val lang: ContentModel.this.type = ContentModel.this - import lang._ - //val re = Sequ(Star(Letter(IntConst( 3 )))) - //val aut = automatonFrom(re, 7) } - case class ElemName(name: String) extends Label { override def toString() = "ElemName(\""+name+"\")" } @@ -134,14 +129,14 @@ sealed abstract class DFAContentModel extends ContentModel { private var _dfa: DetWordAutom[ContentModel.ElemName] = null def dfa = { - if(null == _dfa) { + if (null == _dfa) { val nfa = ContentModel.Translator.automatonFrom(r, 1); _dfa = new SubsetConstruction(nfa).determinize; } _dfa } } -case class MIXED(r:ContentModel.RegExp) extends DFAContentModel { +case class MIXED(r: ContentModel.RegExp) extends DFAContentModel { import ContentModel.{Alt, Eps, RegExp} /* def getIterator(ns:NodeSeq) = new Iterator[String] { @@ -165,11 +160,8 @@ Console.println("ns = "+ns); } */ override def toString(sb: StringBuilder): StringBuilder = { - sb.append("(#PCDATA|"); - //r match { - // case Alt(Eps, rs@_*) => ContentModel.toString(Alt(rs:_*):RegExp, sb); - //} - ContentModel.toString(Alt(r.asInstanceOf[Alt].rs.toList.drop(1):_*):RegExp, sb); + sb.append("(#PCDATA|") + ContentModel.toString(Alt(r.asInstanceOf[Alt].rs.toList.drop(1):_*):RegExp, sb); sb.append(")*"); } } diff --git a/src/library/scala/xml/dtd/ContentModelParser.scala b/src/library/scala/xml/dtd/ContentModelParser.scala index 712c0c24ff..d9912ee0f8 100644 --- a/src/library/scala/xml/dtd/ContentModelParser.scala +++ b/src/library/scala/xml/dtd/ContentModelParser.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,21 +9,20 @@ // $Id$ -package scala.xml.dtd; +package scala.xml.dtd /** Parser for regexps (content models in DTD element declarations) */ object ContentModelParser extends Scanner { // a bit too permissive concerning #PCDATA - import ContentModel._ ; + import ContentModel._ /** parses the argument to a regexp */ - def parse(s:String): ContentModel = { initScanner( s ); contentspec } + def parse(s: String): ContentModel = { initScanner(s); contentspec } - // zzz parser methods zzz def accept(tok: Int) = { - if( token != tok ) { - if(( tok == STAR )&&( token == END )) // common mistake + if (token != tok) { + if ((tok == STAR) && (token == END)) // common mistake error("in DTDs, \n"+ "mixed content models must be like (#PCDATA|Name|Name|...)*"); else @@ -35,18 +34,17 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // s [ '+' | '*' | '?' ] def maybeSuffix(s: RegExp) = token match { - case STAR => nextToken; Star( s ) - case PLUS => nextToken; Sequ( s, Star( s )) - case OPT => nextToken; Alt( Eps, s ) + case STAR => nextToken; Star(s) + case PLUS => nextToken; Sequ(s, Star(s)) + case OPT => nextToken; Alt(Eps, s) case _ => s } - // contentspec ::= EMPTY | ANY | (#PCDATA) | "(#PCDATA|"regexp) def contentspec: ContentModel = token match { - case NAME => value match { + case NAME => value match { case "ANY" => ANY case "EMPTY" => EMPTY case _ => error("expected ANY, EMPTY or '(' instead of " + value ); @@ -55,7 +53,7 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # nextToken; sOpt; - if( token != TOKEN_PCDATA ) + if (token != TOKEN_PCDATA) ELEMENTS(regexp); else { nextToken; @@ -101,8 +99,7 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # } */ // '(' S? regexp ::= cp S? [seqRest|choiceRest] ')' [ '+' | '*' | '?' ] - def regexp:RegExp = { - //Console.println("regexp, token = "+token2string(token)); + def regexp: RegExp = { val p = particle; sOpt; maybeSuffix( token match { @@ -112,10 +109,9 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # }) } - // seqRest ::= (',' S? cp S?)+ - def seqRest( p:RegExp ) = { - var k = List( p ); + def seqRest(p: RegExp) = { + var k = List(p); while( token == COMMA ) { nextToken; sOpt; @@ -139,18 +135,15 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning # // particle ::= '(' S? regexp // | name [ '+' | '*' | '?' ] - def particle = { - //Console.println("particle, token="+token2string(token)); - token match { + def particle = token match { case LPAREN => nextToken; sOpt; regexp; - case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix( a ) - case _ => error("expected '(' or Name, got:"+token2string( token )); - } + case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix(a) + case _ => error("expected '(' or Name, got:"+token2string(token)); } // atom ::= name def atom = token match { case NAME => val a = Letter(ElemName(value)); nextToken; a - case _ => error("expected Name, got:"+token2string( token )); + case _ => error("expected Name, got:"+token2string(token)); } } diff --git a/src/library/scala/xml/dtd/DTD.scala b/src/library/scala/xml/dtd/DTD.scala index 0ca74a7926..a64e40fa92 100644 --- a/src/library/scala/xml/dtd/DTD.scala +++ b/src/library/scala/xml/dtd/DTD.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -33,10 +33,6 @@ abstract class DTD { var decls: List[Decl] = Nil - //def getElemDecl(elem:String): ElemDecl - - //def getAttribDecl(elem: String, attr: String): AttrDecl - override def toString() = { val sb = new StringBuilder("DTD [\n") if (null != externalID) @@ -46,15 +42,4 @@ abstract class DTD { sb.append("]").toString() } - /* - def initializeEntities() = { - for (x <- decls) x match { - case y @ ParsedEntityDecl(name, _) => ent.update(name, y); - case y @ UnparsedEntityDecl(name, _, _) => ent.update(name, y); - case y @ ParameterEntityDecl(name, _) => ent.update(name, y); - case _ => - } - } - */ - } diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala index bdae3922fa..fbde14fd1d 100644 --- a/src/library/scala/xml/dtd/Decl.scala +++ b/src/library/scala/xml/dtd/Decl.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** - ** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** + ** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -12,7 +12,7 @@ package scala.xml.dtd -abstract class Decl; +abstract class Decl abstract class MarkupDecl extends Decl { def toString(sb: StringBuilder): StringBuilder @@ -20,10 +20,8 @@ abstract class MarkupDecl extends Decl { /** an element declaration */ -case class ElemDecl(name: String, contentModel: ContentModel) extends MarkupDecl with DtdTypeSymbol { - - //def mixed = ; // to do - +case class ElemDecl(name: String, contentModel: ContentModel) +extends MarkupDecl with DtdTypeSymbol { override def toString(sb: StringBuilder): StringBuilder = { sb .append("'); } +} -} // ElemDecl - -case class AttListDecl(name: String, attrs:List[AttrDecl]) extends MarkupDecl with DtdTypeSymbol { - +case class AttListDecl(name: String, attrs:List[AttrDecl]) +extends MarkupDecl with DtdTypeSymbol { override def toString(sb: StringBuilder): StringBuilder = { sb .append("'); + entdef.toString(sb).append('>') } } @@ -79,7 +74,7 @@ case class ParsedEntityDecl(name: String, entdef: EntityDef) extends EntityDecl case class ParameterEntityDecl(name: String, entdef: EntityDef) extends EntityDecl { override def toString(sb: StringBuilder): StringBuilder = { sb.append("'); + entdef.toString(sb).append('>') } } @@ -94,7 +89,7 @@ case class UnparsedEntityDecl( name:String, extID:ExternalID, notation:String ) case class NotationDecl( name:String, extID:ExternalID ) extends MarkupDecl { override def toString(sb: StringBuilder): StringBuilder = { sb.append(" - val nfa = ContentModel.Translator.automatonFrom(r, 1); - dfa = new SubsetConstruction(nfa).determinize; + case ELEMENTS(r) => + val nfa = ContentModel.Translator.automatonFrom(r, 1) + dfa = new SubsetConstruction(nfa).determinize case _ => - dfa = null; + dfa = null } } - def getContentModel = contentModel; + def getContentModel = contentModel /** set meta data, enabling attribute validation */ - def setMetaData(adecls: List[AttrDecl]) = - this.adecls = adecls; + def setMetaData(adecls: List[AttrDecl]) { this.adecls = adecls } def getIterator(nodes: Seq[Node], skipPCDATA: Boolean): Iterator[ElemName] = nodes.toList @@ -65,8 +64,6 @@ class ElementValidator() extends Function1[Node,Boolean] { /** check attributes, return true if md corresponds to attribute declarations in adecls. */ def check(md: MetaData): Boolean = { - //Console.println("checking md = "+md); - //Console.println("adecls = "+adecls); //@todo other exceptions import MakeValidationException._; val len: Int = exc.length; @@ -83,9 +80,8 @@ class ElementValidator() extends Function1[Node,Boolean] { attr } val it = md.elements; while(it.hasNext) { - val attr = it.next; - //Console.println("attr:"+attr); - j = 0; + val attr = it.next + j = 0 find(attr.key) match { case null => @@ -100,10 +96,11 @@ class ElementValidator() extends Function1[Node,Boolean] { } } - //Console.println("so far:"+(exc.length == len)); - //val missing = ok.toSet( false ); FIXME: it doesn't seem to be used anywhere - j = 0; var kt = adecls.elements; while(kt.hasNext) { + //val missing = ok.toSet(false); FIXME: it doesn't seem to be used anywhere + j = 0 + var kt = adecls.elements + while (kt.hasNext) { kt.next match { case AttrDecl(key, tpe, REQUIRED) if !ok(j) => exc = fromMissingAttribute( key, tpe ) :: exc; @@ -112,27 +109,28 @@ class ElementValidator() extends Function1[Node,Boolean] { j = j + 1; } } - //Console.println("finish:"+(exc.length == len)); - (exc.length == len) //- true if no new exception + exc.length == len //- true if no new exception } /** check children, return true if conform to content model * @pre contentModel != null */ def check(nodes: Seq[Node]): Boolean = contentModel match { + case ANY => + true - case ANY => true ; + case EMPTY => + !getIterator(nodes, false).hasNext - case EMPTY => !getIterator(nodes, false).hasNext - - case PCDATA => !getIterator(nodes, true).hasNext; + case PCDATA => + !getIterator(nodes, true).hasNext case MIXED(ContentModel.Alt(branches @ _*)) => //@todo - val j = exc.length; - def find(Key: String): Boolean = { - var res = false; - val jt = branches.elements; - while(jt.hasNext && !res) + val j = exc.length + def find(Key: String): Boolean = { + var res = false + val jt = branches.elements + while (jt.hasNext && !res) jt.next match { // !!! check for match translation problem case ContentModel.Letter(ElemName(Key)) => res = true; case _ => @@ -142,7 +140,7 @@ class ElementValidator() extends Function1[Node,Boolean] { var it = getIterator(nodes, true); while(it.hasNext) { var label = it.next.name; - if(!find(label)) { + if (!find(label)) { exc = MakeValidationException.fromUndefinedElement(label) :: exc; } } @@ -150,16 +148,14 @@ class ElementValidator() extends Function1[Node,Boolean] { (exc.length == j) //- true if no new exception case _:ELEMENTS => - var q = 0; - val it = getIterator(nodes, false); - //Console.println("it empty from the start? "+(!it.hasNext)); - while( it.hasNext ) { - val e = it.next; + var q = 0 + val it = getIterator(nodes, false) + while (it.hasNext) { + val e = it.next dfa.delta(q).get(e) match { - case Some(p) => q = p; + case Some(p) => q = p case _ => throw ValidationException("element "+e+" not allowed here") } - //Console.println("q now " + q); } dfa.isFinal(q) //- true if arrived in final state } diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index 5f384f610d..fe2e20efbe 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -14,18 +14,15 @@ package scala.xml.dtd /** an ExternalIDs - either PublicID or SystemID * - * @author Burak Emir - * @param target target name of this PI - * @param text text contained in this node, may not contain "?>" -**/ - + * @author Burak Emir + */ abstract class ExternalID { /** returns "PUBLIC "+publicLiteral+" SYSTEM "+systemLiteral */ override def toString(): String /** returns "PUBLIC "+publicLiteral+" SYSTEM "+systemLiteral */ - def toString(sb: StringBuilder): StringBuilder + def toString(sb: StringBuilder): StringBuilder def systemId: String @@ -33,11 +30,10 @@ abstract class ExternalID { /** a system identifier * - * @author Burak Emir - * @param systemLiteral the system identifier literal -**/ - -case class SystemID( systemId:String ) extends ExternalID with parsing.TokenTests{ + * @author Burak Emir + * @param systemLiteral the system identifier literal + */ +case class SystemID(systemId: String) extends ExternalID with parsing.TokenTests { if( !checkSysID(systemId) ) throw new IllegalArgumentException( @@ -52,26 +48,26 @@ case class SystemID( systemId:String ) extends ExternalID with parsing.TokenTest } -/** a public identifier +/** a public identifier (see http://www.w3.org/QA/2002/04/valid-dtd-list.html). * - * @author Burak Emir - * @param publicLiteral the public identifier literal - * @param systemLiteral (can be null for notation pubIDs) the system identifier literal -**/ + * @author Burak Emir + * @param publicLiteral the public identifier literal + * @param systemLiteral (can be null for notation pubIDs) the system identifier literal + */ case class PublicID(publicId: String, systemId: String) extends ExternalID with parsing.TokenTests { - if( !checkPubID( publicId )) + if (!checkPubID(publicId)) throw new IllegalArgumentException( "publicId must consist of PubidChars" ) - if( (systemId ne null) && !checkSysID( systemId ) ) + if ((systemId ne null) && !checkSysID(systemId)) throw new IllegalArgumentException( "can't use both \" and ' in systemId" ) /** the constant "#PI" */ - def label = "#PI" + def label = "#PI" /** always empty */ def attribute = Node.NoAttributes @@ -79,12 +75,17 @@ extends ExternalID with parsing.TokenTests { /** always empty */ def child = Nil - /** appends "PUBLIC "+publicId+" SYSTEM "+systemId to argument */ + /** returns " PUBLIC "+publicId+" "+systemId */ + override def toString() = + toString(new StringBuilder()).toString() + + /** appends "PUBLIC "+publicId+" "+systemId to argument */ override def toString(sb: StringBuilder): StringBuilder = { - Utility.publicLiteralToString( sb, publicId ).append(' ') - if(systemId ne null) - Utility.systemLiteralToString( sb, systemId ) - else - sb + Utility.publicLiteralToString(sb, publicId) + if (systemId ne null) { + sb.append(' ') + Utility.appendQuoted(systemId, sb) + } + sb } } diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index 1d32f7c3f7..0bb8d99b74 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -17,10 +17,8 @@ package scala.xml.dtd */ class Scanner extends Tokens with parsing.TokenTests { - // zzz constants zzz final val ENDCH = '\u0000' - // zzz fields zzz var token:Int = END var value:String = _ @@ -29,7 +27,6 @@ class Scanner extends Tokens with parsing.TokenTests { /** initializes the scanner on input s */ final def initScanner(s: String) { - //Console.println("[scanner init on \""+s+"\"]"); value = "" it = (s).elements token = 1+END @@ -39,12 +36,9 @@ class Scanner extends Tokens with parsing.TokenTests { /** scans the next token */ final def nextToken { - if (token != END) token = readToken; - //Console.println("["+token2string( token )+"]"); + if (token != END) token = readToken } - // zzz scanner methods zzz - // todo: see XML specification... probably isLetter,isDigit is fine final def isIdentChar = ( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')); @@ -56,15 +50,9 @@ class Scanner extends Tokens with parsing.TokenTests { } final def accS(ds: Seq[Char]) { - val jt = ds.elements; while (jt.hasNext) { acc(jt.next) } - } - - /* - final def isSpace = c match { - case '\u0020' | '\u0009' | '\u000D' | '\u000A' => true - case _ => false; + val jt = ds.elements + while (jt.hasNext) { acc(jt.next) } } - */ final def readToken: Int = if (isSpace(c)) { diff --git a/src/library/scala/xml/dtd/Tokens.scala b/src/library/scala/xml/dtd/Tokens.scala index 43185983a8..73834e3838 100644 --- a/src/library/scala/xml/dtd/Tokens.scala +++ b/src/library/scala/xml/dtd/Tokens.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,7 +9,7 @@ // $Id$ -package scala.xml.dtd; +package scala.xml.dtd class Tokens { @@ -29,15 +29,15 @@ class Tokens { final val S = 13 final def token2string(i: Int): String = i match { - case 0 => "#PCDATA" - case 1 => "NAME" - case 3 => "(" - case 4 => ")" - case 5 => "," - case 6 => "*" - case 7 => "+" - case 8 => "?" - case 9 => "|" + case 0 => "#PCDATA" + case 1 => "NAME" + case 3 => "(" + case 4 => ")" + case 5 => "," + case 6 => "*" + case 7 => "+" + case 8 => "?" + case 9 => "|" case 10 => "END" case 13 => " " } diff --git a/src/library/scala/xml/dtd/ValidationException.scala b/src/library/scala/xml/dtd/ValidationException.scala index 021fca54fd..4425167a03 100644 --- a/src/library/scala/xml/dtd/ValidationException.scala +++ b/src/library/scala/xml/dtd/ValidationException.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -19,18 +19,19 @@ case class ValidationException(e: String) extends Exception(e) */ object MakeValidationException { def fromFixedAttribute(k: String, value: String, actual: String) = - ValidationException("value of attribute " + k + " FIXED to \""+value+"\", but document tries \""+actual+"\"") + ValidationException("value of attribute " + k + " FIXED to \""+ + value+"\", but document tries \""+actual+"\"") - def fromNonEmptyElement() = { + def fromNonEmptyElement() = new ValidationException("element should be *empty*") - } - def fromUndefinedElement( label:String ) = + + def fromUndefinedElement(label: String) = new ValidationException("element \""+ label +"\" not allowed here") - def fromUndefinedAttribute( key:String ) = - new ValidationException("attribute " + key +" not allowed here" ) + def fromUndefinedAttribute(key: String) = + new ValidationException("attribute " + key +" not allowed here") - def fromMissingAttribute( allKeys:scala.collection.Set[String] ) = { + def fromMissingAttribute(allKeys: scala.collection.Set[String]) = { val sb = new StringBuilder("missing value for REQUIRED attribute") if (allKeys.size > 1) sb.append('s'); val it = allKeys.elements -- cgit v1.2.3