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
Source
MarkupParser.scala
Version

1.0

Linear Supertypes
MarkupParserCommon, TokenTests, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MarkupParser
  2. MarkupParserCommon
  3. TokenTests
  4. AnyRef
  5. Any
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. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Test two objects for inequality.

    Test two objects for inequality.

    returns

    true if !(this == that), false otherwise.

    Definition Classes
    Any
  3. final def ##(): Int

    Equivalent to x.hashCode except for boxed numeric types and null.

    Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.

    returns

    a hash value consistent with ==

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Test two objects for equality.

    Test two objects for equality. The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Definition Classes
    Any
  6. def appendText(pos: Int, ts: NodeBuffer, txt: String): Unit

  7. final def asInstanceOf[T0]: T0

    Cast the receiver object to be of type T0.

    Cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

    returns

    the receiver object.

    Definition Classes
    Any
    Exceptions thrown
    ClassCastException

    if the receiver object is not an instance of the erasure of type T0.

  8. def attrDecl(): Unit

     <! attlist := ATTLIST
    
  9. val cbuf: StringBuilder

    character buffer, for names

    character buffer, for names

    Attributes
    protected
  10. 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.

    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
  11. def ch_returning_nextch: Char

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

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

    Definition Classes
    TokenTests
  14. def clone(): AnyRef

    Create a copy of the receiver object.

    Create a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
    Note

    not specified by SLS as a member of AnyRef

  15. def content(pscope: NamespaceBinding): NodeSeq

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

     '<' content1 ::=  ...
    
  17. var curInput: Source

    Attributes
    protected
  18. var doc: Document

    Attributes
    protected
  19. 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
    
  20. var dtd: DTD

  21. def element(pscope: NamespaceBinding): NodeSeq

  22. def element1(pscope: NamespaceBinding): NodeSeq

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

    <! element := ELEMENT

    <! element := ELEMENT

  24. def entityDecl(): Unit

     &lt;! element := ELEMENT
    
  25. def eof: Boolean

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

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an equivalence relation on non-null instances of AnyRef, and has three additional properties:

    • It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
    • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
    • null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    returns

    true if the argument is a reference to the receiver object; false otherwise.

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

    The equality method for reference types.

    The equality method for reference types. Default implementation delegates to eq.

    See also equals in Any.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

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

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

    Definition Classes
    MarkupParser → MarkupParserCommon
  30. var extIndex: Int

  31. def extSubset(): Unit

  32. def externalID(): ExternalID

     externalID ::= SYSTEM S syslit
                    PUBLIC S pubid S syslit
    
  33. def finalize(): Unit

    Called by the garbage collector on the receiver object when there are no more references to the object.

    Called by the garbage collector on the receiver object when there are no more references to the object.

    The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
    Note

    not specified by SLS as a member of AnyRef

  34. final def getClass(): Class[_]

    A representation that corresponds to the dynamic class of the receiver object.

    A representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    Definition Classes
    AnyRef → Any
    Note

    not specified by SLS as a member of AnyRef

  35. def hashCode(): Int

    The hashCode method for reference types.

    The hashCode method for reference types. See hashCode in Any.

    returns

    the hash code value for this object.

    Definition Classes
    AnyRef → Any
  36. def initialize: MarkupParser.this.type

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

  37. var inpStack: List[Source]

    stack of inputs

  38. def intSubset(): Unit

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

  39. 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
  40. def isAlphaDigit(c: Char): Boolean

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

    Test whether the dynamic type of the receiver object is T0.

    Test whether the dynamic type of the receiver object is T0.

    Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

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

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

    See [5] of XML 1.0 specification.

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

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

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

    Definition Classes
    TokenTests
  44. 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
  45. def isPubIDChar(ch: Char): Boolean

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

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

     (#x20 | #x9 | #xD | #xA)
    
    Definition Classes
    TokenTests
  48. 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
  49. var lastChRead: Char

  50. 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
  51. def markupDecl(): Unit

  52. def markupDecl1(): Any

  53. def mkAttributes(name: String, pscope: NamespaceBinding): (MetaData, NamespaceBinding)

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

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

    Equivalent to !(this eq that).

    Equivalent to !(this eq that).

    returns

    true if the argument is not a reference to the receiver object; false otherwise.

    Definition Classes
    AnyRef
  56. var nextChNeeded: Boolean

    holds the next character

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

     'N' notationDecl ::= "OTATION"
    
  59. final def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Note

    not specified by SLS as a member of AnyRef

  60. final def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Note

    not specified by SLS as a member of AnyRef

  61. 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.

     &lt;! parseDTD ::= DOCTYPE name ... >
    
  62. def pop(): Unit

  63. var pos: Int

    holds the position in the source file

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

     &lt;? prolog ::= xml S?
     // this is a bit more lenient than necessary...
    
  65. def pubidLiteral(): String

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

  67. def pushExternal(systemId: String): Unit

  68. def putChar(c: Char): StringBuilder

    append Unicode character to name buffer

    append Unicode character to name buffer

    Attributes
    protected
  69. var reachedEof: Boolean

  70. def reportSyntaxError(str: String): Unit

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

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

  73. 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
  74. 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
  75. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  76. def systemLiteral(): String

    attribute value, terminated by either ' or ".

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

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

    prolog, but without standalone

  78. var tmppos: Int

    holds temporary values of pos

    holds temporary values of pos

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

    Creates a String representation of this object.

    Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

    returns

    a String representation of the object.

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

    Definition Classes
    MarkupParser → MarkupParserCommon
  81. def unreachable: Nothing

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

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

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

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

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

    attribute value, terminated by either ' or ".

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

    Definition Classes
    MarkupParserCommon
  87. 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 }
    
  88. def xCharData: NodeSeq

     '&lt;! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]&gt;'
    
     see [15]
    
  89. def xCharRef: String

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

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

    CharRef ::= "&#" '0'.

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

    see [66]

    Definition Classes
    MarkupParserCommon
  92. def xComment: NodeSeq

     Comment ::= '&lt;!--' ((Char - '-') | ('-' (Char - '-')))* '--&gt;'
    
    see [15]
    
  93. def xEQ(): Unit

    scan [S] '=' [S]

    scan [S] '=' [S]

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

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

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

    Definition Classes
    MarkupParserCommon
  95. def xEntityValue(): String

    entity value, terminated by either ' or ".

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

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

    Definition Classes
    MarkupParser → MarkupParserCommon
  97. 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
  98. def xProcInstr: ElementType

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

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

    see [15]

    Definition Classes
    MarkupParserCommon
  99. def xSpace(): Unit

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

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

    Definition Classes
    MarkupParserCommon
  100. def xSpaceOpt(): Unit

    skip optional space S?

    skip optional space S?

    Definition Classes
    MarkupParserCommon
  101. def xTag(pscope: NamespaceType): (String, (MetaData, NamespaceBinding))

    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
  102. def xTakeUntil[T](handler: (PositionType, String) ⇒ T, positioner: () ⇒ PositionType, until: String): T

    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
  103. def xToken(that: Seq[Char]): Unit

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

    Definition Classes
    MarkupParserCommon
  105. def xmlProcInstr(): MetaData

     &lt;? prolog ::= xml S ... ?&gt;
    

Inherited from MarkupParserCommon

Inherited from TokenTests

Inherited from AnyRef

Inherited from Any