XML-Parser

DTDEntityDeclaration
A DTDEntityDeclaration is xxxxxxxxx.
Instance Variables
name: <Object>
ndata: <Object>
value: <Object>
name
- xxxxx
ndata
- xxxxx
value
- xxxxx
behaviorForContext:
bypass
Return my reference as is.
contextBehavior
forbidden
include
Return my expanded value.
includedInLiteral
Return my expanded value.
initialize
Subclasses should redefine this method to perform initializations on instance creation
leadIn
name
Answer a name for the receiver. This is used generically in the title of certain inspectors, such as the referred-to inspector, and specificially by various subsystems. By default, we let the object just print itself out..
name:
name:value:
ndata
ndata:
reference
Return my reference as is.
registerIn:
value
value:
valueForContext:
DTDExternalEntityDeclaration
A DTDExternalEntityDeclaration is xxxxxxxxx.
Instance Variables
initialize
Subclasses should redefine this method to perform initializations on instance creation
DTDParameterEntityDeclaration
A DTDParameterEntityDeclaration is xxxxxxxxx.
Instance Variables
includePE
Return my expanded value.
initialize
Subclasses should redefine this method to perform initializations on instance creation
leadIn
notRecognized
registerIn:
SAXDriver
A SAXDriver is xxxxxxxxx.
Instance Variables
languageEnvironment: <Object>
saxHandler: <Object>
scope: <Object>
useNamespaces: <Object>
validateAttributes: <Object>
languageEnvironment
- xxxxx
saxHandler
- xxxxx
scope
- xxxxx
useNamespaces
- xxxxx
validateAttributes
- xxxxx
handleCData:
handleComment:
handleEndDocument
handleEndTag:
handlePCData:
handlePI:data:
handleStartDocument
handleStartTag:attributes:namespaces:
handleWhitespace:
handleXMLDecl:namespaces:
initialize
Subclasses should redefine this method to perform initializations on instance creation
languageEnvironment
saxHandler
saxHandler:
scope
splitName:into:
Split the name into namespace and local name (the block arguments).
Handle both qualified and unqualified names using the default name space
useNamespaces:
usesNamespaces
validatesAttributes
SAXException
A SAXException is xxxxxxxxx.
Instance Variables
SAXHandler
A SAXHandler is xxxxxxxxx.
Instance Variables
document: <Object>
driver: <Object>
eod: <Object>
document
- xxxxx
driver
- xxxxx
eod
- xxxxx
characters:
This call corresponds to the Java SAX call
characters(char[] ch, int start, int length).
checkEOD
Check if the document shouldn't be ended already
comment:
This call corresponds to the Java SAX ext call
comment(char[] ch, int start, int length).
document
document:
documentAttributes:
driver
driver:
endDocument
This call corresponds to the Java SAX call
endDocument().
endElement:
endElement:namespace:namespaceURI:qualifiedName:
This call corresponds to the Java SAX call
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName).
By default this call is mapped to the following more convenient call:
endEntity:
This call corresponds to the Java SAX ext call
endEntity(java.lang.String name).
endPrefixMapping:
This call corresonds to the Java SAX call
endPrefixMapping(java.lang.String prefix).
eod
ignorableWhitespace:
This call corresonds to the Java SAX call
ignorableWhitespace(char[] ch, int start, int length).
initialize
Subclasses should redefine this method to perform initializations on instance creation
on:
parseDTDFrom:
parseDocument
parseDocumentFrom:
parseDocumentFrom:useNamespaces:
parseDocumentFromFileNamed:
parseDocumentFromFileNamed:readIntoMemory:
parserOnFileNamed:
parserOnFileNamed:readIntoMemory:
processingInstruction:data:
This call corresonds to the Java SAX call
processingInstruction(java.lang.String target, java.lang.String data).
resolveEntity:systemID:
This call corresonds to the Java SAX call
resolveEntity(java.lang.String publicId, java.lang.String systemId).
skippedEntity:
This call corresonds to the Java SAX call
skippedEntity(java.lang.String name).
startCData
This call corresponds to the Java SAX ext call
startCData().
startDTD:publicID:systemID:
This call corresponds to the Java SAX ext call
startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId).
startDocument
This call corresonds to the Java SAX call
startDocument().
startElement:attributeList:
startElement:namespaceURI:namespace:attributeList:
This call corresonds to the Java SAX call
startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, Attributes atts).
By default this call is mapped to the following more convenient call:
startEntity:
This call corresponds to the Java SAX ext call
startEntity(java.lang.String name).
startPrefixMapping:uri:
This call corresonds to the Java SAX call
startPrefixMapping(java.lang.String prefix, java.lang.String uri).
useNamespaces:
SAXMalformedException
A SAXMalformedException is xxxxxxxxx.
Instance Variables
SAXParseException
A SAXParseException is xxxxxxxxx.
Instance Variables
SAXWarning
A SAXWarning is xxxxxxxxx.
Instance Variables
XMLDOMParser
A XMLDOMParser is xxxxxxxxx.
Instance Variables
entity: <Object>
incremental: <Object>
stack: <Object>
entity
- xxxxx
incremental
- xxxxx
stack
- xxxxx
addressBookXMLWithDTD
characters:
This call corresponds to the Java SAX call
characters(char[] ch, int start, int length).
defaultNamespace
documentAttributes:
domDocument
endDocument
This call corresponds to the Java SAX call
endDocument().
endElement:
endElement:namespace:namespaceURI:qualifiedName:
This call corresponds to the Java SAX call
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName).
By default this call is mapped to the following more convenient call:
incremental
incremental:
initialize
Subclasses should redefine this method to perform initializations on instance creation
nextEntity
nextEntityStart
parseDocumentFrom:
parseDocumentFrom:useNamespaces:
pop
processingInstruction:data:
This call corresonds to the Java SAX call
processingInstruction(java.lang.String target, java.lang.String data).
push:
stack
startDocument
This call corresonds to the Java SAX call
startDocument().
startElement:attributeList:
startElement:namespaceURI:namespace:attributeList:
newElement := namespace = self defaultNamespace
ifTrue: [XMLElement named: localName namespace: nil uri: nil attributes: attributeList]
ifFalse: [XMLElement named: localName namespace: namespace uri: namespaceUri attributes: attributeList].
top
XMLDocument
A XMLDocument is xxxxxxxxx.
Instance Variables
dtd: <Object>
encoding: <Object>
requiredMarkup: <Object>
version: <Object>
dtd
- xxxxx
encoding
- xxxxx
requiredMarkup
- xxxxx
version
- xxxxx
dtd
dtd:
encoding
encoding:
printCanonicalOn:
printXMLOn:
requiredMarkup
requiredMarkup:
root
return my root element
version
version:
XMLElement
A XMLElement is xxxxxxxxx.
Instance Variables
attributes: <Object>
name: <Object>
attributes
- xxxxx
name
- xxxxx
@
shorthand form
addContent:
allAttributes
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
attributeAt:
attributeAt:ifAbsent:
attributeAt:put:
attributes
characterData
contentString
contentStringAt:
contents
contentsDo:
elements
elementsAndContentsDo:
elementsDo:
firstTagNamed:
Return the first encountered node with the specified tag.
If it is not the receiver, pass the message on
firstTagNamed:with:
Return the first encountered node with the specified tag that allows
the block to evaluate to true. Pass the message on
isEmpty
isTag
localName
name
Answer a name for the receiver. This is used generically in the title of certain inspectors, such as the referred-to inspector, and specificially by various subsystems. By default, we let the object just print itself out..
name:
named:
named:attributes:
named:namespace:uri:attributes:
parent
parent:
printXMLOn:
qualifiedName
setAttributes:
tag
tagsNamed:contentsDo:
Evaluate aBlock for all of the contents of the receiver
if the receiver tag equals aSymbol. Pass the message on
tagsNamed:do:
If the receiver tag equals aSymbol, evaluate aOneArgumentBlock
with the receiver. Continue the search
tagsNamed:ifReceiverDo:
If the receiver tag equals aSymbol, evaluate aOneArgumentBlock with the receiver
tagsNamed:ifReceiverDoAndRecurse:
If the receiver tag equals aSymbol, evaluate aOneArgumentBlock
with the receiver. Then recurse through all the children
tagsNamed:ifReceiverOrChildDo:
If the receiver tag equals aSymbol, evaluate aOneArgumentBlock with the receiver.
For each of the receivers children do the same. Do not go beyond direct children
valueFor:
valueFor:ifAbsent:
XMLException
A XMLException is xxxxxxxxx.
Instance Variables
XMLInvalidException
A XMLInvalidException is xxxxxxxxx.
Instance Variables
XMLMalformedException
A XMLMalformedException is xxxxxxxxx.
Instance Variables
XMLNamespaceScope
A XMLNamespaceScope is xxxxxxxxx.
Instance Variables
currentBindings: <Object>
scope: <Object>
useNamespaces: <Object>
validateAttributes: <Object>
currentBindings
- xxxxx
scope
- xxxxx
useNamespaces
- xxxxx
validateAttributes
- xxxxx
currentScope
declareNamespace:uri:
Declare the given name space prefix with the given URL
defaultNamespace
defaultNamespace:
Declare the default namespace.
enterScope
establishLocalBindings
initScope
leaveScope
namespaceAliases:
Locate all namespaces that are aliases of the given URI.
namespaceURIOf:
Retrieve the URI of the given namespace prefix, if it is defined. A nil namespace
returns the global namespace
namespaceURIOf:ifAbsent:
Retrieve the URI of the given namespace prefix, if it is defined.
A nil namespace returns the default namespace.
If no namespace can be found the value of the block is returned
namespaces
scope
validateAttributes:
check all attribute namespaces are defined and not duplicated by aliasing
XMLNode
A XMLNode is xxxxxxxxx.
Instance Variables
addContent:
contentsDo:
elementsAndContentsDo:
elementsDo:
firstTagNamed:
Return the first encountered node with the specified tag. Pass the message on
firstTagNamed:with:
Return the first encountered node with the specified tag that
allows the block to evaluate to true. Pass the message on
isProcessingInstruction
isTag
isText
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
printXMLOn:
tagsNamed:childrenDo:
Evaluate aOneArgumentBlock for all children who match
tagsNamed:childrenDoAndRecurse:
Evaluate aOneArgumentBlock for all children who match and recurse
tagsNamed:contentsDo:
Evaluate aBlock for all of the contents of the receiver.
The receiver has no tag, so pass the message on
tagsNamed:do:
Search for nodes with tag aSymbol. When encountered evaluate aOneArgumentBlock
tagsNamed:ifReceiverDo:
Handled only by XMLTagNode subclass
tagsNamed:ifReceiverDoAndRecurse:
Recurse all children
tagsNamed:ifReceiverOrChildDo:
Recurse all children
XMLNodeWithElements
A XMLNodeWithElements is xxxxxxxxx.
Instance Variables
elementsAndContents: <Object>
namespace: <Object>
parent: <Object>
uri: <Object>
elementsAndContents
- xxxxx
namespace
- xxxxx
parent
- xxxxx
uri
- xxxxx
addElement:
addEntity:value:
elementAt:
elementAt:ifAbsent:
elementUnqualifiedAt:
elementUnqualifiedAt:ifAbsent:
elements
elementsAndContents
elementsDo:
namespace
namespace:uri:
namespaceURI
printXMLOn:
topElement
XMLPI
A XMLPI is xxxxxxxxx.
Instance Variables
data: <Object>
target: <Object>
data
- xxxxx
target
- xxxxx
data
data:
isProcessingInstruction
printXMLOn:
target
target:
target:data:
XMLParser
This is a generic parser.
There is two ways to parse XML files, either using SAX, or using DOM. Both ways are supported in the XML-Parser package. SAX is event-based while DOM is tree-based. Ask google for more information
attribute:value:
This method is called for each attribute/value pair in a start tag
beginStartTag:asPI:
This method is called for at the beginning of a start tag.
The asPI parameter defines whether or not the tag is a 'processing
instruction' rather than a 'normal' tag.
endStartTag:
This method is called at the end of the start tag after all of the
attributes have been processed
endTag:
This method is called when the parser encounters either an
end tag or the end of a unary tag
handleCData:
handleEndTag:
handlePCData:
handleStartTag:attributes:
text:
This method is called for the blocks of text between tags.
It preserves whitespace, but has all of the enclosed entities expanded
XMLParserTest
A XMLParserTest is xxxxxxxxx.
Instance Variables
addressBookXML
addressBookXMLWithDTD
testExampleAddressBook
self debug: #testExampleAddressBook
testExampleAddressBookWithDTD
XMLTokenizer exampleAddressBookWithDTD
testParsing
self debug: #testParsing
testParsingCharacters
This test is actually not that useful. This is not the proper way of using the parser. This test is here just for specification purpose
XMLStringNode
A XMLStringNode is xxxxxxxxx.
Instance Variables
string: <Object>
string
- xxxxx
characterData
isText
printXMLOn:
string
string:
XMLTokenizer
XMLTokenizer
bolot@cc.gatech.edu
breaks the stream of characters into a stream of XMLnodes (aka token stream)
token stream is used by XMLparser to generate XMLdocument tree
addressBookXML
addressBookXMLWithDTD
atEnd
checkAndExpandReference:
checkNestedStream
conditionalInclude:
endDocTypeDecl
Skip ]>
endParsingMarkup
entities
entity:
entity:put:
Only the first declaration of an entity is valid so if there is already one don't register the new value.
errorExpected:
exampleAddressBook
exampleAddressBookWithDTD
externalEntities
externalEntity:
fastStreamStringContents:
handleCData:
handleComment:
handleEndDocument
handleEndTag:
handleEntity:in:
handlePCData:
handlePI:data:
handleStartDocument
handleStartTag:attributes:
handleWhitespace:
handleXMLDecl:namespaces:
hasNestedStreams
initEntities
initialize
Subclasses should redefine this method to perform initializations on instance creation
isCharEscape:
log:
Transcript show: aString; cr
malformedError:
match:into:
Set the access position of the receiver to be past the next occurrence of the subCollection. Answer whether subCollection is found. No wildcards, and case does matter.
nestedStreams
next
Return the next character from the current input stream. If the current stream is at end pop to next nesting level if there is one.
Due to the potential nesting of original document, included documents and replacment texts the streams are held in a stack representing the nested streams. The current stream is the top one.
nextAttributeInto:namespaces:
nextAttributeValue
nextCDataContent
Skip $[
nextCDataOrConditional
Skip [
nextCharReference
nextComment
Skip first -
nextDocType
nextDocTypeDecl
nextEndTag
Skip /
nextEntity
return the next XMLnode, or nil if there are no more.
Fixed to retain leading whitespace when PCDATA is detected.
nextEntityDeclaration
nextEntityValue
nextExternalId
nextIncludeSection:
Read the file up to the next include section delimiter and parse it if parseSection is true
nextLiteral
nextMarkupDeclaration
nextName
nextNode
Skip <
nextPCData
nextPI
Skip ?
nextPubidLiteral
nextSystemLiteral
nextTag
nextTrimmedBlanksUpTo:
nextUpTo:
nextUpToAll:
nextWhitespace
nextXMLDecl
on:
parameterEntities
parameterEntity:
parameterEntity:put:
Only the first declaration of an entity is valid so if there is already one don't register the new value.
parseError:
parseStream:
parsingMarkup
peek
Return the next character from the current input stream. If the current stream poop to next nesting level if there is one.
Due to the potential nesting of original document, included documents and replacment texts the streams are held in a stack representing the nested streams. The current stream is the top one.
popNestingLevel
pushBack:
Fixed to push the string before the peek char (if any).
pushStream:
Continue parsing from the new nested stream.
readNumberBase:
Read a hex number from stream until encountering $;
skipMarkupDeclaration
skipSeparators
skipUpTo:
startParsingMarkup
stream
stream:
Continue parsing from the new nested stream.
stream:upToAll:
Answer a subcollection from the current access position to the occurrence (not inclusive) of aCollection. If aCollection is not in the stream, answer nil.
streamEncoding:
topStream
unpeek
Fixed to use nested stream since multi-byte streams
do not properly override pushBack: to deal with multi-byte
characters.
upToAll:
Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of delimitingString. If delimitingString is not in the stream, answer the entire rest of the stream.
usesNamespaces
validating
validating:
XMLWarningException
A XMLWarningException is xxxxxxxxx.
Instance Variables
XMLWriter
A XMLWriter is xxxxxxxxx.
Instance Variables
canonical: <Object>
currentIndent: <Object>
indentString: <Object>
scanner: <Object>
scope: <Object>
stack: <Object>
stream: <Object>
canonical
- xxxxx
currentIndent
- xxxxx
indentString
- xxxxx
scanner
- xxxxx
scope
- xxxxx
stack
- xxxxx
stream
- xxxxx
attribute:value:
canonical
canonical:
cdata:
comment:
declareNamespace:uri:
defaultNamespace
defaultNamespace:
Declare the default namespace.
endCData
endComment
endDecl:
endDeclaration
endEmptyTag:
endPI
endTag
endTag:
endTag:xmlns:
enterScope
eq
flush
indent
indentString:
indentTab
initialize
Subclasses should redefine this method to perform initializations on instance creation
leaveScope
on:
outdent
pcData:
pi:data:
popTag:
pushTag:
putAsXMLString:
scope
stack
startCData
startComment
startDecl:
startDecl:named:
startDeclaration:
startElement:attributeList:
startPI:
startTag:
startTag:xmlns:
stream
stream:
writeIndent
xmlDeclaration:encoding: