On Tue, Apr 28, 2015 at 09:57:04AM -0400, Carl Traenkner wrote:
> Hello Dave,
> 
> I have been using generateDS for many years (4+) and have loved it except
> for one issue that has always plagued me and suspect it is just that I have
> not figured out how to have generateDS take care of it. I took the schema I
> was given and broke it into many parts to prevent duplicate inner class
> name collisions... I would like to have one schema file.
> 

Carl,

Glad to hear that generateDS.py has been useful.

Sorry that I'm slow about responding with anything but that brief
earlier email.  I've been away from home and also working on other
things, including one fix to generateDS.py.

More below.

> 
> <xs:schema>
>   <xs:element name="classA">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="inner">
>           <xs:complexType>
>             <xs:attribute name="attrA1" type="string"/>
>             <xs:attribute name="attrA2" type="string"/>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> 
>   <xs:element name="classB">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="inner">
>           <xs:complexType>
>             <xs:attribute name="attrB1" type="string"/>
>             <xs:attribute name="attrB2" type="string"/>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> 
> In the early days this would only generate one instance of inner for the
> last one in the schema which would have included the code to handle attrB1
> and attrB2.
> 
> Now (well 2.12b anyway) I get two instances of inner sort of... I
> get innerType and innerType1. But now to use this I have no predictable way
> to pick the inner type names. It would be great if I could specify a switch
> so the inner class names were based on the hierarchy and it auto generated
> classA_inner and classB_inner or something along these lines so I would
> know what the names are and could even generate the name...

Thanks for explaining this issue so clearly.

This problem seems similar to, but different from, another problem
that occurs when the schema uses:

    <xs:import namespace="http://abc"; schemaLocation="schema1.xsd" />
    <xs:import namespace="http://def"; schemaLocation="schema2.xsd" />

and schema1.xsd and schema2.xsd both define an xs:complexType with
the same name, but in different namespaces.

Your suggestion to use a prefixed name in order to distinguish
between these different definitions seems like a hopeful one.  Since
that nesting of type definitions can be done to any level, I suppose
we'd need to create a prefixed name that used the entire hierarchy
of type names.  That sounds paranoid, but then with XML schema, it's
best to be paranoid.  After all, as we paranoids say, they really are
out to get us.

In the case of the xs:import with different namespaces, I suppose we
could use some transformation of the namespace as the prefix.

Doing so would complicate the *use* of the generated class, both for
the user writing code that creates instances of the class and for
generateDS.py when it generates references to that class (for
example, when it generates the build method that creates instances
of generated classes.  Those references would need to be prefixed as
well.

But, a complicated solution is better than no solution at all, which
is what we have now.

Perhaps it would simplify things, for me when I'm trying to
implement this, at least, if we *always* attach a prefix, even if in
most cases that prefix is an empty string.

Thanks again for explaining this aspect of the problem to me.  I'd
hate to have tried to solve the xs:import name conflict problem and
then later find that we'd still need a (different) solution to the
name conflict problem that you are describing.

I'll try to think about it.  I've tried doing that before, and it's
always made my head hurt.  Perhaps a couple of aspirin, or better
yet, a couple of shots of whiskey would help.  And, then when I try
to *do* something about it, I get hopelessly confused.  But, I'll
try again.  Maybe this time ...

Dave

> 
> If there is a way to do this now (2.12b) please let me know how and if not
> I bet there are others that would like to see this?
> 
> How did I get here? Not my schema I just have to use it to access a
> webservice...
> 
> Thanks
> 
> Carl
> 
> Carl Traenkner
> 941-342-9568H
> 941-806-1455W

-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to