Best method to write an xml document

maretix

Member
Hi to all.
I need to create an XML document , reading data from a DB Progress 10.2.b version.

I read tutorial and i learn there are 3 ways to create an XML file inside 4Gl or WebSpeed Program.
(I need to create an XML via WEBSTREAM with a series of WEBSPEED programs.)

1) SAX PARSER (I have to study)
2) X-DOM (i have old programs written in this way ..that i find a lot complicate)
3) Using Write-XML method with TEMP-TABLES and DATASET

I ask what is the best way to do that i want ???

For example i attach an example of what a thirdy companu ask to me.

Regards.

PS. I was able to do something with Write-XML Method and i found it easier than others way.


Code:
<?xml version="1.0"?>
-<Tabella><P1 label="Prezzo unitario riservato al cliente (ECO-FEE compreso)">5,70394</P1>
<D1 label="Mag.%20Verona%20Vendita%20Std." a_value="120001">656</D1>
<D2 label="Mag.Legnago%20S.Pietro%20Vend.Std" a_value="120003">25</D2>
<D3 label="Mag.%20Saonara%20Vendita%20Std." a_value="120006">713</D3>
<D4 label="Mag.%20S.Daniele%20Vendita" a_value="120061">1522</D4>
<Lotto label="Lotti">S</Lotto>
<Lotto120001>58;28;20;</Lotto120001>
<Lotto120003>25;</Lotto120003>
<Lotto120006>64;13;12;12;12;5;</Lotto120006>
<Lotto120061>46;15;</Lotto120061>
<CodiceAssociato label="Codice Interno">CCC0811L</CodiceAssociato>
<CodiceFornitore label="Codice Fornitore">FG7OR%2019G1,5%20(B)</CodiceFornitore>
<Sigla label="Sigla">CCC</Sigla>
<Fornitore label="Fornitore">CAVO-FORN.%20VARI</Fornitore>
<Descrizione label="Descrizione">CAVO%20BUT.FLESS.FG7OR%2019G1,5%20Bobina</Descrizione>
<LisFor label="Lis. Fornitore"> 5,70394</LisFor>
<AlberoLevel label="AlberoLevel">7</AlberoLevel>
<AlberoCod label="AlberoCod">LACFHWH</AlberoCod>
<AlberoDes label="AlberoDes">1,5mmq</AlberoDes>
<ImpFee label="Importo ECO-FEE"> 0,00000</ImpFee>
<Unmiven label="Un. misura di Vendita">MT</Unmiven>
<Prezzo label="Prezzo">5,70394</Prezzo>
<Sconto label="Sconto"> 0,00</Sconto>
<Scontoapp label="Sconto Applicato">0,00</Scontoapp>
<Formsco label="Formula Sconto"/>
<Listino label="Listino">RRM</Listino>
<Flag-net label="Flag Netto">N</Flag-net>
<Proven label="Codice Promozione"/>
<Codger label="Codice Gerarchia"/>
<Whatpre label="Tipo Prezzo">0</Whatpre>
<Prelis label="Prezzo Listino">5,70394</Prelis>
<Gesres label="Default Residuo">N</Gesres>
</Tabella>
 

Cringer

ProgressTalk.com Moderator
Staff member
Best/Worst depends on all sorts of things, like what you want to create, but also what you find works best for you. If write XML works for you then why use something else?
 

GregTomkins

Active Member
For me/us, WRITE-XML is what we'd almost always use. We'd only look to SAX (or in some cases we just output XML directly using PUT, but that's a bad idea) if the # of records involved was big enough. I might start worrying about that in the 1,000+ records range, if it were something that lots of people were doing all the time.
 

Cringer

ProgressTalk.com Moderator
Staff member
And DOM is almost always a bad idea unless you know for sure there isn't going to be much in the file, ever, as it has to parse the lot into memory first.
 

RealHeavyDude

Well-Known Member
The WRITE-XML and READ-XML are only applicable when the structure of the XML matches the structure of a ProDataSet or a Temp-Table. If that is not the case you can either use the SAX or theDOM.

In general I find the SAX parser more straight forward and it does not have limits ( at least that I know of ) regarding the XML document size. The DOM is always the complete XML document loaded into memory - therefore there is a limit regarding the XML document size and in general it should only be used with small documents ( for example configuration files ). But the DOM, since you always know at which XML node you are and what the parent nodes is as you are traversing the XML node tree yourself, provides some sort of context management out-of-the-box whereas SAX does not. SAX does not provide any information where you are in the document therfore you must keep track of that yourself - as long as it is syntactically correct XML the SAX parser will be happy ( as will the DOM ).

There is no straight forward answer other than I think that you won't be able to generate that XML by WRITE-XML on a Temp-Table or ProDataSet - but YMMY.

Heavy Regards, RealHeavyDude.
 

maretix

Member
Best/Worst depends on all sorts of things, like what you want to create, but also what you find works best for you. If write XML works for you then why use something else?
Thanks for your answer.
I think i will rewrite an old procedure wrutten in X-DOM with WRITE-XML method.
I think it should be better . it is easier to do that.
 

maretix

Member
For me/us, WRITE-XML is what we'd almost always use. We'd only look to SAX (or in some cases we just output XML directly using PUT, but that's a bad idea) if the # of records involved was big enough. I might start worrying about that in the 1,000+ records range, if it were something that lots of people were doing all the time.
Thanks a lot for your answer.
I will try to rewrite an old .p with write-xml ...
Will see , records envolved are not so much ...
I will inform you about it.
Thanks.
 

maretix

Member
The WRITE-XML and READ-XML are only applicable when the structure of the XML matches the structure of a ProDataSet or a Temp-Table. If that is not the case you can either use the SAX or theDOM.

In general I find the SAX parser more straight forward and it does not have limits ( at least that I know of ) regarding the XML document size. The DOM is always the complete XML document loaded into memory - therefore there is a limit regarding the XML document size and in general it should only be used with small documents ( for example configuration files ). But the DOM, since you always know at which XML node you are and what the parent nodes is as you are traversing the XML node tree yourself, provides some sort of context management out-of-the-box whereas SAX does not. SAX does not provide any information where you are in the document therfore you must keep track of that yourself - as long as it is syntactically correct XML the SAX parser will be happy ( as will the DOM ).

There is no straight forward answer other than I think that you won't be able to generate that XML by WRITE-XML on a Temp-Table or ProDataSet - but YMMY.

Heavy Regards, RealHeavyDude.
Thanks for yoir kind reply.
 

GregTomkins

Active Member
I believe WRITE-XML does (indirectly) have *some* flexibility, ie. to make the output different than just a straight XMLification of the temp-table, by way of the XML-NODE-NAME and SERIALIZE-HIDDEN attributes in the temp-table definition. I tried to use these once and ran into Progress version trouble, so, watch out for that.
 

Similar threads

R
Replies
0
Views
5K
Rhonda Fitzgerald
R
Top