scala.xml.parsing

trait MarkupParser

[source: scala/xml/parsing/MarkupParser.scala]

trait MarkupParser
extends 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.
Author
Burak Emir
Version
1.0
Direct Known Subclasses:
ConstructingParser, XMLEventReader.Parser

Value Summary
protected val cbuf : StringBuilder
character buffer, for names
var ch : Char
holds the next character
var curInput : Source
protected var doc : Document
var dtd : DTD
var eof : Boolean
var extIndex : Int
var inpStack : List[Source]
stack of inputs
abstract val input : Source
var pos : Int
holds the position in the source file
abstract val preserveWS : Boolean
if true, does not remove surplus whitespace
var tmppos : Int
holds temporary values of pos
Method Summary
def appendText (pos : Int, ts : NodeBuffer, txt : java.lang.String) : Unit
def attrDecl : Unit
<! attlist := ATTLIST
def content (pscope : NamespaceBinding) : NodeSeq
content1 ::= '<' content1 | '&' charref ...
def content1 (pscope : NamespaceBinding, ts : NodeBuffer) : Unit
'<' content1 ::= ...
def document : Document
[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') [25] Eq ::= S? '=' S? [26] VersionNum ::= '1.0' [27] Misc ::= Comment | PI | S
def element (pscope : NamespaceBinding) : NodeSeq
def element1 (pscope : NamespaceBinding) : NodeSeq
'<' element ::= xmlTag1 '>' { xmlExpr | '{' simpleExpr '}' } ETag | xmlTag1 '/' '>'
def elementDecl : Unit
<! element := ELEMENT
def entityDecl : Unit
<! element := ELEMENT
def extSubset : Unit
def externalID : ExternalID
externalID ::= SYSTEM S syslit PUBLIC S pubid S syslit
abstract def externalSource (systemLiteral : java.lang.String) : Source
def intSubset : Unit
"rec-xml/#ExtSubset" pe references may not occur within markup declarations
def markupDecl : Unit
def markupDecl1 : Any
def nextch : Unit
this method assign the next character to ch and advances in input
def normalizeAttributeValue (attval : java.lang.String) : java.lang.String
for the moment, replace only character references see spec 3.3.3 precond: cbuf empty
def notationDecl : Unit
'N' notationDecl ::= "OTATION"
def parseDTD : Unit
parses document type declaration and assigns it to instance variable dtd. <! parseDTD ::= DOCTYPE name ... >
def pop : Unit
def prolog : (Option[java.lang.String], Option[java.lang.String], Option[Boolean])
<? prolog ::= xml S // this is a bit more lenient than necessary...
def pubidLiteral : java.lang.String
def push (entityName : java.lang.String) : Unit
def pushExternal (systemId : java.lang.String) : Unit
protected def putChar (c : Char) : StringBuilder
append Unicode character to name buffer
def reportSyntaxError (pos : Int, str : java.lang.String) : Unit
report a syntax error
def reportSyntaxError (str : java.lang.String) : Unit
def reportValidationError (pos : Int, str : java.lang.String) : Unit
report a syntax error
def systemLiteral : java.lang.String
attribute value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`
def textDecl : (Option[java.lang.String], Option[java.lang.String])
prolog, but without standalone
def xAttributeValue : java.lang.String
attribute value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`
def xAttributes (pscope : NamespaceBinding) : (MetaData, NamespaceBinding)
parse attribute and create namespace scope, metadata [41] Attributes ::= { S Name Eq AttValue }
def xCharData : NodeSeq
'<! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]>' see [15]
def xCharRef (ch : () => Char, nextch : () => Unit) : java.lang.String
CharRef ::= "&#" '0'..'9' {'0'..'9'} ";" | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";" see [66]
def xComment : NodeSeq
Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-'))) '-->' see [15]
def xEQ : Unit
scan [S] '=' [S]
def xEndTag (n : java.lang.String) : Unit
[42] '<' xmlEndTag ::= '<' '/' Name S? '>'
def xEntityValue : java.lang.String
entity value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`
def xName : java.lang.String
Name ::= (Letter | '_' | ':') (NameChar) see [5] of XML 1.0 specification
def xProcInstr : NodeSeq
'<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>' see [15]
def xSpace : Unit
scan [3] S ::= (#x20 | #x9 | #xD | #xA)+
def xSpaceOpt : Unit
skip optional space S?
protected def xTag (pscope : NamespaceBinding) : (java.lang.String, MetaData, NamespaceBinding)
parse a start or empty tag. [40] STag ::= '<' Name { S Attribute } [S] [44] EmptyElemTag ::= '<' Name { S Attribute } [S]
def xText : java.lang.String
parse character data. precondition: xEmbeddedBlock == false (we are not in a scala block)
def xToken (that : Seq[Char]) : Unit
def xToken (that : Char) : Unit
munch expected XML token, report syntax error for unexpected
def xmlProcInstr : MetaData
<? prolog ::= xml S ... ?>
Methods inherited from TokenTests
isSpace, isSpace, isNameChar, isNameStart, isName, isPubIDChar, isValidIANAEncoding, checkSysID, checkPubID
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
abstract val input : Source

abstract val preserveWS : Boolean
if true, does not remove surplus whitespace

var curInput : Source

var inpStack : List[Source]
stack of inputs

var pos : Int
holds the position in the source file

var extIndex : Int

var tmppos : Int
holds temporary values of pos

var ch : Char
holds the next character

protected val cbuf : StringBuilder
character buffer, for names

var dtd : DTD

protected var doc : Document

var eof : Boolean

Method Details
abstract def externalSource(systemLiteral : java.lang.String) : Source

def xmlProcInstr : MetaData
<? prolog ::= xml S ... ?>

def prolog : (Option[java.lang.String], Option[java.lang.String], Option[Boolean])
<? prolog ::= xml S // this is a bit more lenient than necessary...

def textDecl : (Option[java.lang.String], Option[java.lang.String])
prolog, but without standalone

def document : Document
[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') [25] Eq ::= S? '=' S? [26] VersionNum ::= '1.0' [27] Misc ::= Comment | PI | S

protected def putChar(c : Char) : StringBuilder
append Unicode character to name buffer

def nextch : Unit
this method assign the next character to ch and advances in input

def xToken(that : Char) : Unit
munch expected XML token, report syntax error for unexpected

def xToken(that : Seq[Char]) : Unit

def xAttributes(pscope : NamespaceBinding) : (MetaData, NamespaceBinding)
parse attribute and create namespace scope, metadata [41] Attributes ::= { S Name Eq AttValue }

def xAttributeValue : java.lang.String
attribute value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`

def xEntityValue : java.lang.String
entity value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`

protected def xTag(pscope : NamespaceBinding) : (java.lang.String, MetaData, NamespaceBinding)
parse a start or empty tag. [40] STag ::= '<' Name { S Attribute } [S] [44] EmptyElemTag ::= '<' Name { S Attribute } [S]

def xEndTag(n : java.lang.String) : Unit
[42] '<' xmlEndTag ::= '<' '/' Name S? '>'

def xCharData : NodeSeq
'<! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]>' see [15]

def xCharRef(ch : () => Char, nextch : () => Unit) : java.lang.String
CharRef ::= "&#" '0'..'9' {'0'..'9'} ";" | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";" see [66]

def xComment : NodeSeq
Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-'))) '-->' see [15]

def appendText(pos : Int, ts : NodeBuffer, txt : java.lang.String) : Unit

def content1(pscope : NamespaceBinding, ts : NodeBuffer) : Unit
'<' content1 ::= ...

def content(pscope : NamespaceBinding) : NodeSeq
content1 ::= '<' content1 | '&' charref ...

def externalID : ExternalID
externalID ::= SYSTEM S syslit PUBLIC S pubid S syslit

def parseDTD : Unit
parses document type declaration and assigns it to instance variable dtd. <! parseDTD ::= DOCTYPE name ... >

def element(pscope : NamespaceBinding) : NodeSeq

def element1(pscope : NamespaceBinding) : NodeSeq
'<' element ::= xmlTag1 '>' { xmlExpr | '{' simpleExpr '}' } ETag | xmlTag1 '/' '>'

def xName : java.lang.String
Name ::= (Letter | '_' | ':') (NameChar) see [5] of XML 1.0 specification

def xEQ : Unit
scan [S] '=' [S]

def xSpaceOpt : Unit
skip optional space S?

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

def xProcInstr : NodeSeq
'<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>' see [15]

def xText : java.lang.String
parse character data. precondition: xEmbeddedBlock == false (we are not in a scala block)

def systemLiteral : java.lang.String
attribute value, terminated by either ' or ". value may not contain <. AttValue ::= `'` { _ } `'` | `"` { _ } `"`

def pubidLiteral : java.lang.String

def extSubset : Unit

def markupDecl1 : Any

def markupDecl : Unit

def intSubset : Unit
"rec-xml/#ExtSubset" pe references may not occur within markup declarations

def elementDecl : Unit
<! element := ELEMENT

def attrDecl : Unit
<! attlist := ATTLIST

def entityDecl : Unit
<! element := ELEMENT

def notationDecl : Unit
'N' notationDecl ::= "OTATION"

def reportSyntaxError(pos : Int, str : java.lang.String) : Unit
report a syntax error

def reportSyntaxError(str : java.lang.String) : Unit

def reportValidationError(pos : Int, str : java.lang.String) : Unit
report a syntax error

def push(entityName : java.lang.String) : Unit

def pushExternal(systemId : java.lang.String) : Unit

def pop : Unit

def normalizeAttributeValue(attval : java.lang.String) : java.lang.String
for the moment, replace only character references see spec 3.3.3 precond: cbuf empty