XML Sax writer reposition

Jan Gielissen

New Member
Hi,

Using a Sax-writer is there an easy way to change the value of the ModifyMe element after other elements have been added to the XML file.
In the real program the value of ModifyMe is unknown until the complete XML file has been build.

.
.
create sax-writer hSax.
.
.
hSax:start-element("Header").
hSax:write-data-element("ModifyMe","","",hSaxAtt).
hSax:write-data-element("Element","fixed","",hSaxAtt).
--> on this line or further down I'd like to modify the value of the ModifyMe element.
hSax:end-element("Header").

Kind regards,
 

Cecil

19+ years progress programming and still learning.
The SAX Writer is a one time pass for creating XML Documents.

Use the DOM passer to alter the required element value post creation of the XML document using the SAX Writer.
 

Jan Gielissen

New Member
I was affraid this would be the answer.

The real XML file is actually a Portugees SAFT file containing all customers, suppliers, General Ledger , General Ledger Entries and so on... = very large XML file

1) As I understand it DOM reads the complete XML file into memory before parsing. I don't know how well it will handle such a large file

2) I was thinking about using a combination of a sax-reader and a sax-writer to fill in the ModifyMe element on a second pass. Yes it would still require me to process the complete XML file 2 times.

3) Technicaly I could process a large amount of data 2 times inside the 4GL so i know the value of ModifyMe beforehand.

The real question now is which option will be the least time consuming.

Regards,

Jan
 

Cecil

19+ years progress programming and still learning.
OpenEdge use to fall over if the file XML got to big i.e. 1024 MB.

It's sound to me that you will need to uses the SAX-reader and at the same time of reading the document create and Identical XML document using the the SAX writer. During this process check for the element(s) you want to pick up on and replace the values.

It might be slow but you should be able to then handle any size XML document that you then parse.

I had to write something like this for XHTML email and replace key element values and attributes from the database. So it can be done.

Alternatively look at some sort of XQuery command line tool to do the job. (If one actually exists.) This might be an JAVA application :(
 
Top