I just parsed the DAML sentence using XMLParser. Next step i have to do is that i have to collect all the parsed elements and store it in a temporary variable. So please anyone tell me the syntax for this one.
|
>
> I just parsed the DAML sentence using XMLParser. Next step i have to do is > that i have to collect all the parsed elements and store it in a temporary > variable. So please anyone tell me the syntax for this one. > -- What the DAML sentence ? a DAML sentence ?... I think you just have to select elements of interest that are "returned" by the XMLParser. Inspect (cmd+i) or explore (cmd+shift+i) it to see where are the elements you want... something like: XMLParser parseDocument: 'yourDAMLSentence' ... <- cmd+shift+i when selected after you can store the result in a var, navigate in the tree structure while collecting in a collection the elements you're interested in... hth Cédrick _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by rameshvidya
(copy of a mail I sent to the wrong post)
[hidden email] 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. > 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. 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 :'( Cédrick 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 _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners SUP-Model-Meteo.st (24K) Download Attachment |
Free forum by Nabble | Edit this page |