Class/Object

scala.xml.parsing

ConstructingParser

Related Docs: object ConstructingParser | package parsing

Permalink

class ConstructingParser extends ConstructingHandler with ExternalSources with MarkupParser

An xml parser. parses XML and invokes callback methods of a MarkupHandler. Don't forget to call next.ch on a freshly instantiated parser in order to initialize it. If you get the parser from the object method, initialization is already done for you.

object parseFromURL {
  def main(args: Array[String]) {
    val url = args(0)
    val src = scala.io.Source.fromURL(url)
    val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false) // fromSource initializes automatically
    val doc = cpa.document()

    // let's see what it is
    val ppr = new scala.xml.PrettyPrinter(80, 5)
    val ele = doc.docElem
    println("finished parsing")
    val out = ppr.format(ele)
    println(out)
  }
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ConstructingParser
  2. MarkupParser
  3. MarkupParserCommon
  4. TokenTests
  5. ExternalSources
  6. ConstructingHandler
  7. MarkupHandler
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ConstructingParser(input: Source, preserveWS: Boolean)

    Permalink

Type Members

  1. type AttributesType = (MetaData, NamespaceBinding)

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  2. type ElementType = NodeSeq

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  3. type InputType = Source

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  4. type NamespaceType = NamespaceBinding

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  5. type PositionType = Int

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def appendText(pos: Int, ts: NodeBuffer, txt: String): Unit

    Permalink
    Definition Classes
    MarkupParser
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def attListDecl(name: String, attList: List[AttrDecl]): Unit

    Permalink
    Definition Classes
    MarkupHandler
  7. def attrDecl(): Unit

    Permalink

    <! attlist := ATTLIST
    Definition Classes
    MarkupParser
  8. val cbuf: collection.mutable.StringBuilder

    Permalink

    character buffer, for names

    character buffer, for names

    Attributes
    protected
    Definition Classes
    MarkupParser
  9. def ch: Char

    Permalink

    The library and compiler parsers had the interesting distinction of different behavior for nextch (a function for which there are a total of two plausible behaviors, so we know the design space was fully explored.) One of them returned the value of nextch before the increment and one of them the new value.

    The library and compiler parsers had the interesting distinction of different behavior for nextch (a function for which there are a total of two plausible behaviors, so we know the design space was fully explored.) One of them returned the value of nextch before the increment and one of them the new value. So to unify code we have to at least temporarily abstract over the nextchs.

    Definition Classes
    MarkupParser → MarkupParserCommon
  10. def ch_returning_nextch: Char

    Permalink
    Attributes
    protected
    Definition Classes
    MarkupParser → MarkupParserCommon
  11. def checkPubID(s: String): Boolean

    Permalink
    Definition Classes
    TokenTests
  12. def checkSysID(s: String): Boolean

    Permalink
    Definition Classes
    TokenTests
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def comment(pos: Int, txt: String): Comment

    Permalink

    callback method invoked by MarkupParser after parsing comment.

    callback method invoked by MarkupParser after parsing comment.

    Definition Classes
    ConstructingHandlerMarkupHandler
  15. def content(pscope: NamespaceBinding): NodeSeq

    Permalink

    content1 ::=  '<' content1 | '&' charref ...
    Definition Classes
    MarkupParser
  16. def content1(pscope: NamespaceBinding, ts: NodeBuffer): Unit

    Permalink

    '<' content1 ::=  ...
    Definition Classes
    MarkupParser
  17. var curInput: Source

    Permalink
    Attributes
    protected
    Definition Classes
    MarkupParser
  18. var decls: List[Decl]

    Permalink
    Definition Classes
    MarkupHandler
  19. var doc: Document

    Permalink
    Attributes
    protected
    Definition Classes
    MarkupParser
  20. def document(): Document

    Permalink

    [22]     prolog      ::= XMLDecl? Misc* (doctypedecl Misc*)?
    [23]     XMLDecl     ::= ' VersionInfo EncodingDecl? SDDecl? S? '?>'
    [24]     VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
    [25]     Eq          ::= S? '=' S?
    [26]     VersionNum  ::= '1.0'
    [27]     Misc        ::= Comment | PI | S
    Definition Classes
    MarkupParser
  21. var dtd: DTD

    Permalink
    Definition Classes
    MarkupParser
  22. def elem(pos: Int, pre: String, label: String, attrs: MetaData, pscope: NamespaceBinding, empty: Boolean, nodes: NodeSeq): NodeSeq

    Permalink

    callback method invoked by MarkupParser after parsing an element, between the elemStart and elemEnd callbacks

    callback method invoked by MarkupParser after parsing an element, between the elemStart and elemEnd callbacks

    pos

    the position in the source file

    pre

    the prefix

    label

    the local name

    attrs

    the attributes (metadata)

    empty

    true if the element was previously empty; false otherwise.

    Definition Classes
    ConstructingHandlerMarkupHandler
  23. def elemDecl(n: String, cmstr: String): Unit

    Permalink
    Definition Classes
    MarkupHandler
  24. def elemEnd(pos: Int, pre: String, label: String): Unit

    Permalink

    callback method invoked by MarkupParser after end-tag of element.

    callback method invoked by MarkupParser after end-tag of element.

    pos

    the position in the source file

    pre

    the prefix

    label

    the local name

    Definition Classes
    MarkupHandler
  25. def elemStart(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding): Unit

    Permalink

    callback method invoked by MarkupParser after start-tag of element.

    callback method invoked by MarkupParser after start-tag of element.

    pos

    the position in the sourcefile

    pre

    the prefix

    label

    the local name

    attrs

    the attributes (metadata)

    Definition Classes
    MarkupHandler
  26. def element(pscope: NamespaceBinding): NodeSeq

    Permalink
    Definition Classes
    MarkupParser
  27. def element1(pscope: NamespaceBinding): NodeSeq

    Permalink

    '<' element ::= xmlTag1 '>'  { xmlExpr | '{' simpleExpr '}' } ETag
                 | xmlTag1 '/' '>'
    Definition Classes
    MarkupParser
  28. def elementDecl(): Unit

    Permalink

    <! element := ELEMENT

    <! element := ELEMENT

    Definition Classes
    MarkupParser
  29. def endDTD(n: String): Unit

    Permalink
    Definition Classes
    MarkupHandler
  30. var ent: Map[String, EntityDecl]

    Permalink
    Definition Classes
    MarkupHandler
  31. def entityDecl(): Unit

    Permalink

    <! element := ELEMENT
    Definition Classes
    MarkupParser
  32. def entityRef(pos: Int, n: String): EntityRef

    Permalink

    callback method invoked by MarkupParser after parsing entity ref.

    callback method invoked by MarkupParser after parsing entity ref.

    Definition Classes
    ConstructingHandlerMarkupHandler
    To do

    expanding entity references

  33. def eof: Boolean

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  34. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  35. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  36. def errorAndResult[T](msg: String, x: T): T

    Permalink
    Attributes
    protected
    Definition Classes
    MarkupParserCommon
  37. def errorNoEnd(tag: String): Nothing

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  38. var extIndex: Int

    Permalink
    Definition Classes
    MarkupParser
  39. def extSubset(): Unit

    Permalink
    Definition Classes
    MarkupParser
  40. def externalID(): ExternalID

    Permalink

    externalID ::= SYSTEM S syslit
                   PUBLIC S pubid S syslit
    Definition Classes
    MarkupParser
  41. def externalSource(systemId: String): Source

    Permalink
    Definition Classes
    ExternalSources
  42. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  43. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  44. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  45. def initialize: ConstructingParser.this.type

    Permalink

    As the current code requires you to call nextch once manually after construction, this method formalizes that suboptimal reality.

    As the current code requires you to call nextch once manually after construction, this method formalizes that suboptimal reality.

    Definition Classes
    MarkupParser
  46. var inpStack: List[Source]

    Permalink

    stack of inputs

    stack of inputs

    Definition Classes
    MarkupParser
  47. val input: Source

    Permalink
    Definition Classes
    ConstructingParserMarkupParser
  48. def intSubset(): Unit

    Permalink

    "rec-xml/#ExtSubset" pe references may not occur within markup declarations

    "rec-xml/#ExtSubset" pe references may not occur within markup declarations

    Definition Classes
    MarkupParser
  49. def isAlpha(c: Char): Boolean

    Permalink

    These are 99% sure to be redundant but refactoring on the safe side.

    These are 99% sure to be redundant but refactoring on the safe side.

    Definition Classes
    TokenTests
  50. def isAlphaDigit(c: Char): Boolean

    Permalink
    Definition Classes
    TokenTests
  51. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  52. def isName(s: String): Boolean

    Permalink

    Name ::= ( Letter | '_' ) (NameChar)*

    See [5] of XML 1.0 specification.

    Definition Classes
    TokenTests
  53. def isNameChar(ch: Char): Boolean

    Permalink

    NameChar ::= Letter | Digit | '.' | '-' | '_' | ':'
               | CombiningChar | Extender

    See [4] and Appendix B of XML 1.0 specification.

    Definition Classes
    TokenTests
  54. def isNameStart(ch: Char): Boolean

    Permalink

    NameStart ::= ( Letter | '_' )

    where Letter means in one of the Unicode general categories { Ll, Lu, Lo, Lt, Nl }.

    We do not allow a name to start with :. See [3] and Appendix B of XML 1.0 specification

    Definition Classes
    TokenTests
  55. def isPubIDChar(ch: Char): Boolean

    Permalink
    Definition Classes
    TokenTests
  56. final def isSpace(cs: Seq[Char]): Boolean

    Permalink

    (#x20 | #x9 | #xD | #xA)+
    Definition Classes
    TokenTests
  57. final def isSpace(ch: Char): Boolean

    Permalink

    (#x20 | #x9 | #xD | #xA)
    Definition Classes
    TokenTests
  58. def isValidIANAEncoding(ianaEncoding: Seq[Char]): Boolean

    Permalink

    Returns true if the encoding name is a valid IANA encoding.

    Returns true if the encoding name is a valid IANA encoding. This method does not verify that there is a decoder available for this encoding, only that the characters are valid for an IANA encoding name.

    ianaEncoding

    The IANA encoding name.

    Definition Classes
    TokenTests
  59. val isValidating: Boolean

    Permalink

    returns true is this markup handler is validating

    returns true is this markup handler is validating

    Definition Classes
    MarkupHandler
  60. var lastChRead: Char

    Permalink
    Definition Classes
    MarkupParser
  61. def lookahead(): BufferedIterator[Char]

    Permalink

    Create a lookahead reader which does not influence the input

    Create a lookahead reader which does not influence the input

    Definition Classes
    MarkupParser → MarkupParserCommon
  62. def lookupElemDecl(Label: String): ElemDecl

    Permalink
    Definition Classes
    MarkupHandler
  63. def markupDecl(): Unit

    Permalink
    Definition Classes
    MarkupParser
  64. def markupDecl1(): Any

    Permalink
    Definition Classes
    MarkupParser
  65. def mkAttributes(name: String, pscope: NamespaceBinding): AttributesType

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  66. def mkProcInstr(position: Int, name: String, text: String): ElementType

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  67. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  68. var nextChNeeded: Boolean

    Permalink

    holds the next character

    holds the next character

    Definition Classes
    MarkupParser
  69. def nextch(): Unit

    Permalink

    this method tells ch to get the next character when next called

    this method tells ch to get the next character when next called

    Definition Classes
    MarkupParser → MarkupParserCommon
  70. def notationDecl(): Unit

    Permalink

    'N' notationDecl ::= "OTATION"
    Definition Classes
    MarkupParser
  71. def notationDecl(notat: String, extID: ExternalID): Unit

    Permalink
    Definition Classes
    MarkupHandler
  72. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  73. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  74. def parameterEntityDecl(name: String, edef: EntityDef): Unit

    Permalink
    Definition Classes
    MarkupHandler
  75. def parseDTD(): Unit

    Permalink

    parses document type declaration and assigns it to instance variable dtd.

    parses document type declaration and assigns it to instance variable dtd.

    <! parseDTD ::= DOCTYPE name ... >
    Definition Classes
    MarkupParser
  76. def parsedEntityDecl(name: String, edef: EntityDef): Unit

    Permalink
    Definition Classes
    MarkupHandler
  77. def peReference(name: String): Unit

    Permalink
    Definition Classes
    MarkupHandler
  78. def pop(): Unit

    Permalink
    Definition Classes
    MarkupParser
  79. var pos: Int

    Permalink

    holds the position in the source file

    holds the position in the source file

    Definition Classes
    MarkupParser
  80. val preserveWS: Boolean

    Permalink

    if true, does not remove surplus whitespace

    if true, does not remove surplus whitespace

    Definition Classes
    ConstructingParserMarkupParserConstructingHandler
  81. def procInstr(pos: Int, target: String, txt: String): ProcInstr

    Permalink

    callback method invoked by MarkupParser after parsing PI.

    callback method invoked by MarkupParser after parsing PI.

    Definition Classes
    ConstructingHandlerMarkupHandler
  82. def prolog(): (Option[String], Option[String], Option[Boolean])

    Permalink

    <? prolog ::= xml S?
    // this is a bit more lenient than necessary...
    Definition Classes
    MarkupParser
  83. def pubidLiteral(): String

    Permalink

    [12]       PubidLiteral ::=        '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
    Definition Classes
    MarkupParser
  84. def push(entityName: String): Unit

    Permalink
    Definition Classes
    MarkupParser
  85. def pushExternal(systemId: String): Unit

    Permalink
    Definition Classes
    MarkupParser
  86. def putChar(c: Char): collection.mutable.StringBuilder

    Permalink

    append Unicode character to name buffer

    append Unicode character to name buffer

    Attributes
    protected
    Definition Classes
    MarkupParser
  87. var reachedEof: Boolean

    Permalink
    Definition Classes
    MarkupParser
  88. def replacementText(entityName: String): Source

    Permalink
    Definition Classes
    MarkupHandler
  89. def reportSyntaxError(str: String): Unit

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  90. def reportSyntaxError(pos: Int, str: String): Unit

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  91. def reportValidationError(pos: Int, str: String): Unit

    Permalink
    Definition Classes
    MarkupParser
  92. def returning[T](x: T)(f: (T) ⇒ Unit): T

    Permalink

    Apply a function and return the passed value

    Apply a function and return the passed value

    Definition Classes
    MarkupParserCommon
  93. def saving[A, B](getter: A, setter: (A) ⇒ Unit)(body: ⇒ B): B

    Permalink

    Execute body with a variable saved and restored after execution

    Execute body with a variable saved and restored after execution

    Definition Classes
    MarkupParserCommon
  94. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  95. def systemLiteral(): String

    Permalink

    attribute value, terminated by either ' or ".

    attribute value, terminated by either ' or ". value may not contain <.

    AttValue     ::= `'` { _ } `'`
                   | `"` { _ } `"`
    Definition Classes
    MarkupParser
  96. def text(pos: Int, txt: String): Text

    Permalink

    callback method invoked by MarkupParser after parsing text.

    callback method invoked by MarkupParser after parsing text.

    Definition Classes
    ConstructingHandlerMarkupHandler
  97. def textDecl(): (Option[String], Option[String])

    Permalink

    prolog, but without standalone

    prolog, but without standalone

    Definition Classes
    MarkupParser
  98. var tmppos: Int

    Permalink

    holds temporary values of pos

    holds temporary values of pos

    Definition Classes
    MarkupParser → MarkupParserCommon
  99. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  100. def truncatedError(msg: String): Nothing

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  101. def unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit

    Permalink
    Definition Classes
    MarkupHandler
  102. def unreachable: Nothing

    Permalink
    Attributes
    protected
    Definition Classes
    MarkupParserCommon
  103. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  104. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  105. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  106. def xAttributeValue(): String

    Permalink
    Definition Classes
    MarkupParserCommon
  107. def xAttributeValue(endCh: Char): String

    Permalink

    attribute value, terminated by either ' or ".

    attribute value, terminated by either ' or ". value may not contain <.

    endCh

    either ' or "

    Definition Classes
    MarkupParserCommon
  108. def xAttributes(pscope: NamespaceBinding): (MetaData, NamespaceBinding)

    Permalink

    parse attribute and create namespace scope, metadata

    parse attribute and create namespace scope, metadata

    [41] Attributes    ::= { S Name Eq AttValue }
    Definition Classes
    MarkupParser
  109. def xCharData: NodeSeq

    Permalink

    '<! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]>'
    
    see [15]
    Definition Classes
    MarkupParser
  110. def xCharRef: String

    Permalink
    Definition Classes
    MarkupParserCommon
  111. def xCharRef(it: Iterator[Char]): String

    Permalink
    Definition Classes
    MarkupParserCommon
  112. def xCharRef(ch: () ⇒ Char, nextch: () ⇒ Unit): String

    Permalink

    CharRef ::= "&#" '0'..'9' {'0'..'9'} ";" | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"

    CharRef ::= "&#" '0'..'9' {'0'..'9'} ";" | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";"

    see [66]

    Definition Classes
    MarkupParserCommon
  113. def xComment: NodeSeq

    Permalink

     Comment ::= ''
    
    see [15]
    Definition Classes
    MarkupParser
  114. def xEQ(): Unit

    Permalink

    scan [S] '=' [S]

    scan [S] '=' [S]

    Definition Classes
    MarkupParserCommon
  115. def xEndTag(startName: String): Unit

    Permalink

    [42] '<' xmlEndTag ::= '<' '/' Name S? '>'

    [42] '<' xmlEndTag ::= '<' '/' Name S? '>'

    Definition Classes
    MarkupParserCommon
  116. def xEntityValue(): String

    Permalink

    entity value, terminated by either ' or ".

    entity value, terminated by either ' or ". value may not contain <.

    AttValue     ::= `'` { _  } `'`
                   | `"` { _ } `"`
    Definition Classes
    MarkupParser
  117. def xHandleError(that: Char, msg: String): Unit

    Permalink
    Definition Classes
    MarkupParser → MarkupParserCommon
  118. def xName: String

    Permalink

    actually, Name ::= (Letter | '_' | ':') (NameChar)* but starting with ':' cannot happen Name ::= (Letter | '_') (NameChar)*

    actually, Name ::= (Letter | '_' | ':') (NameChar)* but starting with ':' cannot happen Name ::= (Letter | '_') (NameChar)*

    see [5] of XML 1.0 specification

    pre-condition: ch != ':' // assured by definition of XMLSTART token post-condition: name does neither start, nor end in ':'

    Definition Classes
    MarkupParserCommon
  119. def xProcInstr: ElementType

    Permalink

    '<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>'

    '<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>'

    see [15]

    Definition Classes
    MarkupParserCommon
  120. def xSpace(): Unit

    Permalink

    scan [3] S ::= (#x20 | #x9 | #xD | #xA)+

    scan [3] S ::= (#x20 | #x9 | #xD | #xA)+

    Definition Classes
    MarkupParserCommon
  121. def xSpaceOpt(): Unit

    Permalink

    skip optional space S?

    skip optional space S?

    Definition Classes
    MarkupParserCommon
  122. def xTag(pscope: NamespaceType): (String, AttributesType)

    Permalink

    parse a start or empty tag.

    parse a start or empty tag. [40] STag ::= '<' Name { S Attribute } [S] [44] EmptyElemTag ::= '<' Name { S Attribute } [S]

    Attributes
    protected
    Definition Classes
    MarkupParserCommon
  123. def xTakeUntil[T](handler: (PositionType, String) ⇒ T, positioner: () ⇒ PositionType, until: String): T

    Permalink

    Take characters from input stream until given String "until" is seen.

    Take characters from input stream until given String "until" is seen. Once seen, the accumulated characters are passed along with the current Position to the supplied handler function.

    Attributes
    protected
    Definition Classes
    MarkupParserCommon
  124. def xToken(that: Seq[Char]): Unit

    Permalink
    Definition Classes
    MarkupParserCommon
  125. def xToken(that: Char): Unit

    Permalink
    Definition Classes
    MarkupParserCommon
  126. def xmlProcInstr(): MetaData

    Permalink

    <? prolog ::= xml S ... ?>
    Definition Classes
    MarkupParser

Deprecated Value Members

  1. def log(msg: String): Unit

    Permalink
    Definition Classes
    MarkupHandler
    Annotations
    @deprecated
    Deprecated

    (Since version 2.11) This method and its usages will be removed. Use a debugger to debug code.

Inherited from MarkupParser

Inherited from MarkupParserCommon

Inherited from TokenTests

Inherited from ExternalSources

Inherited from ConstructingHandler

Inherited from MarkupHandler

Inherited from AnyRef

Inherited from Any

Ungrouped