diff --git a/src/XML-Parser-Tools/XMLNode.extension.st b/src/XML-Parser-Tools/XMLNode.extension.st index 19f5a65d..197ea91e 100644 --- a/src/XML-Parser-Tools/XMLNode.extension.st +++ b/src/XML-Parser-Tools/XMLNode.extension.st @@ -11,22 +11,16 @@ XMLNode >> inspectSourceIn: specBuilder [ { #category : '*XML-Parser-Tools' } XMLNode >> inspectTreeIn: specBuilder [ + - | 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' } @@ -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: $> ] ] diff --git a/src/XML-Parser/XMLDecodingReadStreamAdapter.class.st b/src/XML-Parser/XMLDecodingReadStreamAdapter.class.st index aa209feb..5d9bb2da 100644 --- a/src/XML-Parser/XMLDecodingReadStreamAdapter.class.st +++ b/src/XML-Parser/XMLDecodingReadStreamAdapter.class.st @@ -56,7 +56,7 @@ XMLDecodingReadStreamAdapter >> atEnd [ XMLDecodingReadStreamAdapter >> detectEncoding [ prePeekStreamPosition := nil. peekChar := nil. - stream reset. + stream position: 0. (((self hasNullStreamConverter or: [self hasImplicitStreamConverter]) diff --git a/src/XML-Parser/XMLNode.class.st b/src/XML-Parser/XMLNode.class.st index ac22d42c..b5d3ae47 100644 --- a/src/XML-Parser/XMLNode.class.st +++ b/src/XML-Parser/XMLNode.class.st @@ -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' @@ -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