'From Squeak3.1alpha of 6 February 2001 [latest update: #3527] on 12 February 2001 at 5:34:58 pm'!
"Change Set: XML-browseInScamper
Date: 7 February 2001
Author: Bolot Kerimbaev
Enhance Squeak Jabber with debugging support:
- print XMLElements as HTML in Scamper"!
!Scamper methodsFor: 'changing page' stamp: 'bolot 2/7/2001 18:26'!
jumpToDocument: mimeDocument
"display a new page"
self stopEverything.
[recentDocuments size > currentUrlIndex] whileTrue: [
"delete all elements in recentDocuments after currentUrlIndex"
recentDocuments removeLast.
].
documentQueue nextPut: mimeDocument.
currentUrlIndex _ currentUrlIndex + 1.
^true! !
!XMLElement methodsFor: 'printing' stamp: 'bolot 2/7/2001 17:36'!
browseInScamper
self browseInScamper: Scamper new! !
!XMLElement methodsFor: 'printing' stamp: 'bolot 2/7/2001 18:26'!
browseInScamper: aScamper
| htmlDoc htmlStream |
htmlStream _ WriteStream on: String new.
htmlStream nextPutAll:
'
', self name, '
Document: ', self name, '
'.
self printHtmlOn: htmlStream.
htmlStream nextPutAll:
'
'.
htmlDoc _ MIMEDocument
contentType: 'text/html'
content: htmlStream contents
url: 'xml-', self name, '-', Time totalSeconds printString.
aScamper jumpToDocument: htmlDoc! !
!XMLElement methodsFor: 'printing' stamp: 'bolot 2/12/2001 17:32'!
printHtmlOn: stream
| contentsAtNewLines |
contentsAtNewLines _ false.
stream nextPutAll: '- <', self name, ''; cr.
attributes isEmptyOrNil not
ifTrue: ["stream nextPutAll: '
Attributes: '; cr."
attributes associationsDo: [:a |
stream nextPutAll: ' ', a key, '
="', a value,
'"']].
stream nextPutAll: '>'; cr.
self contents isEmptyOrNil ifFalse:
[self contents size > 1 ifTrue: [contentsAtNewLines _ true].
self contents do: [:c |
contentsAtNewLines ifTrue: [stream nextPutAll: '
'].
stream nextPutAll: '', c string, ''; cr]].
(entities isEmptyOrNil not)
ifTrue: [entities do: [:c | c value printHtmlOn: stream]].
contentsAtNewLines | entities isEmptyOrNil not
ifTrue: [stream nextPutAll: '
- '].
stream nextPutAll: '</', self name,
'>
'; cr.
! !