diff --git a/README b/README index 1d6c84694ab962a927d41b6c1fafcb4336b541cb..c8d896a2de0f6ea628ca3e2e5c5378c393b3c9d5 100644 --- a/README +++ b/README @@ -144,6 +144,10 @@ Change history Version 2.15b (03/04/2015) - Fix to generation of simpleType validation code for list (unbounded) elements. Thanks to wobanator for this fix. +- Fix to code for --one-file-per-xsd. Added check to avoid an + infinite loop schemas not suitable to --one-file-per-xsd. Thanks + Michael Vezie for catching this and for identifying relevant + location in the code. Version 2.15a (02/18/2015) - Modifications so that we generate code that can be used by Python 3. diff --git a/generateDS.py b/generateDS.py index b88ac014386609078e2adee8864fbc004d58367e..e14e02eff172c75a0a42c868fa6463771efd40e4 100755 --- a/generateDS.py +++ b/generateDS.py @@ -184,7 +184,7 @@ logging.disable(logging.INFO) # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.15a' +VERSION = '2.15b' ##VERSION## GenerateProperties = 0 @@ -678,7 +678,7 @@ class XschemaElement(XschemaElementBase): typeName = self.name if typeName and not self.fullyQualifiedType: namespace = self.targetNamespace - if self.prefix: + if self.prefix and self.prefix in prefixToNamespaceMap: xmlns = prefixToNamespaceMap[self.prefix] if xmlns: namespace = xmlns @@ -6094,7 +6094,10 @@ def generate(outfileName, subclassFilename, behaviorFilename, # # Generate the elements that were postponed because we had not # yet generated their base class. - while 1: + maxLoops = 100 + loops = 0 + while loops <= maxLoops: + loops += 1 if len(PostponedExtensions) <= 0: break element = PostponedExtensions.pop() @@ -6105,6 +6108,9 @@ def generate(outfileName, subclassFilename, behaviorFilename, generateClasses(wrt, prefix, element, 1) else: PostponedExtensions.insert(0, element) + if loops >= maxLoops: + sys.stderr.write('\n*** maxLoops exceeded. Something is wrong with ' + '--one-file-per-xsd.\n\n') # # Disable the generation of SAX handler/parser. # It failed when we stopped putting simple types into ElementDict. @@ -6223,7 +6229,6 @@ def parseAndGenerate( if SingleFileOutput: parser = make_parser() dh = XschemaHandler() - ## parser.setDocumentHandler(dh) parser.setContentHandler(dh) if processIncludes: import process_includes @@ -6239,10 +6244,6 @@ def parseAndGenerate( parser.parse(infile) root = dh.getRoot() root.annotate() -## print '-' * 60 -## root.show(sys.stdout, 0) -## print '-' * 60 - #debug_show_elements(root) generate( outfileName, subclassFilename, behaviorFilename, prefix, root, options, args, superModule) @@ -6259,7 +6260,7 @@ def parseAndGenerate( outfile = open(outfileName, "a") outfile.write(exportLine) outfile.close() - else: + else: # not SingleFileOutput import process_includes rootPaths = process_includes.get_all_root_file_paths( infile, inpath=xschemaFileName, diff --git a/generateDS.txt b/generateDS.txt index 84001442a2a0b23340115f39e17045c40b08e6ba..4d90a12fdd0d63ef76873e3ae07575183cb22eb3 100644 --- a/generateDS.txt +++ b/generateDS.txt @@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema .. version -:revision: 2.15a +:revision: 2.15b .. version diff --git a/gui/generateds_gui.py b/gui/generateds_gui.py index e1d26463834611bc21dd43322d1ba96dca18018c..dd14694f090d643ce971137626b4790046a5a5c4 100755 --- a/gui/generateds_gui.py +++ b/gui/generateds_gui.py @@ -31,7 +31,7 @@ from libgenerateDS.gui import generateds_gui_session # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.15a' +VERSION = '2.15b' ##VERSION## diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt index 8ae28acffc6ab7b55dc49abe70a08079ab5eddf3..3a3f9c2228ad4fba57ddea25f3ba85af15f426bf 100644 --- a/librarytemplate_howto.txt +++ b/librarytemplate_howto.txt @@ -8,7 +8,7 @@ How to package a generateDS.py generated library .. version -:revision: 2.15a +:revision: 2.15b .. version diff --git a/process_includes.py b/process_includes.py index 8c326a17b9c979c6e8c9bf5386916ee5d3d0eab0..62f4fe6582fa30c182a2f0d3c4706fe7a22c510a 100755 --- a/process_includes.py +++ b/process_includes.py @@ -30,7 +30,7 @@ from lxml import etree # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.15a' +VERSION = '2.15b' ##VERSION## CatalogDict = {} diff --git a/setup.py b/setup.py index c24e5513e66464ddcabb1865859fafe56e9116c3..f0bb6dd6754a182938d2881bbbc57760744b7773 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup(name="generateDS", # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## - version="2.15a", + version="2.15b", ##VERSION## author="Dave Kuhlman", author_email="dkuhlman@davekuhlman.org", diff --git a/tutorial/generateds_tutorial.txt b/tutorial/generateds_tutorial.txt index d01a293fd48d6fe8ad3eeb65aab9f27aa7df996e..adf2b8b3a64b1e508f909b7c1c124873a6fdf915 100644 --- a/tutorial/generateds_tutorial.txt +++ b/tutorial/generateds_tutorial.txt @@ -11,7 +11,7 @@ generateDS -- Introduction and Tutorial .. version -:revision: 2.15a +:revision: 2.15b .. version