>From: "Carre, Olivier"
>Sent: Thursday, August 25, 2011 1:16 AM

>
> Hello Dave,
> 
> I've been playing with generateDS lately, and it is a great tool, i
> must first thank you for it. However i now need to generate xml
> documents from scratch. I mean i have the schemas, i generate the
> bindings and i want to generate an xml file from that. Can it be
> done with generateDS without too much overhead ?
>

Oliver -

Good to hear from you.

Yes, you can generate XML documents using the code generated by
generateDS.py, in fact that is one of the goals or purposes for the
project.  There is some work involved.  You can think of
generateDS.py as generating Python class definitions for each of the
element types in your schema.  (You've already figured that out, I
suppose.)  So, you need to write some code that creates instances of
those generated classes, and hooks them together with the correct
nesting.  Then call the export() function on the top-level
instance/class to generate an instance document.

Imagine a schema that defines an outerType element type contain
instances of an innerType element type.  Then you might do something
like the following:

        inner = innerType()
        outer = outerType()
        outer.set_inner(inner)
        outer.export(sys.stdout, 0)

or:

        outer = outerType(inner=innerType())
        outer.set_inner(inner)
        outer.export(sys.stdout, 0)

Of course, in a real world case, it will be quite a bit more
complex, but that should give you the idea.  Pardon me if I'm
telling you things that you've already figured out.

Hope this helps.  And when you have more questions, let me know.

- Dave



-- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to