All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.xml.dtd.Decl.scala Maven / Gradle / Ivy

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2020, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    (c) 2011-2020, Lightbend, Inc.       **
** /____/\___/_/ |_/____/_/ | |    http://www.scala-lang.org/           **
**                          |/                                          **
\*                                                                      */

package scala
package xml
package dtd

import Utility.sbToString

/**
 * XML declarations
 * 
 *  - [[scala.xml.dtd.AttListDecl]] — Attribute list declaration (ATTLIST)
 *  - [[scala.xml.dtd.AttrDecl]] — Attribute declaration
 *  - [[scala.xml.dtd.ElemDecl]] — Element declaration (ELEMENT)
 *  - [[scala.xml.dtd.ParameterEntityDecl]] — Parameter entity list (ENTITY %)
 *  - [[scala.xml.dtd.ParsedEntityDecl]] — Parsed general entity list (ENTITY)
 *  - [[scala.xml.dtd.PEReference]] — Parsed entity reference
 *  - [[scala.xml.dtd.UnparsedEntityDecl]] — Unparsed entity list (ENTITY NDATA)
 */
sealed abstract class Decl

sealed abstract class MarkupDecl extends Decl {
  override def toString(): String = sbToString(buildString)
  def buildString(sb: StringBuilder): StringBuilder
}

/**
 * an element declaration
 */
case class ElemDecl(name: String, contentModel: ContentModel)
  extends MarkupDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "'
  }
}

case class AttListDecl(name: String, attrs: List[AttrDecl])
  extends MarkupDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "")
  }
}

/**
 * an attribute declaration. at this point, the tpe is a string. Future
 *  versions might provide a way to access the attribute types more
 *  directly.
 */
case class AttrDecl(name: String, tpe: String, default: DefaultDecl) {
  override def toString(): String = sbToString(buildString)

  def buildString(sb: StringBuilder): StringBuilder = {
    sb append "  " append name append ' ' append tpe append ' '
    default buildString sb
  }

}

/** an entity declaration */
sealed abstract class EntityDecl extends MarkupDecl

/** a parsed general entity declaration */
case class ParsedEntityDecl(name: String, entdef: EntityDef) extends EntityDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "'
  }
}

/** a parameter entity declaration */
case class ParameterEntityDecl(name: String, entdef: EntityDef) extends EntityDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "'
  }
}

/** an unparsed entity declaration */
case class UnparsedEntityDecl(name: String, extID: ExternalID, notation: String) extends EntityDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "'
  }
}
/** a notation declaration */
case class NotationDecl(name: String, extID: ExternalID) extends MarkupDecl {
  override def buildString(sb: StringBuilder): StringBuilder = {
    sb append "




© 2015 - 2025 Weber Informatics LLC | Privacy Policy