[Newbies] Re: Regarding smalltalk

cdrick cdrick65 at gmail.com
Mon May 21 16:50:46 UTC 2007

(copy of a mail I sent to the wrong post)
ramramesh_26 at yahoo.co.in a écrit :
> HI cdrick thanks for your reply
> i will tell you in detail.
> This is the actual DAML sentence (input) given to the XMLParser
>  <daml:Class rdf:ID = "Person">
> <rdfs:subClassOf rdf:resource = "#Animal" />
> <rdfs:subClassOf>
> <daml:Restriction>
> <daml:onProperty rdf:resource = "#hasParent" />
> <daml:toClass rdf:resource = "#Person" />
> </daml:Restriction>
> </rdfs:subClassOf>
> </daml:Class>
> <person rdf:ID = "Joe">
> <hasParent rdf:resource = "#John"/>
> </person>
> Iam parsing this using the code | stream |
> [
> | tree |
> stream := FileStream fileNamed: 'test.daml'.
> tree := XMLDOMParser parseDocumentFrom: stream.
> tree elements collect: [:each| each name].
> ] ensure: [stream close].
> >From the above code, "tree elements collect: [:each | each name]." actually collects the root elements. for example from the above example it collects <daml:class> and <person>. My aim is to collect all the elements including attributes and attribute values from that parsed tree in a sequeanceable order.
show us the result you'd like for the example sentence...
> After collecting it in a sequence i have to store it in a variable, so that i can check with that elements with other conditions.
Not sure (and not expert), but I think you should use the SAXParser so
that you navigate the xml tree and do whatever you want with
elements/attributes... The DOMParser is actually building a full tree
for further exploration... can be long and you have to process it
again to get more information... I dit that once to collect wheteher
data for a large xml file... The process is maybe not obvious, you
need to subclass SAXHandler with say DAMLHandler, where you'll
redefine messages likes characters: startDocument: endElement:
startElement:attribute:list:...  but the better is probably to
subclass,   then  you put a    self halt   in the method
startDocument:   and little by little you see how it works... Also,
you'll probably have to create a class where you'll store the
information you want (Meteo class in my case...)...
Sorry, but I cannot help you more on this... really busy for some monthes :'(


ps: I joined my meteo handlers, of course it won't work but it will
give you another example of SAXHandler (that the XMLDOMParser which is
a particular case of SAXHandler)... soory for the bad code :p
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SUP-Model-Meteo.st
Type: application/octet-stream
Size: 18700 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070521/a28e8c46/SUP-Model-Meteo-0001.obj

More information about the Beginners mailing list