Hi Dave,
Unfortunately, I have not had time to investigate this further. I tried
PyXB a few years ago, but what I didn't like was that you needed PyXB
installed just to use the generated python code. In my work, I am creating
sample scripts for our users so they can see how one might go about using
our RESTful APIs. It's preferable to me that they can use the scripts
without much setup.
Hopefully I can take a look soon.
Thanks!
On Mon Nov 10 2014 at 3:33:47 PM Dave Kuhlman <dkuhl...@davekuhlman.org>
wrote:
> > Hi Dave,
> >
> > I have attached, 2 xsd files, a valid xml file, the generated xml file,
> the
> > python file generated by generateDs, and a test python file I created.
> >
> > I ran the following comand to create enumList.py:
> >
> > generateDS.py -o enumList.py enum-list.xsd
> >
> > Then I try to create an XML file using enumListTest.py:
> >
> > from enumList import EnumList
> > import sys
> >
> > enums = EnumList()
> > enums.add_simple_type_named_enumeration("ONE")
> >
> > enums.export(sys.stdout, 0, name_='enum-list')
> >
> > I save the output to generated.xml.
> >
> > Then I run:
> >
> > xmllint --noout --valid --schema enum-list.xsd generated.xml
> >
> > and get the following report:
> >
> > generated.xml:1: validity error : Validation failed: no DTD found !
> > ns:simple-type-named-enumeration="urn:com:george:
> simple-type-named-enumeration"
> >
> > ^
> > generated.xml:2: element simple-type-named-enumeration: Schemas validity
> > error : Element '{urn:com:george:enum-list}
> simple-type-named-enumeration':
> > This element is not expected. Expected is (
> > {urn:com:george:simple-type-named-enumeration}simple-type-
> named-enumeration
> > ).
> > generated.xml fails to validate
> >
> > The issue is that the generated xml file has the following:
> >
> > <enum-list:simple-type-named-enumeration>ONE</enum-list:
> simple-type-named-enumeration>
> >
> > but it should really be
> >
> > <simple-type-named-enumeration:simple-type-named-
> enumeration>ONE</simple-type-named-enumeration:simple-type-
> named-enumeration>
>
> George,
>
> I've been spending some time on this and I'm beginning to think that
> I can't solve it. But, here are a few thoughts that might help you
> deal with it:
>
> There are two namespace definitions (and their prefixes). But, the
> generated (exported) XML has only one. generateDS.py has made a
> guess about this and generated a default definition, but it's not
> quite right. You can fix this by adding a command line option when
> you run generateDS.py that might look something like this:
>
> --namespacedef='xmlns:enum-list="urn:com:george:enum-list"
> xmlns:simple-type-named-en
> umeration="urn:com:george:simple-type-named-enumeration"
> '
>
> But the more serious problem is that we are dealing with two
> different namespaces and one of them is in the imported file.
> generateDS.py calls a function in process_includes.py to process
> those xs:import and xs:include elements in the schema and to combine
> all the included/imported schemas into a single one. But, it does
> not keep track of the namespace when it processes the xs:include and
> xs:import elements. For xs:import (but not xs:include, I believe),
> it should track the namespace that is passed in by the xs:import.
> generateDS.py and process_includes.py do not do that, and I don't
> even think I know how to approach that problem. It might even be
> that combining those schemas into a single structure is the wrong
> approach and make a solution impossible.
>
> So, I think we're stuck.
>
> I'll do some more looking. Perhaps I can find a work-around. Or,
> maybe there is a fix that is easier than I think.
>
> I'll let you know if I learn something.
>
> By the way, there is also PyXB. I believe that it does something
> roughly equivalent to what generateDS.py does, but its approach is
> quite different. The documentation suggests that it is more
> sophisticated in its handling of namespaces than generateDS.py. I
> have not taken the time to figure it out. But, perhaps it would be
> helpful to you. One thing I did find is that it generates code with
> syntax errors when you throw a schema at it that has dashes in the
> file name, for example, simple-type-named-enumeration.xsd.
>
> Dave
>
>
> >
> > I ran the code in the debugger. XschemaElement.annotate_find_type()
> seems
> > to be the culprit. It decides that simple-type-named-enumeration is of
> type
> > xs:string, instead of a SimpleTypeNamedEnumeration.
> >
> > Any ideas how to fix this? I'll continue to look at it in case I see
> > something obvious.
> >
> > Thanks,
> >
> > George
> --
>
> Dave Kuhlman
> http://www.davekuhlman.org
>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users