diff --git a/README b/README index fa09f068afb855a9d0a6b47c814c1e4b3ccc29a6..9623182a9e952bde5b76752128268cd1f541ad4e 100644 --- a/README +++ b/README @@ -141,7 +141,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Change history -------------- -Version 2.9a (02/10/2013) +Version 2.9a (02/18/2013) - Added support for exporting to an Lxml element tree. The element tree can then be serialized to XML, e.g. using Lxml etree.tostring(). This innovation is by Logan Owen, who also did @@ -153,7 +153,15 @@ Version 2.9a (02/10/2013) export, export to etree (lxml element tree), or export to literal python code. This will enable users to reduce bulk in their generated files when any or all of these are not needed. The - default is "write", i.e. normal export methods. + default is "write literal", i.e. the normal export methods that we + are used to. Use the --help command line option or read the doc + for a description of this option. +- Fixed a bug that occurs when a schema has an attributeGroup + referenced with a name that includes a namespace prefix but the + attributeGroup is defined with a name that does *not* have the + namespace prefix. Thanks to Mike Detecca for reporting this and + for nudging me in the right direction when I, initially, made the + wrong fix. Version 2.8c (provisional) (01/30/2013) - Changed generated check for attributes that are already_processed diff --git a/generateDS.html b/generateDS.html index 2c56439fbba2cb66ad680edb83fca6b3384d4f29..fe174c0685de7c6be9ac46a675fb8365ecc79e05 100644 --- a/generateDS.html +++ b/generateDS.html @@ -225,7 +225,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">date:</th><td class="field-body">January 31, 2013</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">February 15, 2013</td> </tr> </tbody> </table> @@ -553,6 +553,18 @@ Options: MemberSpec_ containing member name, type, and array or not. Allowed values are "list" or "dict". Default: None. + --export=<export-list> Specifies export functions to be generated. + Value is a whitespace separated list of + any of the following: + write -- write XML to file + literal -- write out python code + etree -- build element tree (can serialize + to XML) + Examples: --export="write etree" + --export="write" + Default: --export="write literal" + -q, --no-questions Do not ask questions, for example, + force overwrite. --session=mysession.session Load and use options from session file. You can create session file in generateds_gui.py. @@ -697,6 +709,31 @@ member name, type, and array or not. See <a class="reference internal" href="#u section for more information about <tt class="docutils literal">MemberSpec_</tt>. Allowed values are "list" or "dict". Default: do <em>not</em> generate member specifications (unless --user-methods specified).</dd> +<dt>export</dt> +<dd><p class="first">Specify which of the export related member methods are to be +generated. The value is a whitespace separated list of any of the following:</p> +<ul class="simple"> +<li>write -- Generate methods <tt class="docutils literal">export</tt>, <tt class="docutils literal">exportAttributes</tt>, +and <tt class="docutils literal">exportChildren</tt>. These methods write XML to a file.</li> +<li>literal -- Generate methods <tt class="docutils literal">exportLiteral</tt>, +<tt class="docutils literal">exportLiteralAttributes</tt> and <tt class="docutils literal">exportLiteralChildren</tt>. +These methods write out python code.</li> +<li>etree -- Generate method <tt class="docutils literal">to_etree</tt>. This method builds an +lxml element tree, which can, for example, be serialized to +XML using lxml's <tt class="docutils literal">tostring</tt> function and searched with the +lxml xpath capability. You can also iterate over nodes in the +tree with the node's <tt class="docutils literal">getiterator</tt>, <tt class="docutils literal">iterchildren</tt>, etc, +and use any of lxml's other capabilities.</li> +</ul> +<p class="last">For example: <tt class="docutils literal"><span class="pre">--export="write</span> etree"</tt> and <tt class="docutils literal"><span class="pre">--export="write"</span></tt>. The +default is: <tt class="docutils literal"><span class="pre">--export="write</span> literal"</tt>.</p> +</dd> +<dt>q, no-questions</dt> +<dd>Do not ask questions. For example, if the "-f" command line +option is omitted and the ouput file exists, then generateDS.py +will not ask whether the file should be overwritten. (In this +case, when "-q" is used, the "-f" must be used to force the +output file to be written.</dd> <dt>session=mysession.session</dt> <dd>Load and use options from session file. You can create a session file in generateds_gui.py, the graphical front-end for diff --git a/generateDS.py b/generateDS.py index 6cd65c216667fd746d90e402877c4cf4435db818..d2a56f33b8fdaa0d6642edf381478e8e028c5877 100755 --- a/generateDS.py +++ b/generateDS.py @@ -164,7 +164,7 @@ logging.disable(logging.INFO) # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.8c' +VERSION = '2.9a' ##VERSION## GenerateProperties = 0 @@ -217,7 +217,7 @@ CurrentNamespacePrefix = 'xs:' AnyTypeIdentifier = '__ANY__' ExportWrite = True ExportEtree = False -ExportLiteral = False +ExportLiteral = True SchemaToPythonTypeMap = {} @@ -1091,27 +1091,26 @@ class XschemaElement(XschemaElementBase): self.replace_attributeGroup_names_1(groupName) def replace_attributeGroup_names_1(self, groupName): - key = None - if groupName in AttributeGroups: - key = groupName - else: - # Looking for name space prefix - keyList = groupName.split(':') - if len(keyList) > 1: - key1 = keyList[1] - if key1 in AttributeGroups: - key = key1 - if key is not None: - attrGroup = AttributeGroups[key] - for name in attrGroup.getKeys(): - if name in AttributeGroups: - self.replace_attributeGroup_names_1(name) - else: - attr = attrGroup.get(name) - self.attributeDefs[name] = attr - else: - err_msg('*** Error. attributeGroup %s not defined.\n' % ( - groupName, )) + key = None + if groupName in AttributeGroups: + key = groupName + else: + # Looking for name space prefix + key1 = strip_namespace(groupName) + if key1 != groupName and key1 in AttributeGroups: + key = key1 + if key is not None: + attrGroup = AttributeGroups[key] + for name in attrGroup.getKeys(): + if (name in AttributeGroups or + strip_namespace(name) in AttributeGroups): + self.replace_attributeGroup_names_1(name) + else: + attr = attrGroup.get(name) + self.attributeDefs[name] = attr + else: + err_msg('*** Error. attributeGroup %s not defined.\n' % ( + groupName, )) def __str__(self): s1 = '<XschemaElement name: "%s" type: "%s">' % \ diff --git a/generateDS.txt b/generateDS.txt index f52a60f92f14bbc9059e17c226df085819d10c05..964aa12fe490b1427633d711b5a03300491dcf27 100644 --- a/generateDS.txt +++ b/generateDS.txt @@ -11,7 +11,7 @@ generateDS -- Generate Data Structures from XML Schema .. version -:revision: 2.8c +:revision: 2.9a .. version @@ -261,6 +261,18 @@ Here is the usage message displayed by ``generateDS.py``:: MemberSpec_ containing member name, type, and array or not. Allowed values are "list" or "dict". Default: None. + --export=<export-list> Specifies export functions to be generated. + Value is a whitespace separated list of + any of the following: + write -- write XML to file + literal -- write out python code + etree -- build element tree (can serialize + to XML) + Examples: --export="write etree" + --export="write" + Default: --export="write literal" + -q, --no-questions Do not ask questions, for example, + force overwrite. --session=mysession.session Load and use options from session file. You can create session file in generateds_gui.py. @@ -422,6 +434,34 @@ member-specs values are "list" or "dict". Default: do *not* generate member specifications (unless --user-methods specified). +export + Specify which of the export related member methods are to be + generated. The value is a whitespace separated list of any of the following: + + - write -- Generate methods ``export``, ``exportAttributes``, + and ``exportChildren``. These methods write XML to a file. + + - literal -- Generate methods ``exportLiteral``, + ``exportLiteralAttributes`` and ``exportLiteralChildren``. + These methods write out python code. + + - etree -- Generate method ``to_etree``. This method builds an + lxml element tree, which can, for example, be serialized to + XML using lxml's ``tostring`` function and searched with the + lxml xpath capability. You can also iterate over nodes in the + tree with the node's ``getiterator``, ``iterchildren``, etc, + and use any of lxml's other capabilities. + + For example: ``--export="write etree"`` and ``--export="write"``. The + default is: ``--export="write literal"``. + +q, no-questions + Do not ask questions. For example, if the "-f" command line + option is omitted and the ouput file exists, then generateDS.py + will not ask whether the file should be overwritten. (In this + case, when "-q" is used, the "-f" must be used to force the + output file to be written. + session=mysession.session Load and use options from session file. You can create a session file in generateds_gui.py, the graphical front-end for diff --git a/gui/generateds_gui.py b/gui/generateds_gui.py index c05f07bdbc429cfb38a9763fa661432efc5d68cd..d14461365985407e7bfbfb00117a9f4b33cf6b49 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.8c' +VERSION = '2.9a' ##VERSION## diff --git a/libgenerateDS/gui/generateds_gui.py b/libgenerateDS/gui/generateds_gui.py index c05f07bdbc429cfb38a9763fa661432efc5d68cd..d14461365985407e7bfbfb00117a9f4b33cf6b49 100755 --- a/libgenerateDS/gui/generateds_gui.py +++ b/libgenerateDS/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.8c' +VERSION = '2.9a' ##VERSION## diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt index abc5fb07b73346988fe07833d60fd4aa2c547ee2..80cc4a4fd940edd49c32c8676fea54a4b3e58395 100644 --- a/librarytemplate_howto.txt +++ b/librarytemplate_howto.txt @@ -8,7 +8,7 @@ How to package a generateDS.py generated library .. version -:revision: 2.8c +:revision: 2.9a .. version diff --git a/process_includes.py b/process_includes.py index ad2c0526c1ed5ca060196b0a33a40baa17796354..26ce7635e622e137928e258d99f203bf82f6a710 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.8c' +VERSION = '2.9a' ##VERSION## Namespaces = {'xs': 'http://www.w3.org/2001/XMLSchema'} diff --git a/setup.py b/setup.py index f6e72db8ed0303b3aa5867f36458de1d477f7c82..c9161c0a11e72329fb320ff1c5e1320f71d874a7 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.8c", + version="2.9a", ##VERSION## author="Dave Kuhlman", author_email="dkuhlman@rexx.com", diff --git a/tutorial/generateds_tutorial.txt b/tutorial/generateds_tutorial.txt index 1f50f311f713c956d55e71ecc80a5db5033edbd8..19746c150ccb632d6ed25eda9003eaa4ef1d00c3 100644 --- a/tutorial/generateds_tutorial.txt +++ b/tutorial/generateds_tutorial.txt @@ -11,7 +11,7 @@ generateDS -- Introduction and Tutorial .. version -:revision: 2.8c +:revision: 2.9a .. version