diff options
author | buraq <buraq@epfl.ch> | 2005-04-24 22:31:05 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2005-04-24 22:31:05 +0000 |
commit | 07af0f5eb5bd0fdf869e21254bafb38e1088861e (patch) | |
tree | 6b749c072599634ecb37f9908c031b8da63b0350 /sources | |
parent | 040ca6168b6c24482276903503b87eaa364ca416 (diff) | |
download | scala-07af0f5eb5bd0fdf869e21254bafb38e1088861e.tar.gz scala-07af0f5eb5bd0fdf869e21254bafb38e1088861e.tar.bz2 scala-07af0f5eb5bd0fdf869e21254bafb38e1088861e.zip |
moved files
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/xml/dtd/DocType.scala | 44 | ||||
-rw-r--r-- | sources/scala/xml/dtd/ExternalID.scala | 69 |
2 files changed, 113 insertions, 0 deletions
diff --git a/sources/scala/xml/dtd/DocType.scala b/sources/scala/xml/dtd/DocType.scala new file mode 100644 index 0000000000..0ad93097fa --- /dev/null +++ b/sources/scala/xml/dtd/DocType.scala @@ -0,0 +1,44 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ + +package scala.xml.dtd; + +/** an XML node for document type declaration + * + * @author Burak Emir + * @param target name of this DOCTYPE + * @param extID None, or Some(external ID of this doctype) + * @param intSubset sequence of internal subset declarations +**/ + +case class DocType( name:String, extID:ExternalID, intSubset:Seq[dtd.Decl]) { + + if( !Parsing.isName( name ) ) + throw new IllegalArgumentException(name+" must be an XML Name"); + + /** hashcode for this processing instruction */ + final override def hashCode() = name.hashCode() + 7 * extID.hashCode() + 41*intSubset.toList.hashCode(); + + /** returns "<!DOCTYPE + name + extID? + ("["+intSubSet+"]")? >" */ + final override def toString() = { + val sb = new StringBuffer("<!DOCTYPE "); + sb.append( name ); + sb.append(' '); + sb.append(extID.toString()); + if( intSubset.length > 0 ) { + sb.append('['); + for( val d <- intSubset ) { + sb.append( d.toString() ); + } + sb.append(']'); + } + sb.append('>'); + sb.toString(); + } +} diff --git a/sources/scala/xml/dtd/ExternalID.scala b/sources/scala/xml/dtd/ExternalID.scala new file mode 100644 index 0000000000..3463f853e6 --- /dev/null +++ b/sources/scala/xml/dtd/ExternalID.scala @@ -0,0 +1,69 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ + +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 "?>" +**/ + +class ExternalID ; + +/** a system identifier + * + * @author Burak Emir + * @param systemLiteral the system identifier literal +**/ + +case class SystemID( systemLiteral:String ) extends ExternalID { + + if( !Parsing.checkSysID( systemLiteral ) ) + throw new IllegalArgumentException( + "can't use both \" and ' in systemLiteral" + ); + final override def toString() = + Utility.systemLiteralToString( systemLiteral ); +} + + +/** a public identifier + * + * @author Burak Emir + * @param publicLiteral the public identifier literal + * @param systemLiteral the system identifier literal +**/ +case class PublicID( publicLiteral:String, systemLiteral:String ) extends ExternalID { + + if( !Parsing.checkPubID( publicLiteral )) + throw new IllegalArgumentException( + "publicLiteral must consist of PubidChars" + ); + if( !Parsing.checkSysID( systemLiteral ) ) + throw new IllegalArgumentException( + "can't use both \" and ' in systemLiteral" + ); + + /** the constant "#PI" */ + final def label = "#PI"; + + /** always empty */ + final def attribute = Node.NoAttributes; + + /** always empty */ + final def child = Nil; + + /** returns "PUBLIC "+publicLiteral+" SYSTEM "+systemLiteral */ + final override def toString() = + Utility.publicLiteralToString( publicLiteral ) + + Utility.systemLiteralToString( systemLiteral ); + +} |