[squeak-dev] The Trunk: XML-Parser-topa.38.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Jun 9 12:18:56 UTC 2016
Tobias Pape uploaded a new version of XML-Parser to project The Trunk:
http://source.squeak.org/trunk/XML-Parser-topa.38.mcz
==================== Summary ====================
Name: XML-Parser-topa.38
Author: topa
Time: 9 June 2016, 2:18:47.587644 pm
UUID: 04dceb47-db2b-4617-86ac-737264db4bbd
Ancestors: XML-Parser-bf.37
Fix SAX namespace handling
Add FileService to Explore XML files (includes external Drag'n'Drop)
=============== Diff against XML-Parser-bf.37 ===============
Item was changed:
----- Method: SAXDriver>>handleStartTag:attributes:namespaces: (in category 'handling tokens') -----
handleStartTag: elementName attributes: attributeList namespaces: namespaces
| localName namespace namespaceURI |
(attributeList includesKey: 'xml:lang')
ifTrue: [languageEnvironment := LanguageEnvironment localeID: (LocaleID isoString: (attributeList at: 'xml:lang'))].
self usesNamespaces
ifTrue: [
self scope enterScope.
"declare any namespaces"
namespaces keysAndValuesDo: [:ns :uri |
self scope declareNamespace: ns uri: uri].
self splitName: elementName into: [:ns :ln |
namespace := ns.
localName := ln].
+ namespaceURI := self scope
+ namespaceURIOf: namespace
+ ifAbsent: [self parseError: 'Start tag ' , elementName , ' refers to undefined namespace ' , namespace asString].
- "ensure our namespace is defined"
- namespace
- ifNil: [namespace := self scope defaultNamespace]
- ifNotNil: [
- namespaceURI := self scope namespaceURIOf: namespace.
- namespaceURI
- ifNil: [self parseError: 'Start tag ' , elementName , ' refers to undefined namespace ' , namespace asString]].
self validatesAttributes
ifTrue: [self scope validateAttributes: attributeList].
"call the handler"
self saxHandler
checkEOD;
startElement: localName namespaceURI: namespaceURI namespace: namespace attributeList: attributeList]
ifFalse: [
"call the handler"
self saxHandler
checkEOD;
startElement: elementName namespaceURI: nil namespace: nil attributeList: attributeList]!
Item was added:
+ ----- Method: XMLDOMParser class>>fileReaderServicesForFile:suffix: (in category 'file reader services') -----
+ fileReaderServicesForFile: fullName suffix: suffix
+
+ " some known suffixes "
+ ^ ((#('xml' 'xsl' 'xhtml' 'sif' 'rss' 'atom' '*') includes: suffix)
+ or: [self looksLikeXML: fullName])
+ ifFalse: [#()]
+ ifTrue: [{self serviceExplore}]!
Item was added:
+ ----- Method: XMLDOMParser class>>initialize (in category 'initialize-release') -----
+ initialize
+ "register the receiver in the global registries"
+ self environment
+ at: #FileList
+ ifPresent: [:cl | cl registerFileReader: self]!
Item was added:
+ ----- Method: XMLDOMParser class>>looksLikeXML: (in category 'file reader services') -----
+ looksLikeXML: fullName
+
+ [ | sample |
+ FileStream readOnlyFileNamed: fullName do:
+ [:stream |
+ stream isBinary ifTrue: [^ false].
+ sample := (stream next: 20) withBlanksTrimmed].
+ ^ sample first = $<
+ and: [ (#( $!! $? $: $_ ) includes: sample second)
+ or: [sample second isLetter]]
+ ] on: Error do: [^ false "backstop"]!
Item was added:
+ ----- Method: XMLDOMParser class>>serviceExplore (in category 'file reader services') -----
+ serviceExplore
+
+ ^ SimpleServiceEntry
+ provider: [:fullName |
+ (FileStream readOnlyFileNamed: fullName do:
+ [:file | self parseDocumentFrom: file useNamespaces: true]) explore]
+ label: 'explore XML'
+ selector: #value:
+ description: 'read and partse the file and explore its XML structure'
+ buttonLabel: 'explore'!
Item was added:
+ ----- Method: XMLDOMParser class>>unload (in category 'initialize-release') -----
+ unload
+ "Unload the receiver from global registries"
+ self environment
+ at: #FileList
+ ifPresent: [:cl | cl unregisterFileReader: self]!
More information about the Squeak-dev
mailing list
|