t

scala.xml.parsing

MarkupParser

trait MarkupParser extends MarkupParserCommon with TokenTests

An XML parser.

Parses XML 1.0, invokes callback methods of a MarkupHandler and returns whatever the markup handler returns. Use ConstructingParser if you just want to parse XML to construct instances of scala.xml.Node.

While XML elements are returned, DTD declarations - if handled - are collected using side-effects.

Self Type
MarkupParser with MarkupHandler
Version

1.0

Linear Supertypes
MarkupParserCommon, TokenTests, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MarkupParser
  2. MarkupParserCommon
  3. TokenTests
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type AttributesType = (MetaData, NamespaceBinding)
    Definition Classes
    MarkupParser → MarkupParserCommon
  2. type ElementType = NodeSeq
    Definition Classes
    MarkupParser → MarkupParserCommon
  3. type InputType = Source
    Definition Classes
    MarkupParser → MarkupParserCommon
  4. type NamespaceType = NamespaceBinding
    Definition Classes
    MarkupParser → MarkupParserCommon
  5. type PositionType = Int
    Definition Classes
    MarkupParser → MarkupParserCommon

Abstract Value Members

  1. abstract def externalSource(systemLiteral: String): Source
  2. abstract val input: Source
  3. abstract val preserveWS: Boolean

    if true, does not remove surplus whitespace

Concrete Value Members

  1. def appendText(pos: Int, ts: NodeBuffer, txt: String): Unit
  2. def attrDecl(): Unit

    <! attlist := ATTLIST
  3. def ch: Char

    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
  4. def checkPubID(s: String): Boolean
    Definition Classes
    TokenTests
  5. def checkSysID(s: String): Boolean
    Definition Classes
    TokenTests
  6. def content(pscope: NamespaceBinding): NodeSeq

    content1 ::=  '<' content1 | '&' charref ...
  7. def content1(pscope: NamespaceBinding, ts: NodeBuffer): Unit

    '<' content1 ::=  ...
  8. def document(): Document

    [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
  9. val dtd: DTD
  10. def element(pscope: NamespaceBinding): NodeSeq
  11. def element1(pscope: NamespaceBinding): NodeSeq

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

    <! element := ELEMENT

  13. def entityDecl(): Unit

    <! element := ELEMENT
  14. def eof: Boolean
    Definition Classes
    MarkupParser → MarkupParserCommon
  15. def errorNoEnd(tag: String): Nothing
    Definition Classes
    MarkupParser → MarkupParserCommon
  16. val extIndex: Int
  17. def extSubset(): Unit
  18. def externalID(): ExternalID

    externalID ::= SYSTEM S syslit
                   PUBLIC S pubid S syslit
  19. def initialize: MarkupParser.this

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

  20. val inpStack: List[Source]

    stack of inputs

  21. def intSubset(): Unit

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

  22. def isAlpha(c: Char): Boolean

    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
  23. def isAlphaDigit(c: Char): Boolean
    Definition Classes
    TokenTests
  24. def isName(s: String): Boolean

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

    See [5] of XML 1.0 specification.

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

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

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

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

    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
  27. def isPubIDChar(ch: Char): Boolean
    Definition Classes
    TokenTests
  28. final def isSpace(cs: Seq[Char]): Boolean

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

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

    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
  31. val lastChRead: Char
  32. def lookahead(): BufferedIterator[Char]

    Create a lookahead reader which does not influence the input

    Create a lookahead reader which does not influence the input

    Definition Classes
    MarkupParser → MarkupParserCommon
  33. def markupDecl(): Unit
  34. def markupDecl1(): Any
  35. def mkAttributes(name: String, pscope: NamespaceBinding): (MarkupParser.this)#AttributesType
    Definition Classes
    MarkupParser → MarkupParserCommon
  36. def mkProcInstr(position: Int, name: String, text: String): (MarkupParser.this)#ElementType
    Definition Classes
    MarkupParser → MarkupParserCommon
  37. val nextChNeeded: Boolean

    holds the next character

  38. def nextch(): Unit

    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
  39. def notationDecl(): Unit

    'N' notationDecl ::= "OTATION"
  40. def parseDTD(): Unit

    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 ... >
  41. def pop(): Unit
  42. val pos: Int

    holds the position in the source file

  43. def prolog(): (Option[String], Option[String], Option[Boolean])

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

    [12]       PubidLiteral ::=        '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
  45. def push(entityName: String): Unit
  46. def pushExternal(systemId: String): Unit
  47. val reachedEof: Boolean
  48. def reportSyntaxError(str: String): Unit
    Definition Classes
    MarkupParser → MarkupParserCommon
  49. def reportSyntaxError(pos: Int, str: String): Unit
    Definition Classes
    MarkupParser → MarkupParserCommon
  50. def reportValidationError(pos: Int, str: String): Unit
  51. def returning[T](x: T)(f: (T) ⇒ Unit): T

    Apply a function and return the passed value

    Apply a function and return the passed value

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

    Execute body with a variable saved and restored after execution

    Execute body with a variable saved and restored after execution

    Definition Classes
    MarkupParserCommon
  53. def systemLiteral(): String

    attribute value, terminated by either ' or ".

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

    AttValue     ::= `'` { _ } `'`
                   | `"` { _ } `"`
  54. def textDecl(): (Option[String], Option[String])

    prolog, but without standalone

  55. val tmppos: Int

    holds temporary values of pos

    holds temporary values of pos

    Definition Classes
    MarkupParser → MarkupParserCommon
  56. def truncatedError(msg: String): Nothing
    Definition Classes
    MarkupParser → MarkupParserCommon
  57. def xAttributeValue(): String
    Definition Classes
    MarkupParserCommon
  58. def xAttributeValue(endCh: Char): String

    attribute value, terminated by either ' or ".

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

    endCh

    either ' or "

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

    parse attribute and create namespace scope, metadata

    parse attribute and create namespace scope, metadata

    [41] Attributes    ::= { S Name Eq AttValue }
  60. def xCharData: NodeSeq

    '<! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]>'
    
    see [15]
  61. def xCharRef: String
    Definition Classes
    MarkupParserCommon
  62. def xCharRef(it: Iterator[Char]): String
    Definition Classes
    MarkupParserCommon
  63. def xCharRef(ch: () ⇒ Char, nextch: () ⇒ Unit): String

    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
  64. def xComment: NodeSeq

     Comment ::= ''
    
    see [15]
  65. def xEQ(): Unit

    scan [S] '=' [S]

    scan [S] '=' [S]

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

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

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

    Definition Classes
    MarkupParserCommon
  67. def xEntityValue(): String

    entity value, terminated by either ' or ".

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

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

    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
  70. def xProcInstr: (MarkupParser.this)#ElementType

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

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

    see [15]

    Definition Classes
    MarkupParserCommon
  71. def xSpace(): Unit

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

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

    Definition Classes
    MarkupParserCommon
  72. def xSpaceOpt(): Unit

    skip optional space S?

    skip optional space S?

    Definition Classes
    MarkupParserCommon
  73. def xToken(that: Seq[Char]): Unit
    Definition Classes
    MarkupParserCommon
  74. def xToken(that: Char): Unit
    Definition Classes
    MarkupParserCommon
  75. def xmlProcInstr(): MetaData

    <? prolog ::= xml S ... ?>