[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Question for updating existing XML file
On Mon, Jul 26, 2004 at 10:13:46AM -0400, Chen, Andrew . wrote: > How do you update your XML files? > Example: > (in a huge XML file...) > <Entry> > <name>Jon</name> > </Entry> > ... > > If I want to update the name to Joe, or add another name Jane. So the > node looks like this: > (in a huge XML file...) > <Entry> > <name>Joe</name> > <name>Jane</name> > </Entry> > ... > > Is there a way to do this kind of update without rewrite the whole > file? My file is about 50MB. I have a related question. For a system like this, which allows dynamic update of a large XML dataset, what would be the most appropriate validation mechanism to use? My main concern is this. When you add <name>Jane</name> to the above huge document, you should not have to revalidate the whole document from scratch. Rather, you should be able to infer a minimum set of checks against the data being inserted, and the parent or ancestor elements, to ensure the document remains valid. For example, in this case perhaps you'd check that 'Jane' is valid content for <name>, and that the maximum number of <name> children for <Entry> is not exceeded, before performing the insertion. It shouldn't be necessary to revalidate the (potentially thousands) of sibling, ancestor or cousin nodes in the rest of the document. It looks to me that W3C Schema might be the appropriate mechanism here (although it's complex, and yet not as flexible as I would like: for example, maxOccurs can only be a constant value, whereas I'd like it to be an XPath expression so that the maximum number of occurences can be set in an attribute of an ancestor node) Relax-NG might work if you could identify that the parent node matched a particular production, and continued to match the same production after the insertion or modification had taken place (thus not requiring any other nodes to be reparsed). But Relax-NG seems to have some non-deterministic properties which I think make it difficult to associate a particular node uniquely with a particular grammar rule, unless you store which rule matched against each node. Schematron seems the hardest of them all, since you have a whole bunch of rules which are applied to the whole document with arbitrary XPath expressions, so inferring which rules don't need to be retested when you make a localised change to the document seems to be a difficult problem to solve. However I'm no expert in any of the above. Does anyone have any comments on my conclusions, and also any other suggestions for how to approach this issue? Thanks, Brian.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|