Preliminary new Yaxo version (was: Re: Question about YAXO-XML and possible bug)

Boris.Gaertner Boris.Gaertner at gmx.net
Thu Nov 1 11:11:46 UTC 2007


"Michael Rueger" <michael at impara.de> wrote:

> there is a new version of Yaxo up at
> http://source.impara.de/infrastructure/XML-Parser-mir.10.mcz

Thank you very much for your prompt fix!
 
> You need the two attached 3.8.2/3.10 fixes for the new package to work.

> Please test the new version. For now I only tried to verify against some 
> examples I had readily available.
> 
Here are my first test results:
1. Squeak 3.9 #7067 does not contain the classes
    CharacterSetComplement  and WideCharacterSet,
    therefore I could not immediately use your code with that
    version. To proceed, I dropped works with 3.9 for now
    and moved to 3.10beta #7158. 

2. In Squeak 3.10beta #7158 I could try your code. The
    surprising result is, that a structured xml element with
    subelements can be parsed, but in the parse tree, all
    subelements are missing.  

Problem analysis:
1. During parsing, a new element is inserted into its parent
in one of the methods
XMLDOMParser>>startElement:attributeList:
XMLDOMParser>>startElement:namespaceURI:namespace:attributeList:

The relevant statement is.
   self top addElement: newElement

addElement:  is defined in XMLNodeWithElements
where we find:

addElement: element
   self elements add: element

Method #elements  is an accessor with lazy initialization
in XMLNodeWithElements, but in the subclass XMLElement
it is now a method that uses a #select: to construct a new
collection.

Conclusion:  We do not add into the instance variable
element, but in a collection that was constructed on the fly
and that is subsequently dropped.

Proposal of a work around.
As  #elements does not answer an lazily initialized
instance variable, we cannot use in XMLElement
the #addElements: method that we inherit from
XMLNodeWithElements.  

Rather, I use these instance methods in XMLElement:

addContent: contentString
 super elements add: contentString


addElement: element
 super elements add: element

The first method is a modification of your method,
the second one is added.


With this change, I can correctly build the parse
tree for xml elements with subelements - also for
xml elements that mix #PCDATA (that is, strings)
with structured elements.

Comments to these proposals are of cource
welcome. Perhaps you can find a better solution.

By the way: Do we have any tests for the XML parser?
At this moment I am deeply involved in xml, that would
be a good moment to write some tests. Any interest?

Greetings
Boris





More information about the Squeak-dev mailing list