Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions src/XML-Parser-Tools/XMLNode.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@ XMLNode >> inspectSourceIn: specBuilder [

{ #category : '*XML-Parser-Tools' }
XMLNode >> inspectTreeIn: specBuilder [

<inspectorPresentationOrder: 28 title: 'Tree'>

| roots |

roots := self inspectorRoots.
^ specBuilder newTree
roots: roots;
display: [ :aNode |
self inspectorTreeStringFor: aNode
];
" displayIcon: [ :aNode | aNode iconName ifNotNil: [ :aName | self iconNamed: aName ] ];"
children: [ :aNode |

aNode hasChildren ifTrue: [ aNode descendantElements ] ifFalse: [ #() ]]


roots: roots;
display: [ :aNode | self inspectorTreeStringFor: aNode ];
" displayIcon: [ :aNode | aNode iconName ifNotNil: [ :aName | self iconNamed: aName ] ];"
children: [ :aNode | aNode elements ];
expandRoots
]

{ #category : '*XML-Parser-Tools' }
Expand All @@ -37,21 +31,19 @@ XMLNode >> inspectorRoots [

{ #category : '*XML-Parser-Tools' }
XMLNode >> inspectorTreeStringFor: anXMLElement [
| display |
anXMLElement isStringNode ifTrue: [ ^ anXMLElement string ].
display := String streamContents: [:s|
s nextPutAll: anXMLElement name.
anXMLElement hasAttributes ifTrue: [
s space.
anXMLElement attributes associations do: [:association |
s
nextPutAll: association key;
nextPutAll: '="';
nextPutAll: association value;
nextPutAll: '"'.
] separatedBy: [ s space ]
]
].
anXMLElement descendantElements isEmpty ifFalse: [ ^ '<',display, '>' ].
^ anXMLElement asString

anXMLElement hasElements ifFalse: [ ^ anXMLElement asString ].
^ String streamContents: [ :s |
s
nextPut: $<;
nextPutAll: anXMLElement name.
anXMLElement hasAttributes ifTrue: [
anXMLElement attributes associations do: [ :association |
s
space;
nextPutAll: association key;
nextPutAll: '="';
nextPutAll: association value;
nextPutAll: '"' ] ].
s nextPut: $> ]
]
2 changes: 1 addition & 1 deletion src/XML-Parser/XMLDecodingReadStreamAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ XMLDecodingReadStreamAdapter >> atEnd [
XMLDecodingReadStreamAdapter >> detectEncoding [
prePeekStreamPosition := nil.
peekChar := nil.
stream reset.
stream position: 0.

(((self hasNullStreamConverter
or: [self hasImplicitStreamConverter])
Expand Down
14 changes: 14 additions & 0 deletions src/XML-Parser/XMLNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ XMLNode >> documentRoot [
^ documentRoot.
]

{ #category : 'accessing' }
XMLNode >> elements [
"returns a new node list of all of the receiver's elements"

^ XMLNodeList empty
]

{ #category : 'private' }
XMLNode >> errorXMLWritingUnsupported [
XMLDOMException signal: 'The XMLWriter package is required for writng DOM objects'
Expand All @@ -202,6 +209,13 @@ XMLNode >> hasChildren [
^ false
]

{ #category : 'testing' }
XMLNode >> hasElements [
"returns true if the receiver has element children"

^ false
]

{ #category : 'private' }
XMLNode >> hasNodeList: aNodeList [
^ false
Expand Down
Loading