On 10/15/07, Callum Gibson <[EMAIL PROTECTED]> wrote: > > On 15 Oct 12:07, Henrik Frisk wrote: > }Is it possible to generate an (empty) instance document from an XML (W3C) > }Schema using libxml2? I've been searching the docs and the lists on this > }topic but please let me know if I've missed something (I'm a newbie!). > > As I was told when I asked the same question, no, not as part of libxml2. > In spite of the apparent simplicity of xml, once you start using schemas > things get very ugly, and it's not a straight forward process to map xsd > to xml.
No, in deed it is not a straight forward process! My method also generates a template document from the schema at run > time by using a callback, then uses another callback to fill in data > values from the template to generate an xml instance document. There is > therefore a slight performance penalty over the precompiled method, but > it's possible to rapidly generate new applications using the API by > defining a callback which just looks up a mapping table of xpath to your > app's data structure (which is what I did). This sounds very interesting and close to what it is I would like to achieve. I've been working with modestly sized xml documents of around 4-5k with > about 130 elements and it's working more than fast enough for my needs. > > I'd be keen on contributing it back to the community, and even having > it incorporated into the main library if it was considered worthy, and > so that support for other schema elements could be added. > > The only consideration is that I probably need to get some clearance > from my work to release the code. Hopefully there shouldn't be any problem > there since there is no business-related intellectual property in what > I've done - it's a generic solution. I have started working on a project specific solution that I think will work for now, but I'd love to see something like this included in libxml. Thanks for the feedback and information. best, Henrik
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
