> Hi,
> 
> I am generating python classes for xml schema which contains
> abstract substitutionGroup. And have problems with references to
> such elements with maxOccurance="1".  Here is short example with
> difficulties i have:

Leonid,

Thanks for this patch.

However, give me time to work with this a bit.  The reason that the
mappedName, which you changed, is used is to prevent conflicts with
element names that are the same as Python keywords.  For example, we
could generate code like this:

    elif nodeName_ == 'with':
        obj_ = boosterType.factory()
        obj_.build(child_)
        self.with = obj_
        obj_.original_tagname_ = 'with'

instead of this:

    elif nodeName_ == 'with':
        obj_ = boosterType.factory()
        obj_.build(child_)
        self.with_ = obj_
        obj_.original_tagname_ = 'with'

Because "with" is a Python keyword, "self.with" produces an error.

I had forgotten about this, but one of my tests revealed it.

So, I'll investigate to see if I can adapt your fix so that it works
with both your test and mine.

Thanks for providing that test case.  It will make my work easier.

More later.

Dave

> 
> This is my shema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
> elementFormDefault="qualified">
> 
>   <xs:element name="Head">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element ref="Animal"/>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> 
>   <xs:element name="Animal" abstract="true"/>
>   <xs:element name="Dog" substitutionGroup="Animal">
>     <xs:complexType>
>       <xs:attribute name="height" use="required" type="xs:integer"/>
>     </xs:complexType>
>   </xs:element>
>   <xs:element name="Snake" substitutionGroup="Animal">
>     <xs:complexType>
>       <xs:attribute name="length" use="required" type="xs:integer"/>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> This is first test document:
> <Head>
>   <Dog height="5"/>
> </Head>
> 
> This is second:
> <Head>
>   <Snake length="5"/>
> </Head>
> 
> GenerateDS generates classes such that i have in 1st test root
> object with property Animal == None and property Dog storing
> instance of Dog, in 2nd root object with property Animal == None and
> property Snake storing instance of Snake.
> 
> I supposed to get property Animal not None and storing instance of
> Dog or Snake.  Is it right behaviour?
> 
> I tried to fix it(patch in attachment).
> 
> 
> Leonid Minchin

-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to