Olof,

I believe I have a fix.  And, I suspect that you will be able to
apply the attached patch to your version of generateDS.py.

So far it passes my tests.  And, it does what we want it to do when
we use --no-namespace-defs with the ipxact schemas, if I understand
that correctly.  Running generateDS.py without --no-namespace-defs
produces things like this:

    def export(self, outfile, level, namespace_='ipxact:', 
name_='busDefinition', 
namespacedef_='xmlns:ipxact="http://www.accellera.org/XMLSchema/IPXACT/1685-2014";',
 pretty_print=True):

And, run *with* --no-namespace-defs produces:

    def export(self, outfile, level, namespace_='ipxact:', 
name_='busDefinition', namespacedef_='', pretty_print=True):

That's what we want, right?

I'll do more checking on this tomorrow.  I apologize if I've slowed
down your work.

Dave

On Wed, Mar 14, 2018 at 10:12:04AM +0100, Olof Kindgren wrote:
> Hi Dave,
> 
> Thanks for the file. It works just fine.
> 
> 
> There is however another thing that popped up.
> 
> I had to update to 2.29.9 (from 2.29.5) first, and I now notice that
> --no-namespace-defs seems broken. Diffing 2.29.5 and 2.29.9 makes me guess
> that the introduction of SchemaNamespaceDict might be the issue here. Maybe
> there's another way to get around this.
> 
> Cheers,
> Olof
> 
> 
> On Wed, Mar 14, 2018 at 12:56 AM, Dave Kuhlman <dkuhl...@davekuhlman.org>
> wrote:
> 
> > Olof,
> >
> > OK, this time it's actually attached.
> >
> > Dave
> >
> >
> > --
> >
> > Dave Kuhlman
> > http://www.davekuhlman.org
> >

-- 

Dave Kuhlman
http://www.davekuhlman.org
diff -r 17d3bb05e70a generateDS.py
--- a/generateDS.py     Wed Mar 14 11:28:30 2018 -0700
+++ b/generateDS.py     Thu Mar 15 16:09:12 2018 -0700
@@ -2836,9 +2836,13 @@
     ns_prefix = SchemaNamespaceDict.get(name)
     if ns_prefix is not None and ns_prefix[0] is not None:
         namespace = ns_prefix[0] + ':'
-        ns_def = 'xmlns:{}'.format(ns_prefix[0])
-        if ns_def not in nameSpacesDef:
-            nameSpacesDef += ' {}="{}"'.format(ns_def, ns_prefix[1])
+    # Was the --no-namespace-defs command line option used?
+    if nameSpacesDef:
+        if ns_prefix is not None and ns_prefix[0] is not None:
+            namespace = ns_prefix[0] + ':'
+            ns_def = 'xmlns:{}'.format(ns_prefix[0])
+            if ns_def not in nameSpacesDef:
+                nameSpacesDef += ' {}="{}"'.format(ns_def, ns_prefix[1])
     wrt("    def export(self, outfile, level, namespace_='%s', "
         "name_='%s', namespacedef_='%s', pretty_print=True):\n" %
         (namespace, encodedname, nameSpacesDef))
------------------------------------------------------------------------------
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