Skip to content

Instantly share code, notes, and snippets.

@SeanTAllen
Created December 24, 2011 03:44
Show Gist options
  • Save SeanTAllen/1516187 to your computer and use it in GitHub Desktop.
Save SeanTAllen/1516187 to your computer and use it in GitHub Desktop.
Exported class
Object subclass: #SAXHandler
instanceVariableNames: 'input configuration elementNester scopeAllocator'
classVariableNames: ''
classInstanceVariableNames: ''
poolDictionaries: ''.
+ on: aStringOrStream
^ self new input: aStringOrStream
+ onFileNamed: aFileName
^ self on: (FileStream readOnlyFileNamed: aFileName)
+ parse: aStringOrStream
^ (self on: aStringOrStream) parseDocument
+ parse: aStringOrStream usingNamespaces: aBoolean
^ (self on: aStringOrStream)
usesNamespaces: aBoolean;
parseDocument
+ parseDocumentFrom: aStringOrStream
^ self parse: aStringOrStream.
+ parseDocumentFrom: aStringOrStream useNamespaces: aBoolean
^ self parse: aStringOrStream usingNamespaces: aBoolean.
+ parseDocumentFromFileNamed: aFileName
self deprecated: 'use #parseFileNamed: instead'.
^ self parseFileNamed: aFileName.
+ parseFileNamed: aFileName
^ (self onFileNamed: aFileName) parseDocument
+ parserOnFileNamed: aFileName
self deprecated: 'use #onFileNamed: instead'.
^ self onFileNamed: aFileName.
- characters: aString
"This call corresponds to the Java SAX call
characters(char[] ch, int start, int length)."
- comment: aCommentString
"This call corresponds to the Java SAX ext call
comment(char[] ch, int start, int length)."
- configuration
^ configuration ifNil: [configuration := self configurationClass new]
- configuration: aConfiguration
configuration := aConfiguration
- configurationClass
^ XMLConfiguration
- currentElement
^ self elementNester currentElement
- currentScope
^ self scopeAllocator currentScope
- currentScope: aScope
self scopeAllocator currentScope: aScope
- elementNester
^ elementNester ifNil: [elementNester := XMLElementNester new]
- endCData
"This call corresponds to the Java SAX ext call
endCData()."
- endDocument
"This call corresponds to the Java SAX call
endDocument()."
- endElement: aQualifiedName
"intentionally empty method"
- endElement: aQualifiedName prefix: aPrefix uri: aUri
"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:"
self endElement: aQualifiedName
- endElement: aQualifiedName prefix: aPrefix uri: aUri localName: aLocalName
"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:"
self
invokeDeprecated: #endElement:namespace:namespaceURI:qualifiedName:
withArguments: (Array with: aLocalName with: aPrefix with: aUri with: aQualifiedName)
orForwardTo: #endElement:prefix:uri:
withArguments: (Array with: aQualifiedName with: aPrefix with: aUri)
- endEntity: anEntityName
"This call corresponds to the Java SAX ext call
endEntity(java.lang.String name)."
- endPrefixMapping: prefix
"This call corresonds to the Java SAX call
endPrefixMapping(java.lang.String prefix)."
- ignorableWhitespace: aString
"This call corresonds to the Java SAX call
ignorableWhitespace(char[] ch, int start, int length)."
- input
^ input
- input: aStringOrStream
input := aStringOrStream.
- invokeDeprecated: aDeprecatedSelector withArguments: anOldArgumentArray orForwardTo: aNewSelector withArguments: aNewArgumentArray
| parentContext |
parentContext := thisContext sender.
(self class includesSelector: aDeprecatedSelector)
ifFalse: [
aNewSelector ifNil: [^ self].
^ self
perform: aNewSelector
withArguments: aNewArgumentArray].
(Deprecation
method: (self class lookupSelector: aDeprecatedSelector)
explanation: 'use ', parentContext selector, ' instead'
on: nil
in: nil) signal.
self
perform: aDeprecatedSelector
withArguments: anOldArgumentArray.
- isValidating
^ self configuration isValidating
- isValidating: aBoolean
self configuration isValidating: aBoolean
- parseDocument
self parser parseDocument.
"Result of parsing"
^ self.
- parser
self configuration parserClass: self class.
^ XMLParser
driver: (SAXDriver saxHandler: self)
on: input.
- processingInstruction: piName data: dataString
"This call corresonds to the Java SAX call
processingInstruction(java.lang.String target, java.lang.String data)."
- scopeAllocator
^ scopeAllocator ifNil: [scopeAllocator := XMLNamespaceScopeAllocator new]
- skippedEntity: anEntityName
"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: aRootElementName publicID: aPublicId systemID: aSystemId
"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: aQualifiedName attributes: aDictionary
self
invokeDeprecated: #startElement:attributeList:
withArguments: (Array with: aQualifiedName with: aDictionary)
orForwardTo: nil
withArguments: nil.
- startElement: aQualifiedName prefix: aPrefix uri: aUri attributes: aDictionary
self startElement: aQualifiedName attributes: aDictionary
- startElement: aQualifiedName prefix: aPrefix uri: aUri localName: aLocalName attributes: aDictionary
"This call corresonds to the Java SAX call
startElement(java.lang.String namespaceURI, java.lang.String localName,
java.lang.String qName, Attributes atts)."
self
invokeDeprecated: #startElement:namespaceURI:namespace:attributeList:
withArguments: (Array with: aLocalName with: aUri with: aPrefix with: aDictionary)
orForwardTo: #startElement:prefix:uri:attributes:
withArguments: (Array with: aQualifiedName with: aPrefix with: aUri with: aDictionary).
- startEntity: anEntityName
"This call corresponds to the Java SAX ext call
startEntity(java.lang.String name)."
- startPrefixMapping: aPrefix uri: aUri
"This call corresonds to the Java SAX call
startPrefixMapping(java.lang.String prefix, java.lang.String uri)."
- useNamespaces: aBoolean
self deprecated: 'use #usesNamespaces: instead'.
self usesNamespaces: aBoolean.
- usesNamespaces
^ self configuration usesNamespaces
- usesNamespaces: aBoolean
self configuration usesNamespaces: aBoolean
- xmlVersion: aVersionFloat encoding: anEncoding standalone: aBoolean
self
invokeDeprecated: #documentAttributes:
withArguments:
(Array with: (Dictionary
with: 'version' -> aVersionFloat asString
with: 'encoding' -> anEncoding))
orForwardTo: nil
withArguments: nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment