summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bayne <mdb@samskivert.com>2012-09-01 13:00:46 -0700
committerMichael Bayne <mdb@samskivert.com>2012-09-04 09:23:24 -0700
commitc49e23572883d427e9471015cd8554c875a9a492 (patch)
tree228ba58f5a083909c494a623a178d8c31c514d1e
parenta36a24b678a83d4297047aa102b3b37a61a3f767 (diff)
downloadscala-c49e23572883d427e9471015cd8554c875a9a492.tar.gz
scala-c49e23572883d427e9471015cd8554c875a9a492.tar.bz2
scala-c49e23572883d427e9471015cd8554c875a9a492.zip
SI-6295: Introduced NoExternalID, fixed DocType's documentation.
DocType claimed to take Option[ExternalID], but instead took ExternalID, which provided no means to construct a DocType that contains no external id. This introduces a NoExternalID marker object which means what it says. Also added a convenience apply method that assumes no external id, nor internal subset declarations. This allows one to construct DocType("html"), which suffices if one intends only to support modern web browsers.
-rw-r--r--src/library/scala/xml/dtd/DocType.scala8
-rw-r--r--src/library/scala/xml/dtd/ExternalID.scala11
2 files changed, 18 insertions, 1 deletions
diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala
index 64aa7e2f74..78aacb2cea 100644
--- a/src/library/scala/xml/dtd/DocType.scala
+++ b/src/library/scala/xml/dtd/DocType.scala
@@ -15,7 +15,7 @@ package dtd
* @author Burak Emir
*
* @param name name of this DOCTYPE
- * @param extID None, or Some(external ID of this doctype)
+ * @param extID NoExternalID or the external ID of this doctype
* @param intSubset sequence of internal subset declarations
*/
case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl])
@@ -32,3 +32,9 @@ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl])
"""<!DOCTYPE %s %s%s>""".format(name, extID.toString, intString)
}
}
+
+object DocType
+{
+ /** Creates a doctype with no external id, nor internal subset declarations. */
+ def apply(name: String): DocType = apply(name, NoExternalID, Nil)
+}
diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala
index a0a5818d07..ccee5dbe5a 100644
--- a/src/library/scala/xml/dtd/ExternalID.scala
+++ b/src/library/scala/xml/dtd/ExternalID.scala
@@ -73,3 +73,14 @@ case class PublicID(publicId: String, systemId: String) extends ExternalID {
/** always empty */
def child = Nil
}
+
+/** A marker used when a `DocType` contains no external id.
+ *
+ * @author Michael Bayne
+ */
+object NoExternalID extends ExternalID {
+ val publicId = null
+ val systemId = null
+
+ override def toString = ""
+}