views:

665

answers:

1

I've been struggling quite a bit with Xerces C++ and my unfamiliarity with all that is XML, but I need to use XML for a project I'm working on.

My question is how do I serialize portions of a DOM tree that I have already parsed and created of out of a XML instance document (validated against a schema I wrote) so that I can create many new instance documents (still containing the root element of the original document) in a way that they remain valid against my schema?

To be more specific, I have a large instance document with thousands of sets contained within a single root element that I need to individually place into separate files for later processing. Basically a large set of sets which need to each be placed into individual files and still validate separately.

I'm lost on the whole process of how to do this. I've not had any luck finding examples that serialize portions of a DOM tree and I find a lot of the terminology surrounding XML related documentation less than helpful.

Thanks in advance.

+1  A: 

Does this article (Section: XML Schema validation using serialization of grammars to disk) help?

We have successfully used the MemBufFormat described here.

dirkgently
I found the first link on my own a few times, and though helpful in general, it doesn't quite relate to what I'm trying to do. Your second link seems to be almost exactly what I was looking for, but I don't want to serialize the whole tree, just portions of it. I think this is taking me on the right track though, so thank you kindly!
Joe
A subset of a well formed XML will also be a well formed XML -- so best of luck with that! (Also don't forget to mention if you've seen something -- our replies will be less redundant.)
dirkgently
Yes, I've heard that before, so my hope is that validation will work out for the best by default. I think I'm going to try and go with the LocalFileFormatTarget serialization to start with. I just need to figure out the best way to get at the the data I need. If I serialize a DOMNode, will that get all of its sub-elements, attributes, and data as well or do I need to go down further in the tree at each? Thanks again.
Joe
IIRC, you'd need to run down the subtree. Here's the documentation: <http://xerces.apache.org/xerces-c/apiDocs-2/classDOMWriter.html#06fc41c008b30284736290bbab0a0aa8>
dirkgently
That's going to be fun. Thanks a lot for your help!
Joe