[Newbies] xml file query and object mapping

cdrick cdrick65 at gmail.com
Thu Jun 29 20:49:29 UTC 2006


Hi all

I've got xml files that I receive from Meteo France (weather forecast) that
I have to query and map to some objects
I've tried several stuff like parsing the file, selecting only some
elements,  displaying it with a WATree but I'm a bit stuck as none results I
got are good enough.

The structure is like behind:

<?xml version="1.0" encoding="UTF-8" ?>...
<donnees>
<dates>...</dates>
<prevision>
 <prev num="1">    // a prev concern a zone for 3 hours - there are 18 prev
for a given zone
  <ZONE>6403</ZONE>
  <VALIDITE>200606292000</VALIDITE>
  <JJ>20060629</JJ>
  <HH>2000</HH>
  <T>24</T>
  <PICTO>P6</PICTO>
  <DD>315</DD>
  <FF>10</FF>
  <RAF></RAF>
  <ISO_ZERO>4100</ISO_ZERO>
  <LIMIT_PLUIE_NEIGE></LIMIT_PLUIE_NEIGE>
  <W1>0</W1>
  <W2></W2>
  <NEBUL_TOT>3</NEBUL_TOT>
  <BASE_NUAGE></BASE_NUAGE>
  <SOMMET_NUAGE></SOMMET_NUAGE>
  <FF1500M>5</FF1500M>
  <FF3000M>25</FF3000M>
  <RR6>0.4</RR6>
  <W3></W3>
  <EPAIS_NEIGE></EPAIS_NEIGE>
  <VIGILANCE></VIGILANCE></prev>

 ....   around 450 prev (18 for each ZONE)

  <prevQ num="1">   // this are prevision for the whole day - 4 prevQ in
each file for a given zone
  <ZONE>3107</ZONE>
  <VALIDITE>200606290000</VALIDITE>
  <JJ>20060629</JJ>
  <TN>15</TN>
  <TX>26</TX>
  <RR24>1.0</RR24>
  <UN>60</UN>
  <UX>100</UX></prevQ>
...
</prevision>
</donnees>


What I need to do is quering the file according to the some attribute (ZONE,
VALIDITE, JJ and HH) so as to get the different value that characterize the
weather forecast. The only thing I can do is selecting nodes accoring to one
parameter, for instance all prevQ element of zone 6504 (using Xpath).

| xml document path results |
   xml := (StandardFileStream readOnlyFileNamed:
'ressources/MF/backup/sympo0805200617h00.xml') contents.
   document := XMLDOMParser parseDocumentFrom: xml readStream.
   path := XPath for: 'prevision/prev'.
   results := path in: document.
   ^ results
       select: [:xmlElem | (xmlElem elementAt: #ZONE) contents first
string = '6504']



I'm a bit lost now. Is it possible to map to objects ?  do I need to work
directly on xml file by xsl transformation ? I don't really understand how
to use a sax parser (I always do a full dom parse that I store in an inst
var).

Do you have advices, pointers or other good practises that can help me ?

Thanks

Cédrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20060629/0b095324/attachment.htm


More information about the Beginners mailing list