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) } }
- Alphabetic
- By Inheritance
- ConstructingParser
- MarkupParser
- MarkupParserCommon
- TokenTests
- ExternalSources
- ConstructingHandler
- MarkupHandler
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ConstructingParser(input: Source, preserveWS: Boolean)
Type Members
-
type
AttributesType = (MetaData, NamespaceBinding)
- Definition Classes
- MarkupParser → MarkupParserCommon
-
type
ElementType = NodeSeq
- Definition Classes
- MarkupParser → MarkupParserCommon
-
type
InputType = Source
- Definition Classes
- MarkupParser → MarkupParserCommon
-
type
NamespaceType = NamespaceBinding
- Definition Classes
- MarkupParser → MarkupParserCommon
-
type
PositionType = Int
- Definition Classes
- MarkupParser → MarkupParserCommon
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
appendText(pos: Int, ts: NodeBuffer, txt: String): Unit
- Definition Classes
- MarkupParser
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
attListDecl(name: String, attList: List[AttrDecl]): Unit
- Definition Classes
- MarkupHandler
-
def
attrDecl(): Unit
<! attlist := ATTLIST
- Definition Classes
- MarkupParser
-
val
cbuf: collection.mutable.StringBuilder
character buffer, for names
character buffer, for names
- Attributes
- protected
- Definition Classes
- MarkupParser
-
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
-
def
ch_returning_nextch: Char
- Attributes
- protected
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
checkPubID(s: String): Boolean
- Definition Classes
- TokenTests
-
def
checkSysID(s: String): Boolean
- Definition Classes
- TokenTests
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
comment(pos: Int, txt: String): Comment
callback method invoked by MarkupParser after parsing comment.
callback method invoked by MarkupParser after parsing comment.
- Definition Classes
- ConstructingHandler → MarkupHandler
-
def
content(pscope: NamespaceBinding): NodeSeq
content1 ::= '<' content1 | '&' charref ...
- Definition Classes
- MarkupParser
-
def
content1(pscope: NamespaceBinding, ts: NodeBuffer): Unit
'<' content1 ::= ...
- Definition Classes
- MarkupParser
-
val
curInput: Source
- Attributes
- protected
- Definition Classes
- MarkupParser
-
var
decls: List[Decl]
- Definition Classes
- MarkupHandler
-
val
doc: Document
- Attributes
- protected
- Definition Classes
- MarkupParser
-
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
- Definition Classes
- MarkupParser
-
val
dtd: DTD
- Definition Classes
- MarkupParser
-
def
elem(pos: Int, pre: String, label: String, attrs: MetaData, pscope: NamespaceBinding, empty: Boolean, nodes: NodeSeq): NodeSeq
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
- ConstructingHandler → MarkupHandler
-
def
elemDecl(n: String, cmstr: String): Unit
- Definition Classes
- MarkupHandler
-
def
elemEnd(pos: Int, pre: String, label: String): Unit
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
-
def
elemStart(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding): Unit
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
-
def
element(pscope: NamespaceBinding): NodeSeq
- Definition Classes
- MarkupParser
-
def
element1(pscope: NamespaceBinding): NodeSeq
'<' element ::= xmlTag1 '>' { xmlExpr | '{' simpleExpr '}' } ETag | xmlTag1 '/' '>'
- Definition Classes
- MarkupParser
-
def
elementDecl(): Unit
<! element := ELEMENT
<! element := ELEMENT
- Definition Classes
- MarkupParser
-
def
endDTD(n: String): Unit
- Definition Classes
- MarkupHandler
-
var
ent: Map[String, EntityDecl]
- Definition Classes
- MarkupHandler
-
def
entityDecl(): Unit
<! element := ELEMENT
- Definition Classes
- MarkupParser
-
def
entityRef(pos: Int, n: String): EntityRef
callback method invoked by MarkupParser after parsing entity ref.
callback method invoked by MarkupParser after parsing entity ref.
- Definition Classes
- ConstructingHandler → MarkupHandler
- To do
expanding entity references
-
def
eof: Boolean
- Definition Classes
- MarkupParser → MarkupParserCommon
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
errorAndResult[T](msg: String, x: T): T
- Attributes
- protected
- Definition Classes
- MarkupParserCommon
-
def
errorNoEnd(tag: String): Nothing
- Definition Classes
- MarkupParser → MarkupParserCommon
-
val
extIndex: Int
- Definition Classes
- MarkupParser
-
def
extSubset(): Unit
- Definition Classes
- MarkupParser
-
def
externalID(): ExternalID
externalID ::= SYSTEM S syslit PUBLIC S pubid S syslit
- Definition Classes
- MarkupParser
-
def
externalSource(systemId: String): Source
- Definition Classes
- ExternalSources
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
initialize: ConstructingParser.this.type
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
-
val
inpStack: List[Source]
stack of inputs
stack of inputs
- Definition Classes
- MarkupParser
-
val
input: Source
- Definition Classes
- ConstructingParser → MarkupParser
-
def
intSubset(): Unit
"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
-
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
-
def
isAlphaDigit(c: Char): Boolean
- Definition Classes
- TokenTests
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isName(s: String): Boolean
Name ::= ( Letter | '_' ) (NameChar)*
See [5] of XML 1.0 specification.
- Definition Classes
- TokenTests
-
def
isNameChar(ch: Char): Boolean
NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
See [4] and Appendix B of XML 1.0 specification.
- Definition Classes
- TokenTests
-
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
-
def
isPubIDChar(ch: Char): Boolean
- Definition Classes
- TokenTests
-
final
def
isSpace(cs: Seq[Char]): Boolean
(#x20 | #x9 | #xD | #xA)+
- Definition Classes
- TokenTests
-
final
def
isSpace(ch: Char): Boolean
(#x20 | #x9 | #xD | #xA)
- Definition Classes
- TokenTests
-
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
-
val
isValidating: Boolean
returns true is this markup handler is validating
returns true is this markup handler is validating
- Definition Classes
- MarkupHandler
-
val
lastChRead: Char
- Definition Classes
- MarkupParser
-
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
-
def
lookupElemDecl(Label: String): ElemDecl
- Definition Classes
- MarkupHandler
-
def
markupDecl(): Unit
- Definition Classes
- MarkupParser
-
def
markupDecl1(): Any
- Definition Classes
- MarkupParser
-
def
mkAttributes(name: String, pscope: NamespaceBinding): AttributesType
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
mkProcInstr(position: Int, name: String, text: String): ElementType
- Definition Classes
- MarkupParser → MarkupParserCommon
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
val
nextChNeeded: Boolean
holds the next character
holds the next character
- Definition Classes
- MarkupParser
-
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
-
def
notationDecl(): Unit
'N' notationDecl ::= "OTATION"
- Definition Classes
- MarkupParser
-
def
notationDecl(notat: String, extID: ExternalID): Unit
- Definition Classes
- MarkupHandler
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
parameterEntityDecl(name: String, edef: EntityDef): Unit
- Definition Classes
- MarkupHandler
-
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 ... >
- Definition Classes
- MarkupParser
-
def
parsedEntityDecl(name: String, edef: EntityDef): Unit
- Definition Classes
- MarkupHandler
-
def
peReference(name: String): Unit
- Definition Classes
- MarkupHandler
-
def
pop(): Unit
- Definition Classes
- MarkupParser
-
val
pos: Int
holds the position in the source file
holds the position in the source file
- Definition Classes
- MarkupParser
-
val
preserveWS: Boolean
if true, does not remove surplus whitespace
if true, does not remove surplus whitespace
- Definition Classes
- ConstructingParser → MarkupParser → ConstructingHandler
-
def
procInstr(pos: Int, target: String, txt: String): ProcInstr
callback method invoked by MarkupParser after parsing PI.
callback method invoked by MarkupParser after parsing PI.
- Definition Classes
- ConstructingHandler → MarkupHandler
-
def
prolog(): (Option[String], Option[String], Option[Boolean])
<? prolog ::= xml S? // this is a bit more lenient than necessary...
- Definition Classes
- MarkupParser
-
def
pubidLiteral(): String
[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
- Definition Classes
- MarkupParser
-
def
push(entityName: String): Unit
- Definition Classes
- MarkupParser
-
def
pushExternal(systemId: String): Unit
- Definition Classes
- MarkupParser
-
def
putChar(c: Char): collection.mutable.StringBuilder
append Unicode character to name buffer
append Unicode character to name buffer
- Attributes
- protected
- Definition Classes
- MarkupParser
-
val
reachedEof: Boolean
- Definition Classes
- MarkupParser
-
def
replacementText(entityName: String): Source
- Definition Classes
- MarkupHandler
-
def
reportSyntaxError(str: String): Unit
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
reportSyntaxError(pos: Int, str: String): Unit
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
reportValidationError(pos: Int, str: String): Unit
- Definition Classes
- MarkupParser
-
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
-
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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
systemLiteral(): String
attribute value, terminated by either ' or ".
attribute value, terminated by either ' or ". value may not contain <.
AttValue ::= `'` { _ } `'` | `"` { _ } `"`
- Definition Classes
- MarkupParser
-
def
text(pos: Int, txt: String): Text
callback method invoked by MarkupParser after parsing text.
callback method invoked by MarkupParser after parsing text.
- Definition Classes
- ConstructingHandler → MarkupHandler
-
def
textDecl(): (Option[String], Option[String])
prolog, but without standalone
prolog, but without standalone
- Definition Classes
- MarkupParser
-
val
tmppos: Int
holds temporary values of pos
holds temporary values of pos
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
truncatedError(msg: String): Nothing
- Definition Classes
- MarkupParser → MarkupParserCommon
-
def
unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit
- Definition Classes
- MarkupHandler
-
def
unreachable: Nothing
- Attributes
- protected
- Definition Classes
- MarkupParserCommon
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
xAttributeValue(): String
- Definition Classes
- MarkupParserCommon
-
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
-
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 }
- Definition Classes
- MarkupParser
-
def
xCharData: NodeSeq
'<! CharData ::= [CDATA[ ( {char} - {char}"]]>"{char} ) ']]>' see [15]
- Definition Classes
- MarkupParser
-
def
xCharRef: String
- Definition Classes
- MarkupParserCommon
-
def
xCharRef(it: Iterator[Char]): String
- Definition Classes
- MarkupParserCommon
-
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
-
def
xComment: NodeSeq
Comment ::= '' see [15]
- Definition Classes
- MarkupParser
-
def
xEQ(): Unit
scan [S] '=' [S]
scan [S] '=' [S]
- Definition Classes
- MarkupParserCommon
-
def
xEndTag(startName: String): Unit
[42] '<' xmlEndTag ::= '<' '/' Name S? '>'
[42] '<' xmlEndTag ::= '<' '/' Name S? '>'
- Definition Classes
- MarkupParserCommon
-
def
xEntityValue(): String
entity value, terminated by either ' or ".
entity value, terminated by either ' or ". value may not contain <.
AttValue ::= `'` { _ } `'` | `"` { _ } `"`
- Definition Classes
- MarkupParser
-
def
xHandleError(that: Char, msg: String): Unit
- Definition Classes
- MarkupParser → MarkupParserCommon
-
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
-
def
xProcInstr: ElementType
'<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>'
'<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>'
see [15]
- Definition Classes
- MarkupParserCommon
-
def
xSpace(): Unit
scan [3] S ::= (#x20 | #x9 | #xD | #xA)+
scan [3] S ::= (#x20 | #x9 | #xD | #xA)+
- Definition Classes
- MarkupParserCommon
-
def
xSpaceOpt(): Unit
skip optional space S?
skip optional space S?
- Definition Classes
- MarkupParserCommon
-
def
xTag(pscope: NamespaceType): (String, AttributesType)
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
-
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
-
def
xToken(that: Seq[Char]): Unit
- Definition Classes
- MarkupParserCommon
-
def
xToken(that: Char): Unit
- Definition Classes
- MarkupParserCommon
-
def
xmlProcInstr(): MetaData
<? prolog ::= xml S ... ?>
- Definition Classes
- MarkupParser
Deprecated Value Members
-
def
log(msg: String): Unit
- Definition Classes
- MarkupHandler
- Annotations
- @deprecated
- Deprecated
(Since version 2.11) This method and its usages will be removed. Use a debugger to debug code.