APIs for SAX writers

D

Duke Hamacher

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
 
J

Jan van Mansum

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 ...
 
D

Duke Hamacher

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
 
D

Donald Roby

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
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top