| Author |
SAX model for XML
|
Henadeerage Henadeera
Greenhorn
Joined: Aug 13, 2011
Posts: 10
|
|
Does anybody know
how to insert an XML record to an XML file using SAX model.
I already know how to do it via DOM model. But it is memory intensive.
cheers,
Chinthaka
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
SAX isn't a model; it's a series of events sent while parsing a document, without building up any kind of model. That's why it uses less memory, because there's no model! You therefore can't create a document using SAX -- it doesn't even make sense.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Henadeerage Henadeera
Greenhorn
Joined: Aug 13, 2011
Posts: 10
|
|
Ernest Friedman-Hill wrote:SAX isn't a model; it's a series of events sent while parsing a document, without building up any kind of model. That's why it uses less memory, because there's no model! You therefore can't create a document using SAX -- it doesn't even make sense.
Do you mean that ,using SAX ,can't be updated (insert xml record) an existing XML file ???
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
Henadeerage Henadeera wrote:
Do you mean that ,using SAX ,can't be updated (insert xml record) an existing XML file ???
That is exactly what I mean. Out of the box, SAX does nothing to help you write XML documents, only read them.
Now, to be fair, you could write a SAX event handler which re-sent the events it received, inserting new events as needed to represent your new or changed content; and then another one which, based on the events it received, wrote out an XML document. Then you could connect the first one to a SAX parser, and the second one to the first one, and you'd end up with a modified XML file. I've seen where people have done things like this, actually. But it's pretty crazy stuff.
|
 |
Henadeerage Henadeera
Greenhorn
Joined: Aug 13, 2011
Posts: 10
|
|
Ernest Friedman-Hill wrote:
Henadeerage Henadeera wrote:
Do you mean that ,using SAX ,can't be updated (insert xml record) an existing XML file ???
That is exactly what I mean. Out of the box, SAX does nothing to help you write XML documents, only read them.
Now, to be fair, you could write a SAX event handler which re-sent the events it received, inserting new events as needed to represent your new or changed content; and then another one which, based on the events it received, wrote out an XML document. Then you could connect the first one to a SAX parser, and the second one to the first one, and you'd end up with a modified XML file. I've seen where people have done things like this, actually. But it's pretty crazy stuff.
Thanks for your explanation. This is really helped me...
|
 |
 |
|
|
subject: SAX model for XML
|
|
|