Olof, and Bob, too,

I believe that I have found the fix for both of these problems, and
that it is the same.  I know, that sounds a bit freaky, that two
problems with different signatures reported on almost the same date
have the same cause a solution.  But, ...

So, it means that we'll definitely need to do more testing than I've
done so far.

I've attached a patch.  But, since I do not know what version you
each are using, you might be better off getting the latest copy from
https://bitbucket.org/dkuhlman/generateds

I hope this works, because, if it does, it means I only have to do
half the work to fix two problems.  And, I just love not having to
do work.

Please let me know what your tests show.  In the meantime, I'll try
to do more testing myself.

Dave

On Wed, Oct 25, 2017 at 08:58:24AM +0200, Olof Kindgren wrote:
> Thanks for looking into this. Let me know if there is anything I can do on
> my side. I will continue to dig into the generateDS code to get a better
> understanding myself
> 
> //Olof
> 
> On Wed, Oct 25, 2017 at 12:14 AM, Dave Kuhlman <dkuhl...@davekuhlman.org>
> wrote:
> 
> > Olof,
> >
> > Perhaps I have a clue on this one.  What follows is my attempt to
> > find the cause of the problem.  Tomorrow I'll *try* to find a fix.
> > But, this problem might be due to the fundamental approach that
> > generateDS.py is using, and so it might not be easily fixable.
> >
> > generateDS.py is generating this:
> >
> >         elif nodeName_ == 'addressBlock':
> >                 obj_ = bankedBlockType.factory()
> >
> > but it should generate this:
> >
> >         elif nodeName_ == 'addressBlock':
> >                 obj_ = addressBlockType.factory()
> >
> >
> > The conflict -- addressBlock -- Seems to be defined as both:
> >     - addressBlockType
> >     - bankedBlockType
> >
> > Or, at least generateDS.py thinks it is.  In other words,
> > generateDS.py seems to be, incorrectly,  overlaying the definition
> > addressBlockType with the definition bankedBlockType.
> >
> > Let me try to trace this error.  Here is an attempt to show the order
> > of definitions in memoryMap.xsd.
> >
> >     <xs:complexType name="memoryMapType">
> >         <xs:group ref="ipxact:memoryMap" minOccurs="0"
> > maxOccurs="unbounded"/>
> >             <xs:group name="memoryMap">
> >                 <xs:element ref="ipxact:addressBlock"/>
> >                     <xs:element name="addressBlock"
> > type="ipxact:addressBlockType">
> >                 <xs:element ref="ipxact:bank"/>
> >                     <xs:element name="bank" type="ipxact:addressBankType">
> >                         <xs:complexType name="addressBankType">
> >                             <xs:group name="bankBase">
> >                                 <xs:element name="addressBlock"
> > type="ipxact:bankedBlockType">
> >                                     <xs:complexType name="bankedBlockType">
> >
> > In other words:
> >
> > 1. xs:complexType memoryMapType includes the definitions from group
> >    memoryMap.
> >
> > 2. xs:group memoryMap contains:
> >
> >    2.1. addressBlock defined as addressBlockType *and*
> >
> >    2.2. bank defined as addressBankType, which contains xs:group
> >         bankBase, which defines addressBlock as bankedBlockType
> >
> > I don't know exactly why this is happening, i.e. why the correct
> > definition of addressBlock is being replaced by the incorrect one.
> > That's a problem for tomorrow.
> >
> > One of the lines you removed was the reference to bankBase in the
> > definition of addressBankType, which explains why that eliminated
> > the error.
> >
> > More on this later.
> >
> > Dave
> >
> > On Mon, Oct 23, 2017 at 12:01:19AM +0200, Olof Kindgren wrote:
> > > Hi,
> > >
> > > I have an issue where an element seems to be mapped to the wrong type.
> > I'm
> > > not sure if this is an issue with the upstream xsl or with generateDS,
> > > since both are pretty complex. After some digging however, I'm leaning
> > > towards an error with generateDS.
> > >
> > > The xsl sources I'm using are available here
> > > http://www.accellera.org/XMLSchema/IPXACT/1685-2014/ The issue I'm
> > looking
> > > at in particular can be found in memoryMap.xsl. In that file, there's a
> > > type called MemoryMapType with a child element called addressBlock
> > >
> > > If I'm using the original sources I will get something like this in the
> > > generated MemoryMapType class
> > >
> > >         elif nodeName_ == 'addressBlock':
> > >             obj_ = bankedBlockType.factory()
> > >             obj_.build(child_)
> > >             self.addressBlock.append(obj_)
> > >             obj_.original_tagname_ = 'addressBlock'
> > >         elif nodeName_ == 'bank':
> > >             obj_ = localBankedBankType.factory()
> > >             obj_.build(child_)
> > >             self.bank.append(obj_)
> > >             obj_.original_tagname_ = 'bank'
> > >
> > > This doesn't work with my XML files as they expect and addressBlockType
> > > instead of bankedBlockType.
> > >
> > > If I remove a frew lines in memoryMap.xsd as in the diff below, I get the
> > > result I expect
> > >
> > > diff --git a/2014/memoryMap.xsd b/2014/memoryMap.xsd
> > > index bd72631..1caefd7 100644
> > > --- a/2014/memoryMap.xsd
> > > +++ b/2014/memoryMap.xsd
> > > @@ -117,7 +117,6 @@
> > >                                 </xs:complexType>
> > >                         </xs:element>
> > >                         <xs:group ref="ipxact:addressSpecifier"/>
> > > -                       <xs:group ref="ipxact:bankBase"/>
> > >                 </xs:sequence>
> > >                 <xs:attribute name="bankAlignment"
> > > type="ipxact:bankAlignmentType" use="required">
> > >                         <xs:annotation>
> > > @@ -140,7 +139,6 @@
> > >                                 </xs:complexType>
> > >                         </xs:element>
> > >                         <xs:group ref="ipxact:addressSpecifier"/>
> > > -                       <xs:group ref="ipxact:localBankBase"/>
> > >                 </xs:sequence>
> > >                 <xs:attribute name="bankAlignment"
> > > type="ipxact:bankAlignmentType" use="required">
> > >                         <xs:annotation>
> > > @@ -206,7 +204,6 @@
> > >                                         </xs:sequence>
> > >                                 </xs:complexType>
> > >                         </xs:element>
> > > -                       <xs:group ref="ipxact:bankBase"/>
> > >                 </xs:sequence>
> > >                 <xs:attribute name="bankAlignment"
> > > type="ipxact:bankAlignmentType" use="required"/>
> > >                 <xs:attributeGroup ref="ipxact:id.att"/>
> > > @@ -224,7 +221,6 @@
> > >                                         </xs:sequence>
> > >                                 </xs:complexType>
> > >                         </xs:element>
> > > -                       <xs:group ref="ipxact:localBankBase"/>
> > >                 </xs:sequence>
> > >                 <xs:attribute name="bankAlignment"
> > > type="ipxact:bankAlignmentType" use="required"/>
> > >                 <xs:attributeGroup ref="ipxact:id.att"/>
> > >
> > >
> > >         elif nodeName_ == 'addressBlock':
> > >             obj_ = addressBlockType.factory()
> > >             obj_.build(child_)
> > >             self.addressBlock.append(obj_)
> > >             obj_.original_tagname_ = 'addressBlock'
> > >         elif nodeName_ == 'bank':
> > >             obj_ = addressBankType.factory()
> > >             obj_.build(child_)
> > >             self.bank.append(obj_)
> > >             obj_.original_tagname_ = 'bank'
> > >
> > > Could this be an issue with the type resolving in generateDS, or is it an
> > > upstream error? I'm sorry that I haven't got a better isolated testcase.
> > > Still trying to figure things out
> > >
> > > //Olof
> >
> > > ------------------------------------------------------------
> > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >
> > > _______________________________________________
> > > generateds-users mailing list
> > > generateds-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/generateds-users
> >
> >
> > --
> >
> > Dave Kuhlman
> > http://www.davekuhlman.org
> >

-- 

Dave Kuhlman
http://www.davekuhlman.org
diff -r dfcb8c7523dc -r f2f122c25bac generateDS.py
--- a/generateDS.py     Tue Oct 17 16:05:30 2017 -0700
+++ b/generateDS.py     Wed Oct 25 20:44:48 2017 -0700
@@ -227,7 +227,7 @@
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.28c'
+VERSION = '2.28d'
 ##VERSION##
 
 if sys.version_info.major == 2:
@@ -3795,6 +3795,10 @@
         type_element = None
         abstract_child = False
         type_name = child.getAttrs().get('type')
+        elementDef = ElementDict.get(name)
+        if elementDef is not None:
+            if elementDef.getName() != elementDef.getType():
+                type_name = elementDef.getType()
         if type_name:
             type_element = ElementDict.get(type_name)
         if type_element and type_element.isAbstract():
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to