APIs for SAX writers

Duke Hamacher

Usenet Archive
Joined
Oct 27, 2003
Messages
7
Reaction score
0
I have a situation where I occasionally would like to insert an element in an XML file I'm parsing, while I'm parsing it. Are there any dependable APIs for this? Thanx.

Duke Hamacher
 

Jan van Mansum

Usenet Archive
Joined
Jun 5, 2004
Messages
9
Reaction score
0
Duke said:
I have a situation where I occasionally would like to insert an element in an XML file I'm parsing, while I'm parsing it. Are there any dependable APIs for this? Thanx.

Duke Hamacher

Why would you want to do that? I don't know what the problems is you are trying to solve, but you might want to transform your source xml before parsing it ...
 

Duke Hamacher

Usenet Archive
Joined
Oct 27, 2003
Messages
7
Reaction score
0
I know, it seems odd, but this world presents odd situations. What is going on is this . . . I have a client who will not necessarily follow our schema (for complex reasons). If they make a certain error, it would be most efficient to correct it on the spot (during parsing) and save the need to communicate the problem back to my client. Certainly, there are other ways fix files, but SAX writing provides the best answer resource and time-wise.

Thanx for repsonding,
Duke
 

Donald Roby

Usenet Archive
Joined
May 15, 2004
Messages
12
Reaction score
0
I know, it seems odd, but this world presents odd situations. What is going on is this . . . I have a client who will not necessarily follow our schema (for complex reasons). If they make a certain error, it would be most efficient to correct it on the spot (during parsing) and save the need to communicate the problem back to my client. Certainly, there are other ways fix files, but SAX writing provides the best answer resource and time-wise.
To do this during SAX parsing, you'll want to setup a SAX ContentHandler. Look at http://www-106.ibm.com/developerworks/library/x-tiphandl.html for a good explanation of the basics. DeveloperWorks has quite a few good articles on things like this, so their XML section might be worth a more general browse.

If the error is regular enough, it might be cleaner and simpler to do with XSLT as the previous responder suggested. And if it's not, the code to fix it during parsing might also be a bear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top