The Trunk: XML-Parser-ar.32.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: XML-Parser-ar.32.mcz

commits-2
Andreas Raab uploaded a new version of XML-Parser to project The Trunk:
http://source.squeak.org/trunk/XML-Parser-ar.32.mcz

==================== Summary ====================

Name: XML-Parser-ar.32
Author: ar
Time: 10 August 2010, 1:25:41.615 pm
UUID: 00d928a6-ebba-104d-a598-b96b4445f2e7
Ancestors: XML-Parser-mtf.30

Fix printing of XMLElements; add tests for behavior.

=============== Diff against XML-Parser-mtf.30 ===============

Item was added:
+ ----- Method: XMLParserTest>>testPrintElements (in category 'tests') -----
+ testPrintElements
+ | node |
+ node:= (XMLElement new) name: 'foo';
+ setAttributes: (Dictionary new);
+ yourself.
+ self assert: node asString withBlanksTrimmed = '<foo/>'.
+
+ node:= (XMLElement new) name: 'foo';
+ setAttributes: (Dictionary newFromPairs: {'id'. '123'});
+ yourself.
+ self assert: node asString withBlanksTrimmed = '<foo id="123"/>'.
+
+ node:= (XMLElement new) name: 'foo';
+ addContent: (XMLStringNode string: 'Hello World');
+ setAttributes: (Dictionary new);
+ yourself.
+ self assert: node asString withBlanksTrimmed = '<foo>Hello World</foo>'.
+
+ node:= (XMLElement new) name: 'foo';
+ addContent: (XMLStringNode string: 'Hello World');
+ setAttributes: (Dictionary newFromPairs: {'id'. '123'});
+ yourself.
+ self assert: node asString withBlanksTrimmed = '<foo id="123">Hello World</foo>'.
+
+ !

Item was changed:
  ----- Method: XMLElement>>isEmpty (in category 'testing') -----
  isEmpty
+ "Answer true if the receiver is empty"
+
+ ^self elementsAndContents isEmpty!
- ^self elements isEmpty!

Item was changed:
  ----- Method: XMLElement>>printXMLOn: (in category 'printing') -----
  printXMLOn: writer
+ "Print the receiver in XML form"
+
  writer startElement: self name attributeList: self attributes.
  (writer canonical not
+ and: [self isEmpty])
- and: [self isEmpty and: [self attributes isEmpty not]])
  ifTrue: [writer endEmptyTag: self name]
  ifFalse: [
  writer endTag.
  self elementsAndContentsDo: [:content | content printXMLOn: writer].
  writer endTag: self name]!