From b8e7b683292b49ffecdfce2dd7f05da388786864 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Tue, 21 Apr 2020 19:04:10 +0200 Subject: [PATCH] update generated PAGE core w/ generateDS 2.35.18 --- .../ocrd_models/ocrd_page_generateds.py | 5095 +++++++++++++---- requirements_test.txt | 2 +- tests/model/test_ocrd_page.py | 2 +- 3 files changed, 3849 insertions(+), 1250 deletions(-) diff --git a/ocrd_models/ocrd_models/ocrd_page_generateds.py b/ocrd_models/ocrd_models/ocrd_page_generateds.py index 5db34adaf..420348477 100644 --- a/ocrd_models/ocrd_models/ocrd_page_generateds.py +++ b/ocrd_models/ocrd_models/ocrd_page_generateds.py @@ -2,29 +2,32 @@ # -*- coding: utf-8 -*- # -# Generated Mon Aug 5 20:18:48 2019 by generateDS.py version 2.30.11. -# Python 3.6.6 (default, Jul 24 2018, 16:39:20) [GCC 4.9.2] +# Generated Tue Apr 21 18:42:25 2020 by generateDS.py version 2.35.18. +# Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] # # Command line options: # ('-f', '') # ('--root-element', 'PcGts') +# ('--user-methods', 'ocrd_models/ocrd_page_user_methods.py') # ('-o', 'ocrd_models/ocrd_models/ocrd_page_generateds.py') # # Command line arguments: # repo/assets/data/schema/data/2019.xsd # # Command line: -# /data/monorepo/venv3.6/bin/generateDS -f --root-element="PcGts" -o "ocrd_models/ocrd_models/ocrd_page_generateds.py" repo/assets/data/schema/data/2019.xsd +# /home/kba/env/py3/bin/generateDS -f --root-element="PcGts" --user-methods="ocrd_models/ocrd_page_user_methods.py" -o "ocrd_models/ocrd_models/ocrd_page_generateds.py" repo/assets/data/schema/data/2019.xsd # # Current working directory (os.getcwd()): # core # +from six.moves import zip_longest +import os import sys import re as re_ import base64 import datetime as datetime_ -import warnings as warnings_ +import decimal as decimal_ try: from lxml import etree as etree_ except ImportError: @@ -32,6 +35,7 @@ Validate_simpletypes_ = True +SaveElementTreeNode = True if sys.version_info.major == 2: BaseStrType_ = basestring else: @@ -47,6 +51,11 @@ def parsexml_(infile, parser=None, **kwargs): except AttributeError: # fallback to xml.etree parser = etree_.XMLParser() + try: + if isinstance(infile, os.PathLike): + infile = os.path.join(infile) + except AttributeError: + pass doc = etree_.parse(infile, parser=parser, **kwargs) return doc @@ -71,7 +80,7 @@ def parsexmlstring_(instring, parser=None, **kwargs): # definitions. The export method for any class for which there is # a namespace prefix definition, will export that definition in the # XML representation of that element. See the export method of -# any generated element type class for a example of the use of this +# any generated element type class for an example of the use of this # table. # A sample table is: # @@ -82,11 +91,75 @@ def parsexmlstring_(instring, parser=None, **kwargs): # "ElementtypeB": "http://www.xxx.com/namespaceB", # } # +# Additionally, the generatedsnamespaces module can contain a python +# dictionary named GenerateDSNamespaceTypePrefixes that associates element +# types with the namespace prefixes that are to be added to the +# "xsi:type" attribute value. See the exportAttributes method of +# any generated element type and the generation of "xsi:type" for an +# example of the use of this table. +# An example table: +# +# # File: generatedsnamespaces.py +# +# GenerateDSNamespaceTypePrefixes = { +# "ElementtypeC": "aaa:", +# "ElementtypeD": "bbb:", +# } +# try: from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ except ImportError: GenerateDSNamespaceDefs_ = {} +try: + from generatedsnamespaces import GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_ +except ImportError: + GenerateDSNamespaceTypePrefixes_ = {} + +# +# You can replace the following class definition by defining an +# importable module named "generatedscollector" containing a class +# named "GdsCollector". See the default class definition below for +# clues about the possible content of that class. +# +try: + from generatedscollector import GdsCollector as GdsCollector_ +except ImportError: + + class GdsCollector_(object): + + def __init__(self, messages=None): + if messages is None: + self.messages = [] + else: + self.messages = messages + + def add_message(self, msg): + self.messages.append(msg) + + def get_messages(self): + return self.messages + + def clear_messages(self): + self.messages = [] + + def print_messages(self): + for msg in self.messages: + print("Warning: {}".format(msg)) + + def write_messages(self, outstream): + for msg in self.messages: + outstream.write("Warning: {}\n".format(msg)) + + +# +# The super-class for enum types +# + +try: + from enum import Enum +except ImportError: + Enum = object # # The root super-class for element type classes @@ -100,6 +173,7 @@ def parsexmlstring_(instring, parser=None, **kwargs): except ImportError as exp: class GeneratedsSuper(object): + __hash__ = object.__hash__ tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$') class _FixedOffsetTZ(datetime_.tzinfo): def __init__(self, offset, name): @@ -113,6 +187,8 @@ def dst(self, dt): return None def gds_format_string(self, input_data, input_name=''): return input_data + def gds_parse_string(self, input_data, node=None, input_name=''): + return input_data def gds_validate_string(self, input_data, node=None, input_name=''): if not input_data: return '' @@ -124,8 +200,18 @@ def gds_validate_base64(self, input_data, node=None, input_name=''): return input_data def gds_format_integer(self, input_data, input_name=''): return '%d' % input_data + def gds_parse_integer(self, input_data, node=None, input_name=''): + try: + ival = int(input_data) + except (TypeError, ValueError) as exp: + raise_parse_error(node, 'Requires integer value: %s' % exp) + return ival def gds_validate_integer(self, input_data, node=None, input_name=''): - return input_data + try: + value = int(input_data) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires integer value') + return value def gds_format_integer_list(self, input_data, input_name=''): return '%s' % ' '.join(input_data) def gds_validate_integer_list( @@ -135,12 +221,22 @@ def gds_validate_integer_list( try: int(value) except (TypeError, ValueError): - raise_parse_error(node, 'Requires sequence of integers') + raise_parse_error(node, 'Requires sequence of integer valuess') return values def gds_format_float(self, input_data, input_name=''): return ('%.15f' % input_data).rstrip('0') + def gds_parse_float(self, input_data, node=None, input_name=''): + try: + fval_ = float(input_data) + except (TypeError, ValueError) as exp: + raise_parse_error(node, 'Requires float or double value: %s' % exp) + return fval_ def gds_validate_float(self, input_data, node=None, input_name=''): - return input_data + try: + value = float(input_data) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires float value') + return value def gds_format_float_list(self, input_data, input_name=''): return '%s' % ' '.join(input_data) def gds_validate_float_list( @@ -150,12 +246,47 @@ def gds_validate_float_list( try: float(value) except (TypeError, ValueError): - raise_parse_error(node, 'Requires sequence of floats') + raise_parse_error(node, 'Requires sequence of float values') + return values + def gds_format_decimal(self, input_data, input_name=''): + return ('%s' % input_data).rstrip('0') + def gds_parse_decimal(self, input_data, node=None, input_name=''): + try: + decimal_value = decimal_.Decimal(input_data) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires decimal value') + return decimal_value + def gds_validate_decimal(self, input_data, node=None, input_name=''): + try: + value = decimal_.Decimal(input_data) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires decimal value') + return value + def gds_format_decimal_list(self, input_data, input_name=''): + return '%s' % ' '.join(input_data) + def gds_validate_decimal_list( + self, input_data, node=None, input_name=''): + values = input_data.split() + for value in values: + try: + decimal_.Decimal(value) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires sequence of decimal values') return values def gds_format_double(self, input_data, input_name=''): return '%e' % input_data + def gds_parse_double(self, input_data, node=None, input_name=''): + try: + fval_ = float(input_data) + except (TypeError, ValueError) as exp: + raise_parse_error(node, 'Requires double or float value: %s' % exp) + return fval_ def gds_validate_double(self, input_data, node=None, input_name=''): - return input_data + try: + value = float(input_data) + except (TypeError, ValueError): + raise_parse_error(node, 'Requires double or float value') + return value def gds_format_double_list(self, input_data, input_name=''): return '%s' % ' '.join(input_data) def gds_validate_double_list( @@ -165,11 +296,25 @@ def gds_validate_double_list( try: float(value) except (TypeError, ValueError): - raise_parse_error(node, 'Requires sequence of doubles') + raise_parse_error( + node, 'Requires sequence of double or float values') return values def gds_format_boolean(self, input_data, input_name=''): return ('%s' % input_data).lower() + def gds_parse_boolean(self, input_data, node=None, input_name=''): + if input_data in ('true', '1'): + bval = True + elif input_data in ('false', '0'): + bval = False + else: + raise_parse_error(node, 'Requires boolean value') + return bval def gds_validate_boolean(self, input_data, node=None, input_name=''): + if input_data not in (True, 1, False, 0, ): + raise_parse_error( + node, + 'Requires boolean value ' + '(one of True, 1, False, 0)') return input_data def gds_format_boolean_list(self, input_data, input_name=''): return '%s' % ' '.join(input_data) @@ -177,11 +322,11 @@ def gds_validate_boolean_list( self, input_data, node=None, input_name=''): values = input_data.split() for value in values: - if value not in ('true', '1', 'false', '0', ): + if value not in (True, 1, False, 0, ): raise_parse_error( node, - 'Requires sequence of booleans ' - '("true", "1", "false", "0")') + 'Requires sequence of boolean values ' + '(one of True, 1, False, 0)') return values def gds_validate_datetime(self, input_data, node=None, input_name=''): return input_data @@ -366,6 +511,50 @@ def gds_parse_time(cls, input_data): dt = datetime_.datetime.strptime(input_data, '%H:%M:%S') dt = dt.replace(tzinfo=tz) return dt.time() + def gds_check_cardinality_( + self, value, input_name, + min_occurs=0, max_occurs=1, required=None): + if value is None: + length = 0 + elif isinstance(value, list): + length = len(value) + else: + length = 1 + if required is not None : + if required and length < 1: + self.gds_collector_.add_message( + "Required value {}{} is missing".format( + input_name, self.gds_get_node_lineno_())) + if length < min_occurs: + self.gds_collector_.add_message( + "Number of values for {}{} is below " + "the minimum allowed, " + "expected at least {}, found {}".format( + input_name, self.gds_get_node_lineno_(), + min_occurs, length)) + elif length > max_occurs: + self.gds_collector_.add_message( + "Number of values for {}{} is above " + "the maximum allowed, " + "expected at most {}, found {}".format( + input_name, self.gds_get_node_lineno_(), + max_occurs, length)) + def gds_validate_builtin_ST_( + self, validator, value, input_name, + min_occurs=None, max_occurs=None, required=None): + if value is not None: + try: + validator(value, input_name=input_name) + except GDSParseError as parse_error: + self.gds_collector_.add_message(str(parse_error)) + def gds_validate_defined_ST_( + self, validator, value, input_name, + min_occurs=None, max_occurs=None, required=None): + if value is not None: + try: + validator(value) + except GDSParseError as parse_error: + self.gds_collector_.add_message(str(parse_error)) def gds_str_lower(self, instring): return instring.lower() def get_path_(self, node): @@ -395,7 +584,10 @@ def get_class_obj_(self, node, default_class=None): class_obj1 = class_obj2 return class_obj1 def gds_build_any(self, node, type_name=None): - return None + # provide default value in case option --disable-xml is used. + content = "" + content = etree_.tostring(node, encoding="unicode") + return content @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.items())) @@ -419,11 +611,34 @@ def convert_unicode(instring): result = GeneratedsSuper.gds_encode(str(instring)) return result def __eq__(self, other): + def excl_select_objs_(obj): + return (obj[0] != 'parent_object_' and + obj[0] != 'gds_collector_') if type(self) != type(other): return False - return self.__dict__ == other.__dict__ + return all(x == y for x, y in zip_longest( + filter(excl_select_objs_, self.__dict__.items()), + filter(excl_select_objs_, other.__dict__.items()))) def __ne__(self, other): return not self.__eq__(other) + # Django ETL transform hooks. + def gds_djo_etl_transform(self): + pass + def gds_djo_etl_transform_db_obj(self, dbobj): + pass + # SQLAlchemy ETL transform hooks. + def gds_sqa_etl_transform(self): + return 0, None + def gds_sqa_etl_transform_db_obj(self, dbobj): + pass + def gds_get_node_lineno_(self): + if (hasattr(self, "gds_elementtree_node_") and + self.gds_elementtree_node_ is not None): + return ' near line {}'.format( + self.gds_elementtree_node_.sourceline) + else: + return "" + def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -454,6 +669,10 @@ def getSubclassFromModule_(module, class_): # ExternalEncoding = '' +# Set this to false in order to deactivate during export, the use of +# name space prefixes captured from the input document. +UseCapturedNS_ = True +CapturedNsmap_ = {} Tag_pattern_ = re_.compile(r'({.*})?(.*)') String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)') @@ -555,12 +774,17 @@ def find_attr_value_(attr_name, node): return value +def encode_str_2_3(instr): + return instr + + class GDSParseError(Exception): pass def raise_parse_error(node, msg): - msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, ) + if node is not None: + msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, ) raise GDSParseError(msg) @@ -625,7 +849,7 @@ def exportSimple(self, outfile, level, name): self.name, base64.b64encode(self.value), self.name)) - def to_etree(self, element): + def to_etree(self, element, mapping_=None, nsmap_=None): if self.category == MixedContainer.CategoryText: # Prevent exporting empty content as empty lines. if self.value.strip(): @@ -645,7 +869,7 @@ def to_etree(self, element): subelement.text = self.to_etree_simple() else: # category == MixedContainer.CategoryComplex self.value.to_etree(element) - def to_etree_simple(self): + def to_etree_simple(self, mapping_=None, nsmap_=None): if self.content_type == MixedContainer.TypeString: text = self.value elif (self.content_type == MixedContainer.TypeInteger or @@ -723,14 +947,14 @@ def _cast(typ, value): # -class AlignSimpleType(object): +class AlignSimpleType(Enum): LEFT='left' CENTRE='centre' RIGHT='right' JUSTIFY='justify' -class ChartTypeSimpleType(object): +class ChartTypeSimpleType(Enum): BAR='bar' LINE='line' PIE='pie' @@ -739,14 +963,14 @@ class ChartTypeSimpleType(object): OTHER='other' -class ColourDepthSimpleType(object): +class ColourDepthSimpleType(Enum): BILEVEL='bilevel' GREYSCALE='greyscale' COLOUR='colour' OTHER='other' -class ColourSimpleType(object): +class ColourSimpleType(Enum): BLACK='black' BLUE='blue' BROWN='brown' @@ -765,7 +989,7 @@ class ColourSimpleType(object): OTHER='other' -class GraphicsTypeSimpleType(object): +class GraphicsTypeSimpleType(Enum): LOGO='logo' LETTERHEAD='letterhead' DECORATION='decoration' @@ -779,7 +1003,7 @@ class GraphicsTypeSimpleType(object): OTHER='other' -class GroupTypeSimpleType(object): +class GroupTypeSimpleType(Enum): PARAGRAPH='paragraph' LIST='list' LISTITEM='list-item' @@ -789,7 +1013,7 @@ class GroupTypeSimpleType(object): OTHER='other' -class PageTypeSimpleType(object): +class PageTypeSimpleType(Enum): FRONTCOVER='front-cover' BACKCOVER='back-cover' TITLE='title' @@ -800,7 +1024,8 @@ class PageTypeSimpleType(object): OTHER='other' -class ProductionSimpleType(object): +class ProductionSimpleType(Enum): + """Text production type""" PRINTED='printed' TYPEWRITTEN='typewritten' HANDWRITTENCURSIVE='handwritten-cursive' @@ -809,33 +1034,33 @@ class ProductionSimpleType(object): OTHER='other' -class ReadingDirectionSimpleType(object): +class ReadingDirectionSimpleType(Enum): LEFTTORIGHT='left-to-right' RIGHTTOLEFT='right-to-left' TOPTOBOTTOM='top-to-bottom' BOTTOMTOTOP='bottom-to-top' -class TextDataTypeSimpleType(object): - XSDDECIMAL='xsd:decimal' - XSDFLOAT='xsd:float' - XSDINTEGER='xsd:integer' - XSDBOOLEAN='xsd:boolean' - XSDDATE='xsd:date' - XSDTIME='xsd:time' - XSDDATE_TIME='xsd:dateTime' - XSDSTRING='xsd:string' - OTHER='other' +class TextDataTypeSimpleType(Enum): + XSDDECIMAL='xsd:decimal' # Examples: "123.456", "+1234.456", "-1234.456", "-.456", "-456" + XSDFLOAT='xsd:float' # Examples: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", "NaN" + XSDINTEGER='xsd:integer' # Examples: "123456", "+00000012", "-1", "-456" + XSDBOOLEAN='xsd:boolean' # Examples: "true", "false", "1", "0" + XSDDATE='xsd:date' # Examples: "2001-10-26", "2001-10-26+02:00", "2001-10-26Z", "2001-10-26+00:00", "-2001-10-26", "-20000-04-01" + XSDTIME='xsd:time' # Examples: "21:32:52", "21:32:52+02:00", "19:32:52Z", "19:32:52+00:00", "21:32:52.12679" + XSDDATE_TIME='xsd:dateTime' # Examples: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", "2001-10-26T21:32:52.12679" + XSDSTRING='xsd:string' # Generic text string + OTHER='other' # An XSD type that is not listed or a custom type (use dataTypeDetails attribute). -class TextLineOrderSimpleType(object): +class TextLineOrderSimpleType(Enum): TOPTOBOTTOM='top-to-bottom' BOTTOMTOTOP='bottom-to-top' LEFTTORIGHT='left-to-right' RIGHTTOLEFT='right-to-left' -class TextTypeSimpleType(object): +class TextTypeSimpleType(Enum): PARAGRAPH='paragraph' HEADING='heading' CAPTION='caption' @@ -856,21 +1081,33 @@ class TextTypeSimpleType(object): OTHER='other' -class underlineStyleType(object): +class underlineStyleType(Enum): SINGLE_LINE='singleLine' DOUBLE_LINE='doubleLine' OTHER='other' class PcGtsType(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('pcGtsId', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('Metadata', 'MetadataType', 0, 0, {'name': 'Metadata', 'type': 'MetadataType'}, None), + MemberSpec_('Page', 'PageType', 0, 0, {'name': 'Page', 'type': 'PageType'}, None), + ] subclass = None superclass = None - def __init__(self, pcGtsId=None, Metadata=None, Page=None, **kwargs_): + def __init__(self, pcGtsId=None, Metadata=None, Page=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.pcGtsId = _cast(None, pcGtsId) + self.pcGtsId_nsprefix_ = None self.Metadata = Metadata + self.Metadata_nsprefix_ = None self.Page = Page + self.Page_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -882,6 +1119,10 @@ def factory(*args_, **kwargs_): else: return PcGtsType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Metadata(self): return self.Metadata def set_Metadata(self, Metadata): @@ -902,7 +1143,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('PcGtsType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -910,8 +1151,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'PcGtsType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -923,70 +1166,98 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='PcGtsType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PcGtsType'): if self.pcGtsId is not None and 'pcGtsId' not in already_processed: already_processed.add('pcGtsId') outfile.write(' pcGtsId=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.pcGtsId), input_name='pcGtsId')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.Metadata is not None: + namespaceprefix_ = self.Metadata_nsprefix_ + ':' if (UseCapturedNS_ and self.Metadata_nsprefix_) else '' self.Metadata.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Metadata', pretty_print=pretty_print) if self.Page is not None: + namespaceprefix_ = self.Page_nsprefix_ + ':' if (UseCapturedNS_ and self.Page_nsprefix_) else '' self.Page.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Page', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('pcGtsId', node) if value is not None and 'pcGtsId' not in already_processed: already_processed.add('pcGtsId') self.pcGtsId = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Metadata': obj_ = MetadataType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Metadata = obj_ obj_.original_tagname_ = 'Metadata' elif nodeName_ == 'Page': obj_ = PageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Page = obj_ obj_.original_tagname_ = 'Page' + def __hash__(self): + return hash(self.id) # end class PcGtsType class MetadataType(GeneratedsSuper): """External reference of any kind""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('externalRef', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('Creator', 'string', 0, 0, {'name': 'Creator', 'type': 'string'}, None), + MemberSpec_('Created', 'dateTime', 0, 0, {'name': 'Created', 'type': 'dateTime'}, None), + MemberSpec_('LastChange', 'dateTime', 0, 0, {'name': 'LastChange', 'type': 'dateTime'}, None), + MemberSpec_('Comments', 'string', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Comments', 'type': 'string'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('MetadataItem', 'MetadataItemType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'MetadataItem', 'type': 'MetadataItemType'}, None), + ] subclass = None superclass = None - def __init__(self, externalRef=None, Creator=None, Created=None, LastChange=None, Comments=None, UserDefined=None, MetadataItem=None, **kwargs_): + def __init__(self, externalRef=None, Creator=None, Created=None, LastChange=None, Comments=None, UserDefined=None, MetadataItem=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.externalRef = _cast(None, externalRef) + self.externalRef_nsprefix_ = None self.Creator = Creator + self.Creator_nsprefix_ = None if isinstance(Created, BaseStrType_): initvalue_ = datetime_.datetime.strptime(Created, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = Created self.Created = initvalue_ + self.Created_nsprefix_ = None if isinstance(LastChange, BaseStrType_): initvalue_ = datetime_.datetime.strptime(LastChange, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = LastChange self.LastChange = initvalue_ + self.LastChange_nsprefix_ = None self.Comments = Comments + self.Comments_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if MetadataItem is None: self.MetadataItem = [] else: self.MetadataItem = MetadataItem + self.MetadataItem_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -998,6 +1269,10 @@ def factory(*args_, **kwargs_): else: return MetadataType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Creator(self): return self.Creator def set_Creator(self, Creator): @@ -1024,8 +1299,6 @@ def set_MetadataItem(self, MetadataItem): self.MetadataItem = MetadataItem def add_MetadataItem(self, value): self.MetadataItem.append(value) - def add_MetadataItem(self, value): - self.MetadataItem.append(value) def insert_MetadataItem_at(self, index, value): self.MetadataItem.insert(index, value) def replace_MetadataItem_at(self, index, value): @@ -1046,7 +1319,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -1054,8 +1327,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'MetadataType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -1067,84 +1342,117 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='MetadataType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataType'): if self.externalRef is not None and 'externalRef' not in already_processed: already_processed.add('externalRef') outfile.write(' externalRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalRef), input_name='externalRef')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.Creator is not None: + namespaceprefix_ = self.Creator_nsprefix_ + ':' if (UseCapturedNS_ and self.Creator_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sCreator>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Creator), input_name='Creator')), namespaceprefix_ , eol_)) if self.Created is not None: + namespaceprefix_ = self.Created_nsprefix_ + ':' if (UseCapturedNS_ and self.Created_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sCreated>%s%s' % (namespaceprefix_ , self.gds_format_datetime(self.Created, input_name='Created'), namespaceprefix_ , eol_)) if self.LastChange is not None: + namespaceprefix_ = self.LastChange_nsprefix_ + ':' if (UseCapturedNS_ and self.LastChange_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sLastChange>%s%s' % (namespaceprefix_ , self.gds_format_datetime(self.LastChange, input_name='LastChange'), namespaceprefix_ , eol_)) if self.Comments is not None: + namespaceprefix_ = self.Comments_nsprefix_ + ':' if (UseCapturedNS_ and self.Comments_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sComments>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Comments), input_name='Comments')), namespaceprefix_ , eol_)) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for MetadataItem_ in self.MetadataItem: + namespaceprefix_ = self.MetadataItem_nsprefix_ + ':' if (UseCapturedNS_ and self.MetadataItem_nsprefix_) else '' MetadataItem_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MetadataItem', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('externalRef', node) if value is not None and 'externalRef' not in already_processed: already_processed.add('externalRef') self.externalRef = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Creator': - Creator_ = child_.text - Creator_ = self.gds_validate_string(Creator_, node, 'Creator') - self.Creator = Creator_ + value_ = child_.text + value_ = self.gds_parse_string(value_, node, 'Creator') + value_ = self.gds_validate_string(value_, node, 'Creator') + self.Creator = value_ + self.Creator_nsprefix_ = child_.prefix elif nodeName_ == 'Created': sval_ = child_.text dval_ = self.gds_parse_datetime(sval_) self.Created = dval_ + self.Created_nsprefix_ = child_.prefix elif nodeName_ == 'LastChange': sval_ = child_.text dval_ = self.gds_parse_datetime(sval_) self.LastChange = dval_ + self.LastChange_nsprefix_ = child_.prefix elif nodeName_ == 'Comments': - Comments_ = child_.text - Comments_ = self.gds_validate_string(Comments_, node, 'Comments') - self.Comments = Comments_ + value_ = child_.text + value_ = self.gds_parse_string(value_, node, 'Comments') + value_ = self.gds_validate_string(value_, node, 'Comments') + self.Comments = value_ + self.Comments_nsprefix_ = child_.prefix elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'MetadataItem': obj_ = MetadataItemType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MetadataItem.append(obj_) obj_.original_tagname_ = 'MetadataItem' + def __hash__(self): + return hash(self.id) # end class MetadataType class MetadataItemType(GeneratedsSuper): - """Type of metadata (e.g. author) E.g. imagePhotometricInterpretation + """Type of metadata (e.g. author) + E.g. imagePhotometricInterpretation E.g. RGB""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('type_', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('name', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('value', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('date', 'dateTime', 0, 1, {'use': 'optional'}), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + ] subclass = None superclass = None - def __init__(self, type_=None, name=None, value=None, date=None, Labels=None, **kwargs_): + def __init__(self, type_=None, name=None, value=None, date=None, Labels=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.name = _cast(None, name) + self.name_nsprefix_ = None self.value = _cast(None, value) + self.value_nsprefix_ = None if isinstance(date, BaseStrType_): initvalue_ = datetime_.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S') else: @@ -1154,6 +1462,7 @@ def __init__(self, type_=None, name=None, value=None, date=None, Labels=None, ** self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -1165,14 +1474,16 @@ def factory(*args_, **kwargs_): else: return MetadataItemType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Labels(self): return self.Labels def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -1200,7 +1511,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataItemType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -1208,8 +1519,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'MetadataItemType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -1221,7 +1534,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='MetadataItemType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataItemType'): if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) @@ -1234,19 +1547,24 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.date is not None and 'date' not in already_processed: already_processed.add('date') outfile.write(' date="%s"' % self.gds_format_datetime(self.date, input_name='date')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('type', node) @@ -1268,32 +1586,51 @@ def buildAttributes(self, node, attrs, already_processed): self.date = self.gds_parse_datetime(value) except ValueError as exp: raise ValueError('Bad date-time attribute (date): %s' % exp) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' + def __hash__(self): + return hash(self.id) # end class MetadataItemType class LabelsType(GeneratedsSuper): - """Reference to external model / ontology / schema E.g. an RDF resource - identifier (to be used as subject or object of an RDF triple) + """Reference to external model / ontology / schema + E.g. an RDF resource identifier + (to be used as subject or object of an RDF triple) Prefix for all labels (e.g. first part of an URI)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('externalModel', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('externalId', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('prefix', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('Label', 'LabelType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Label', 'type': 'LabelType'}, None), + ] subclass = None superclass = None - def __init__(self, externalModel=None, externalId=None, prefix=None, comments=None, Label=None, **kwargs_): + def __init__(self, externalModel=None, externalId=None, prefix=None, comments=None, Label=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.externalModel = _cast(None, externalModel) + self.externalModel_nsprefix_ = None self.externalId = _cast(None, externalId) + self.externalId_nsprefix_ = None self.prefix = _cast(None, prefix) + self.prefix_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None if Label is None: self.Label = [] else: self.Label = Label + self.Label_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -1305,14 +1642,16 @@ def factory(*args_, **kwargs_): else: return LabelsType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Label(self): return self.Label def set_Label(self, Label): self.Label = Label def add_Label(self, value): self.Label.append(value) - def add_Label(self, value): - self.Label.append(value) def insert_Label_at(self, index, value): self.Label.insert(index, value) def replace_Label_at(self, index, value): @@ -1340,7 +1679,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelsType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -1348,8 +1687,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'LabelsType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -1361,7 +1702,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='LabelsType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelsType'): if self.externalModel is not None and 'externalModel' not in already_processed: already_processed.add('externalModel') outfile.write(' externalModel=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalModel), input_name='externalModel')), )) @@ -1374,19 +1715,24 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Label_ in self.Label: + namespaceprefix_ = self.Label_nsprefix_ + ':' if (UseCapturedNS_ and self.Label_nsprefix_) else '' Label_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Label', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('externalModel', node) @@ -1405,28 +1751,45 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Label': obj_ = LabelType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Label.append(obj_) obj_.original_tagname_ = 'Label' + def __hash__(self): + return hash(self.id) # end class LabelsType class LabelType(GeneratedsSuper): - """Semantic label The label / tag (e.g. 'person'). Can be an RDF - resource identifier (e.g. object of an RDF triple). Additional - information on the label (e.g. 'YYYY-mm-dd' for a date label). + """Semantic label + The label / tag (e.g. 'person'). + Can be an RDF resource identifier + (e.g. object of an RDF triple). + Additional information on the label + (e.g. 'YYYY-mm-dd' for a date label). Can be used as predicate of an RDF triple.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('value', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('type_', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, value=None, type_=None, comments=None, **kwargs_): + def __init__(self, value=None, type_=None, comments=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.value = _cast(None, value) + self.value_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -1438,6 +1801,10 @@ def factory(*args_, **kwargs_): else: return LabelType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_value(self): return self.value def set_value(self, value): @@ -1457,7 +1824,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -1465,8 +1832,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'LabelType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -1477,7 +1846,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='LabelType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelType'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) @@ -1487,14 +1856,18 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('value', node) @@ -1509,133 +1882,229 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class LabelType class PageType(GeneratedsSuper): - """Contains the image file name including the file extension. Specifies - the width of the image.Specifies the height of the - image.Specifies the image resolution in width.Specifies the - image resolution in height. Specifies the unit of the resolution - information referring to a standardised unit of measurement - (pixels per inch, pixels per centimeter or other). For generic - use The angle the rectangle encapsulating the page (or its - Border) has to be rotated in clockwise direction in order to - correct the present skew (negative values indicate anti- - clockwise rotation). (The rotated image can be further - referenced via “AlternativeImage”.) Range: -179.999,180 The type - of the page within the document (e.g. cover page). The primary - language used in the page (lower-level definitions override the - page-level definition). The secondary language used in the page + """Contains the image file name including the file extension. + Specifies the width of the image.Specifies the height of the + image.Specifies the image resolution in width.Specifies the image + resolution in height. + Specifies the unit of the resolution information + referring to a standardised unit of measurement + (pixels per inch, pixels per centimeter or other). + For generic use + The angle the rectangle encapsulating the page + (or its Border) has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + (The rotated image can be further referenced + via “AlternativeImage”.) + Range: -179.999,180 + The type of the page within the document + (e.g. cover page). + The primary language used in the page + (lower-level definitions override the page-level definition). + The secondary language used in the page + (lower-level definitions override the page-level definition). + The primary script used in the page + (lower-level definitions override the page-level definition). + The secondary script used in the page + (lower-level definitions override the page-level definition). + The direction in which text within lines + should be read (order of words and characters), + in addition to “textLineOrder” + (lower-level definitions override the page-level definition). + The order of text lines within a block, + in addition to “readingDirection” (lower-level definitions override the page-level definition). - The primary script used in the page (lower-level definitions - override the page-level definition). The secondary script used - in the page (lower-level definitions override the page-level - definition). The direction in which text within lines should be - read (order of words and characters), in addition to - “textLineOrder” (lower-level definitions override the page-level - definition). The order of text lines within a block, in addition - to “readingDirection” (lower-level definitions override the - page-level definition). Confidence value for whole page (between - 0 and 1)""" + Confidence value for whole page (between 0 and 1)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('imageFilename', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('imageWidth', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('imageHeight', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('imageXResolution', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('imageYResolution', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('imageResolutionUnit', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:PageTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None), + MemberSpec_('Border', 'BorderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Border', 'type': 'BorderType'}, None), + MemberSpec_('PrintSpace', 'PrintSpaceType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'PrintSpace', 'type': 'PrintSpaceType'}, None), + MemberSpec_('ReadingOrder', 'ReadingOrderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'ReadingOrder', 'type': 'ReadingOrderType'}, None), + MemberSpec_('Layers', 'LayersType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Layers', 'type': 'LayersType'}, None), + MemberSpec_('Relations', 'RelationsType', 0, 1, {'minOccurs': '0', 'name': 'Relations', 'type': 'RelationsType'}, None), + MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 1), + MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 1), + MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 1), + MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 1), + MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 1), + MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 1), + MemberSpec_('MapRegion', 'MapRegionType', 1, 1, {'name': 'MapRegion', 'type': 'MapRegionType'}, 1), + MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 1), + MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 1), + MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 1), + MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 1), + MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 1), + MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 1), + MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 1), + MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 1), + ] subclass = None superclass = None - def __init__(self, imageFilename=None, imageWidth=None, imageHeight=None, imageXResolution=None, imageYResolution=None, imageResolutionUnit=None, custom=None, orientation=None, type_=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, textLineOrder=None, conf=None, AlternativeImage=None, Border=None, PrintSpace=None, ReadingOrder=None, Layers=None, Relations=None, TextStyle=None, UserDefined=None, Labels=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, MapRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, **kwargs_): + def __init__(self, imageFilename=None, imageWidth=None, imageHeight=None, imageXResolution=None, imageYResolution=None, imageResolutionUnit=None, custom=None, orientation=None, type_=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, textLineOrder=None, conf=None, AlternativeImage=None, Border=None, PrintSpace=None, ReadingOrder=None, Layers=None, Relations=None, TextStyle=None, UserDefined=None, Labels=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, MapRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.imageFilename = _cast(None, imageFilename) + self.imageFilename_nsprefix_ = None self.imageWidth = _cast(int, imageWidth) + self.imageWidth_nsprefix_ = None self.imageHeight = _cast(int, imageHeight) + self.imageHeight_nsprefix_ = None self.imageXResolution = _cast(float, imageXResolution) + self.imageXResolution_nsprefix_ = None self.imageYResolution = _cast(float, imageYResolution) + self.imageYResolution_nsprefix_ = None self.imageResolutionUnit = _cast(None, imageResolutionUnit) + self.imageResolutionUnit_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.primaryLanguage = _cast(None, primaryLanguage) + self.primaryLanguage_nsprefix_ = None self.secondaryLanguage = _cast(None, secondaryLanguage) + self.secondaryLanguage_nsprefix_ = None self.primaryScript = _cast(None, primaryScript) + self.primaryScript_nsprefix_ = None self.secondaryScript = _cast(None, secondaryScript) + self.secondaryScript_nsprefix_ = None self.readingDirection = _cast(None, readingDirection) + self.readingDirection_nsprefix_ = None self.textLineOrder = _cast(None, textLineOrder) + self.textLineOrder_nsprefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None if AlternativeImage is None: self.AlternativeImage = [] else: self.AlternativeImage = AlternativeImage + self.AlternativeImage_nsprefix_ = None self.Border = Border + self.Border_nsprefix_ = None self.PrintSpace = PrintSpace + self.PrintSpace_nsprefix_ = None self.ReadingOrder = ReadingOrder + self.ReadingOrder_nsprefix_ = None self.Layers = Layers + self.Layers_nsprefix_ = None self.Relations = Relations + self.Relations_nsprefix_ = None self.TextStyle = TextStyle + self.TextStyle_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None if TextRegion is None: self.TextRegion = [] else: self.TextRegion = TextRegion + self.TextRegion_nsprefix_ = None if ImageRegion is None: self.ImageRegion = [] else: self.ImageRegion = ImageRegion + self.ImageRegion_nsprefix_ = None if LineDrawingRegion is None: self.LineDrawingRegion = [] else: self.LineDrawingRegion = LineDrawingRegion + self.LineDrawingRegion_nsprefix_ = None if GraphicRegion is None: self.GraphicRegion = [] else: self.GraphicRegion = GraphicRegion + self.GraphicRegion_nsprefix_ = None if TableRegion is None: self.TableRegion = [] else: self.TableRegion = TableRegion + self.TableRegion_nsprefix_ = None if ChartRegion is None: self.ChartRegion = [] else: self.ChartRegion = ChartRegion + self.ChartRegion_nsprefix_ = None if MapRegion is None: self.MapRegion = [] else: self.MapRegion = MapRegion + self.MapRegion_nsprefix_ = None if SeparatorRegion is None: self.SeparatorRegion = [] else: self.SeparatorRegion = SeparatorRegion + self.SeparatorRegion_nsprefix_ = None if MathsRegion is None: self.MathsRegion = [] else: self.MathsRegion = MathsRegion + self.MathsRegion_nsprefix_ = None if ChemRegion is None: self.ChemRegion = [] else: self.ChemRegion = ChemRegion + self.ChemRegion_nsprefix_ = None if MusicRegion is None: self.MusicRegion = [] else: self.MusicRegion = MusicRegion + self.MusicRegion_nsprefix_ = None if AdvertRegion is None: self.AdvertRegion = [] else: self.AdvertRegion = AdvertRegion + self.AdvertRegion_nsprefix_ = None if NoiseRegion is None: self.NoiseRegion = [] else: self.NoiseRegion = NoiseRegion + self.NoiseRegion_nsprefix_ = None if UnknownRegion is None: self.UnknownRegion = [] else: self.UnknownRegion = UnknownRegion + self.UnknownRegion_nsprefix_ = None if CustomRegion is None: self.CustomRegion = [] else: self.CustomRegion = CustomRegion + self.CustomRegion_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -1647,14 +2116,16 @@ def factory(*args_, **kwargs_): else: return PageType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_AlternativeImage(self): return self.AlternativeImage def set_AlternativeImage(self, AlternativeImage): self.AlternativeImage = AlternativeImage def add_AlternativeImage(self, value): self.AlternativeImage.append(value) - def add_AlternativeImage(self, value): - self.AlternativeImage.append(value) def insert_AlternativeImage_at(self, index, value): self.AlternativeImage.insert(index, value) def replace_AlternativeImage_at(self, index, value): @@ -1693,8 +2164,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -1705,8 +2174,6 @@ def set_TextRegion(self, TextRegion): self.TextRegion = TextRegion def add_TextRegion(self, value): self.TextRegion.append(value) - def add_TextRegion(self, value): - self.TextRegion.append(value) def insert_TextRegion_at(self, index, value): self.TextRegion.insert(index, value) def replace_TextRegion_at(self, index, value): @@ -1717,8 +2184,6 @@ def set_ImageRegion(self, ImageRegion): self.ImageRegion = ImageRegion def add_ImageRegion(self, value): self.ImageRegion.append(value) - def add_ImageRegion(self, value): - self.ImageRegion.append(value) def insert_ImageRegion_at(self, index, value): self.ImageRegion.insert(index, value) def replace_ImageRegion_at(self, index, value): @@ -1729,8 +2194,6 @@ def set_LineDrawingRegion(self, LineDrawingRegion): self.LineDrawingRegion = LineDrawingRegion def add_LineDrawingRegion(self, value): self.LineDrawingRegion.append(value) - def add_LineDrawingRegion(self, value): - self.LineDrawingRegion.append(value) def insert_LineDrawingRegion_at(self, index, value): self.LineDrawingRegion.insert(index, value) def replace_LineDrawingRegion_at(self, index, value): @@ -1741,8 +2204,6 @@ def set_GraphicRegion(self, GraphicRegion): self.GraphicRegion = GraphicRegion def add_GraphicRegion(self, value): self.GraphicRegion.append(value) - def add_GraphicRegion(self, value): - self.GraphicRegion.append(value) def insert_GraphicRegion_at(self, index, value): self.GraphicRegion.insert(index, value) def replace_GraphicRegion_at(self, index, value): @@ -1753,8 +2214,6 @@ def set_TableRegion(self, TableRegion): self.TableRegion = TableRegion def add_TableRegion(self, value): self.TableRegion.append(value) - def add_TableRegion(self, value): - self.TableRegion.append(value) def insert_TableRegion_at(self, index, value): self.TableRegion.insert(index, value) def replace_TableRegion_at(self, index, value): @@ -1765,8 +2224,6 @@ def set_ChartRegion(self, ChartRegion): self.ChartRegion = ChartRegion def add_ChartRegion(self, value): self.ChartRegion.append(value) - def add_ChartRegion(self, value): - self.ChartRegion.append(value) def insert_ChartRegion_at(self, index, value): self.ChartRegion.insert(index, value) def replace_ChartRegion_at(self, index, value): @@ -1777,8 +2234,6 @@ def set_MapRegion(self, MapRegion): self.MapRegion = MapRegion def add_MapRegion(self, value): self.MapRegion.append(value) - def add_MapRegion(self, value): - self.MapRegion.append(value) def insert_MapRegion_at(self, index, value): self.MapRegion.insert(index, value) def replace_MapRegion_at(self, index, value): @@ -1789,8 +2244,6 @@ def set_SeparatorRegion(self, SeparatorRegion): self.SeparatorRegion = SeparatorRegion def add_SeparatorRegion(self, value): self.SeparatorRegion.append(value) - def add_SeparatorRegion(self, value): - self.SeparatorRegion.append(value) def insert_SeparatorRegion_at(self, index, value): self.SeparatorRegion.insert(index, value) def replace_SeparatorRegion_at(self, index, value): @@ -1801,8 +2254,6 @@ def set_MathsRegion(self, MathsRegion): self.MathsRegion = MathsRegion def add_MathsRegion(self, value): self.MathsRegion.append(value) - def add_MathsRegion(self, value): - self.MathsRegion.append(value) def insert_MathsRegion_at(self, index, value): self.MathsRegion.insert(index, value) def replace_MathsRegion_at(self, index, value): @@ -1813,8 +2264,6 @@ def set_ChemRegion(self, ChemRegion): self.ChemRegion = ChemRegion def add_ChemRegion(self, value): self.ChemRegion.append(value) - def add_ChemRegion(self, value): - self.ChemRegion.append(value) def insert_ChemRegion_at(self, index, value): self.ChemRegion.insert(index, value) def replace_ChemRegion_at(self, index, value): @@ -1825,8 +2274,6 @@ def set_MusicRegion(self, MusicRegion): self.MusicRegion = MusicRegion def add_MusicRegion(self, value): self.MusicRegion.append(value) - def add_MusicRegion(self, value): - self.MusicRegion.append(value) def insert_MusicRegion_at(self, index, value): self.MusicRegion.insert(index, value) def replace_MusicRegion_at(self, index, value): @@ -1837,8 +2284,6 @@ def set_AdvertRegion(self, AdvertRegion): self.AdvertRegion = AdvertRegion def add_AdvertRegion(self, value): self.AdvertRegion.append(value) - def add_AdvertRegion(self, value): - self.AdvertRegion.append(value) def insert_AdvertRegion_at(self, index, value): self.AdvertRegion.insert(index, value) def replace_AdvertRegion_at(self, index, value): @@ -1849,8 +2294,6 @@ def set_NoiseRegion(self, NoiseRegion): self.NoiseRegion = NoiseRegion def add_NoiseRegion(self, value): self.NoiseRegion.append(value) - def add_NoiseRegion(self, value): - self.NoiseRegion.append(value) def insert_NoiseRegion_at(self, index, value): self.NoiseRegion.insert(index, value) def replace_NoiseRegion_at(self, index, value): @@ -1861,8 +2304,6 @@ def set_UnknownRegion(self, UnknownRegion): self.UnknownRegion = UnknownRegion def add_UnknownRegion(self, value): self.UnknownRegion.append(value) - def add_UnknownRegion(self, value): - self.UnknownRegion.append(value) def insert_UnknownRegion_at(self, index, value): self.UnknownRegion.insert(index, value) def replace_UnknownRegion_at(self, index, value): @@ -1873,8 +2314,6 @@ def set_CustomRegion(self, CustomRegion): self.CustomRegion = CustomRegion def add_CustomRegion(self, value): self.CustomRegion.append(value) - def add_CustomRegion(self, value): - self.CustomRegion.append(value) def insert_CustomRegion_at(self, index, value): self.CustomRegion.insert(index, value) def replace_CustomRegion_at(self, index, value): @@ -1943,6 +2382,86 @@ def get_conf(self): return self.conf def set_conf(self, conf): self.conf = conf + def validate_PageTypeSimpleType(self, value): + # Validate type pc:PageTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['front-cover', 'back-cover', 'title', 'table-of-contents', 'index', 'content', 'blank', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on PageTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_LanguageSimpleType(self, value): + # Validate type pc:LanguageSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ScriptSimpleType(self, value): + # Validate type pc:ScriptSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ReadingDirectionSimpleType(self, value): + # Validate type pc:ReadingDirectionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_TextLineOrderSimpleType(self, value): + # Validate type pc:TextLineOrderSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False def hasContent_(self): if ( self.AlternativeImage or @@ -1973,7 +2492,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('PageType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -1981,8 +2500,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'PageType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -1994,7 +2515,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='PageType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PageType'): if self.imageFilename is not None and 'imageFilename' not in already_processed: already_processed.add('imageFilename') outfile.write(' imageFilename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.imageFilename), input_name='imageFilename')), )) @@ -2021,87 +2542,115 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') - outfile.write(' primaryLanguage=%s' % (quote_attrib(self.primaryLanguage), )) + outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), )) if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed: already_processed.add('secondaryLanguage') - outfile.write(' secondaryLanguage=%s' % (quote_attrib(self.secondaryLanguage), )) + outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), )) if self.primaryScript is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') - outfile.write(' primaryScript=%s' % (quote_attrib(self.primaryScript), )) + outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), )) if self.secondaryScript is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') - outfile.write(' secondaryScript=%s' % (quote_attrib(self.secondaryScript), )) + outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), )) if self.readingDirection is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') - outfile.write(' readingDirection=%s' % (quote_attrib(self.readingDirection), )) + outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), )) if self.textLineOrder is not None and 'textLineOrder' not in already_processed: already_processed.add('textLineOrder') - outfile.write(' textLineOrder=%s' % (quote_attrib(self.textLineOrder), )) + outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), )) if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', fromsubclass_=False, pretty_print=True): + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for AlternativeImage_ in self.AlternativeImage: + namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else '' AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print) if self.Border is not None: + namespaceprefix_ = self.Border_nsprefix_ + ':' if (UseCapturedNS_ and self.Border_nsprefix_) else '' self.Border.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Border', pretty_print=pretty_print) if self.PrintSpace is not None: + namespaceprefix_ = self.PrintSpace_nsprefix_ + ':' if (UseCapturedNS_ and self.PrintSpace_nsprefix_) else '' self.PrintSpace.export(outfile, level, namespaceprefix_, namespacedef_='', name_='PrintSpace', pretty_print=pretty_print) if self.ReadingOrder is not None: + namespaceprefix_ = self.ReadingOrder_nsprefix_ + ':' if (UseCapturedNS_ and self.ReadingOrder_nsprefix_) else '' self.ReadingOrder.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ReadingOrder', pretty_print=pretty_print) if self.Layers is not None: + namespaceprefix_ = self.Layers_nsprefix_ + ':' if (UseCapturedNS_ and self.Layers_nsprefix_) else '' self.Layers.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layers', pretty_print=pretty_print) if self.Relations is not None: + namespaceprefix_ = self.Relations_nsprefix_ + ':' if (UseCapturedNS_ and self.Relations_nsprefix_) else '' self.Relations.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relations', pretty_print=pretty_print) if self.TextStyle is not None: + namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else '' self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) for TextRegion_ in self.TextRegion: + namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else '' TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print) for ImageRegion_ in self.ImageRegion: + namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else '' ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print) for LineDrawingRegion_ in self.LineDrawingRegion: + namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else '' LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print) for GraphicRegion_ in self.GraphicRegion: + namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else '' GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print) for TableRegion_ in self.TableRegion: + namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else '' TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print) for ChartRegion_ in self.ChartRegion: + namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else '' ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print) for MapRegion_ in self.MapRegion: + namespaceprefix_ = self.MapRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MapRegion_nsprefix_) else '' MapRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MapRegion', pretty_print=pretty_print) for SeparatorRegion_ in self.SeparatorRegion: + namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else '' SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print) for MathsRegion_ in self.MathsRegion: + namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else '' MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print) for ChemRegion_ in self.ChemRegion: + namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else '' ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print) for MusicRegion_ in self.MusicRegion: + namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else '' MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print) for AdvertRegion_ in self.AdvertRegion: + namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else '' AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print) for NoiseRegion_ in self.NoiseRegion: + namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else '' NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print) for UnknownRegion_ in self.UnknownRegion: + namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else '' UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print) for CustomRegion_ in self.CustomRegion: + namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else '' CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('imageFilename', node) @@ -2111,31 +2660,21 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('imageWidth', node) if value is not None and 'imageWidth' not in already_processed: already_processed.add('imageWidth') - try: - self.imageWidth = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.imageWidth = self.gds_parse_integer(value, node, 'imageWidth') value = find_attr_value_('imageHeight', node) if value is not None and 'imageHeight' not in already_processed: already_processed.add('imageHeight') - try: - self.imageHeight = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.imageHeight = self.gds_parse_integer(value, node, 'imageHeight') value = find_attr_value_('imageXResolution', node) if value is not None and 'imageXResolution' not in already_processed: already_processed.add('imageXResolution') - try: - self.imageXResolution = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (imageXResolution): %s' % exp) + value = self.gds_parse_float(value, node, 'imageXResolution') + self.imageXResolution = value value = find_attr_value_('imageYResolution', node) if value is not None and 'imageYResolution' not in already_processed: already_processed.add('imageYResolution') - try: - self.imageYResolution = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (imageYResolution): %s' % exp) + value = self.gds_parse_float(value, node, 'imageYResolution') + self.imageYResolution = value value = find_attr_value_('imageResolutionUnit', node) if value is not None and 'imageResolutionUnit' not in already_processed: already_processed.add('imageResolutionUnit') @@ -2147,181 +2686,201 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('type', node) if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_PageTypeSimpleType(self.type_) # validate type PageTypeSimpleType value = find_attr_value_('primaryLanguage', node) if value is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') self.primaryLanguage = value + self.validate_LanguageSimpleType(self.primaryLanguage) # validate type LanguageSimpleType value = find_attr_value_('secondaryLanguage', node) if value is not None and 'secondaryLanguage' not in already_processed: already_processed.add('secondaryLanguage') self.secondaryLanguage = value + self.validate_LanguageSimpleType(self.secondaryLanguage) # validate type LanguageSimpleType value = find_attr_value_('primaryScript', node) if value is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') self.primaryScript = value + self.validate_ScriptSimpleType(self.primaryScript) # validate type ScriptSimpleType value = find_attr_value_('secondaryScript', node) if value is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') self.secondaryScript = value + self.validate_ScriptSimpleType(self.secondaryScript) # validate type ScriptSimpleType value = find_attr_value_('readingDirection', node) if value is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') self.readingDirection = value + self.validate_ReadingDirectionSimpleType(self.readingDirection) # validate type ReadingDirectionSimpleType value = find_attr_value_('textLineOrder', node) if value is not None and 'textLineOrder' not in already_processed: already_processed.add('textLineOrder') self.textLineOrder = value + self.validate_TextLineOrderSimpleType(self.textLineOrder) # validate type TextLineOrderSimpleType value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'AlternativeImage': obj_ = AlternativeImageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AlternativeImage.append(obj_) obj_.original_tagname_ = 'AlternativeImage' elif nodeName_ == 'Border': obj_ = BorderType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Border = obj_ obj_.original_tagname_ = 'Border' elif nodeName_ == 'PrintSpace': obj_ = PrintSpaceType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.PrintSpace = obj_ obj_.original_tagname_ = 'PrintSpace' elif nodeName_ == 'ReadingOrder': obj_ = ReadingOrderType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ReadingOrder = obj_ obj_.original_tagname_ = 'ReadingOrder' elif nodeName_ == 'Layers': obj_ = LayersType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Layers = obj_ obj_.original_tagname_ = 'Layers' elif nodeName_ == 'Relations': obj_ = RelationsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Relations = obj_ obj_.original_tagname_ = 'Relations' elif nodeName_ == 'TextStyle': obj_ = TextStyleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextStyle = obj_ obj_.original_tagname_ = 'TextStyle' elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'TextRegion': obj_ = TextRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextRegion.append(obj_) obj_.original_tagname_ = 'TextRegion' elif nodeName_ == 'ImageRegion': obj_ = ImageRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ImageRegion.append(obj_) obj_.original_tagname_ = 'ImageRegion' elif nodeName_ == 'LineDrawingRegion': obj_ = LineDrawingRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.LineDrawingRegion.append(obj_) obj_.original_tagname_ = 'LineDrawingRegion' elif nodeName_ == 'GraphicRegion': obj_ = GraphicRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.GraphicRegion.append(obj_) obj_.original_tagname_ = 'GraphicRegion' elif nodeName_ == 'TableRegion': obj_ = TableRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TableRegion.append(obj_) obj_.original_tagname_ = 'TableRegion' elif nodeName_ == 'ChartRegion': obj_ = ChartRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ChartRegion.append(obj_) obj_.original_tagname_ = 'ChartRegion' elif nodeName_ == 'MapRegion': obj_ = MapRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MapRegion.append(obj_) obj_.original_tagname_ = 'MapRegion' elif nodeName_ == 'SeparatorRegion': obj_ = SeparatorRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.SeparatorRegion.append(obj_) obj_.original_tagname_ = 'SeparatorRegion' elif nodeName_ == 'MathsRegion': obj_ = MathsRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MathsRegion.append(obj_) obj_.original_tagname_ = 'MathsRegion' elif nodeName_ == 'ChemRegion': obj_ = ChemRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ChemRegion.append(obj_) obj_.original_tagname_ = 'ChemRegion' elif nodeName_ == 'MusicRegion': obj_ = MusicRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MusicRegion.append(obj_) obj_.original_tagname_ = 'MusicRegion' elif nodeName_ == 'AdvertRegion': obj_ = AdvertRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AdvertRegion.append(obj_) obj_.original_tagname_ = 'AdvertRegion' elif nodeName_ == 'NoiseRegion': obj_ = NoiseRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.NoiseRegion.append(obj_) obj_.original_tagname_ = 'NoiseRegion' elif nodeName_ == 'UnknownRegion': obj_ = UnknownRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnknownRegion.append(obj_) obj_.original_tagname_ = 'UnknownRegion' elif nodeName_ == 'CustomRegion': obj_ = CustomRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.CustomRegion.append(obj_) obj_.original_tagname_ = 'CustomRegion' + def __hash__(self): + return hash(self.id) # end class PageType class CoordsType(GeneratedsSuper): - """Polygon outline of the element as a path of points. No points may - lie outside the outline of its parent, which in the case of - Border is the bounding rectangle of the root image. Paths are - closed by convention, i.e. the last point logically connects - with the first (and at least 3 points are required to span an - area). Paths must be planar (i.e. must not self-intersect). + """Polygon outline of the element as a path of points. + No points may lie outside the outline of its parent, + which in the case of Border is the bounding rectangle + of the root image. Paths are closed by convention, + i.e. the last point logically connects with the first + (and at least 3 points are required to span an area). + Paths must be planar (i.e. must not self-intersect). Confidence value (between 0 and 1)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required'}), + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, points=None, conf=None, **kwargs_): + def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.points = _cast(None, points) + self.points_nsprefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -2333,6 +2892,10 @@ def factory(*args_, **kwargs_): else: return CoordsType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_points(self): return self.points def set_points(self, points): @@ -2341,6 +2904,32 @@ def get_conf(self): return self.conf def set_conf(self, conf): self.conf = conf + def validate_PointsType(self, value): + # Validate type pc:PointsType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + if not self.gds_validate_simple_patterns( + self.validate_PointsType_patterns_, value): + self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, )) + validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']] + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False def hasContent_(self): if ( @@ -2348,7 +2937,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('CoordsType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -2356,8 +2945,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'CoordsType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -2368,78 +2959,131 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='CoordsType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CoordsType'): if self.points is not None and 'points' not in already_processed: already_processed.add('points') - outfile.write(' points=%s' % (quote_attrib(self.points), )) + outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), )) if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', fromsubclass_=False, pretty_print=True): + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('points', node) if value is not None and 'points' not in already_processed: already_processed.add('points') self.points = value + self.validate_PointsType(self.points) # validate type PointsType value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class CoordsType class TextLineType(GeneratedsSuper): - """Overrides primaryLanguage attribute of parent text region The - primary script used in the text line The secondary script used - in the text line The direction in which text within the line - should be read (order of words and characters). Overrides the - production attribute of the parent text region For generic use - Position (order number) of this text line within the parent text - region.""" + """Overrides primaryLanguage attribute of parent text + region + The primary script used in the text line + The secondary script used in the text line + The direction in which text within the line + should be read (order of words and characters). + Overrides the production attribute of the parent + text region + For generic use + Position (order number) of this text line within the + parent text region.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('index', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None), + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + MemberSpec_('Baseline', 'BaselineType', 0, 1, {'minOccurs': '0', 'name': 'Baseline', 'type': 'BaselineType'}, None), + MemberSpec_('Word', 'WordType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Word', 'type': 'WordType'}, None), + MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None), + MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, primaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, index=None, AlternativeImage=None, Coords=None, Baseline=None, Word=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, **kwargs_): + def __init__(self, id=None, primaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, index=None, AlternativeImage=None, Coords=None, Baseline=None, Word=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.primaryLanguage = _cast(None, primaryLanguage) + self.primaryLanguage_nsprefix_ = None self.primaryScript = _cast(None, primaryScript) + self.primaryScript_nsprefix_ = None self.secondaryScript = _cast(None, secondaryScript) + self.secondaryScript_nsprefix_ = None self.readingDirection = _cast(None, readingDirection) + self.readingDirection_nsprefix_ = None self.production = _cast(None, production) + self.production_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None if AlternativeImage is None: self.AlternativeImage = [] else: self.AlternativeImage = AlternativeImage + self.AlternativeImage_nsprefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None self.Baseline = Baseline + self.Baseline_nsprefix_ = None if Word is None: self.Word = [] else: self.Word = Word + self.Word_nsprefix_ = None if TextEquiv is None: self.TextEquiv = [] else: self.TextEquiv = TextEquiv + self.TextEquiv_nsprefix_ = None self.TextStyle = TextStyle + self.TextStyle_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -2451,14 +3095,16 @@ def factory(*args_, **kwargs_): else: return TextLineType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_AlternativeImage(self): return self.AlternativeImage def set_AlternativeImage(self, AlternativeImage): self.AlternativeImage = AlternativeImage def add_AlternativeImage(self, value): self.AlternativeImage.append(value) - def add_AlternativeImage(self, value): - self.AlternativeImage.append(value) def insert_AlternativeImage_at(self, index, value): self.AlternativeImage.insert(index, value) def replace_AlternativeImage_at(self, index, value): @@ -2477,8 +3123,6 @@ def set_Word(self, Word): self.Word = Word def add_Word(self, value): self.Word.append(value) - def add_Word(self, value): - self.Word.append(value) def insert_Word_at(self, index, value): self.Word.insert(index, value) def replace_Word_at(self, index, value): @@ -2489,8 +3133,6 @@ def set_TextEquiv(self, TextEquiv): self.TextEquiv = TextEquiv def add_TextEquiv(self, value): self.TextEquiv.append(value) - def add_TextEquiv(self, value): - self.TextEquiv.append(value) def insert_TextEquiv_at(self, index, value): self.TextEquiv.insert(index, value) def replace_TextEquiv_at(self, index, value): @@ -2509,8 +3151,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -2551,6 +3191,58 @@ def get_index(self): return self.index def set_index(self, index): self.index = index + def validate_LanguageSimpleType(self, value): + # Validate type pc:LanguageSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ScriptSimpleType(self, value): + # Validate type pc:ScriptSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ReadingDirectionSimpleType(self, value): + # Validate type pc:ReadingDirectionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ProductionSimpleType(self, value): + # Validate type pc:ProductionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.AlternativeImage or @@ -2565,7 +3257,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextLineType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -2573,8 +3265,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TextLineType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -2586,25 +3280,25 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TextLineType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextLineType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') - outfile.write(' primaryLanguage=%s' % (quote_attrib(self.primaryLanguage), )) + outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), )) if self.primaryScript is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') - outfile.write(' primaryScript=%s' % (quote_attrib(self.primaryScript), )) + outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), )) if self.secondaryScript is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') - outfile.write(' secondaryScript=%s' % (quote_attrib(self.secondaryScript), )) + outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), )) if self.readingDirection is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') - outfile.write(' readingDirection=%s' % (quote_attrib(self.readingDirection), )) + outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), )) if self.production is not None and 'production' not in already_processed: already_processed.add('production') - outfile.write(' production=%s' % (quote_attrib(self.production), )) + outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), )) if self.custom is not None and 'custom' not in already_processed: already_processed.add('custom') outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), )) @@ -2614,33 +3308,45 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.index is not None and 'index' not in already_processed: already_processed.add('index') outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for AlternativeImage_ in self.AlternativeImage: + namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else '' AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print) if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) if self.Baseline is not None: + namespaceprefix_ = self.Baseline_nsprefix_ + ':' if (UseCapturedNS_ and self.Baseline_nsprefix_) else '' self.Baseline.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Baseline', pretty_print=pretty_print) for Word_ in self.Word: + namespaceprefix_ = self.Word_nsprefix_ + ':' if (UseCapturedNS_ and self.Word_nsprefix_) else '' Word_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Word', pretty_print=pretty_print) for TextEquiv_ in self.TextEquiv: + namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else '' TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print) if self.TextStyle is not None: + namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else '' self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -2651,22 +3357,27 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') self.primaryLanguage = value + self.validate_LanguageSimpleType(self.primaryLanguage) # validate type LanguageSimpleType value = find_attr_value_('primaryScript', node) if value is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') self.primaryScript = value + self.validate_ScriptSimpleType(self.primaryScript) # validate type ScriptSimpleType value = find_attr_value_('secondaryScript', node) if value is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') self.secondaryScript = value + self.validate_ScriptSimpleType(self.secondaryScript) # validate type ScriptSimpleType value = find_attr_value_('readingDirection', node) if value is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') self.readingDirection = value + self.validate_ReadingDirectionSimpleType(self.readingDirection) # validate type ReadingDirectionSimpleType value = find_attr_value_('production', node) if value is not None and 'production' not in already_processed: already_processed.add('production') self.production = value + self.validate_ProductionSimpleType(self.production) # validate type ProductionSimpleType value = find_attr_value_('custom', node) if value is not None and 'custom' not in already_processed: already_processed.add('custom') @@ -2678,93 +3389,131 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.index = self.gds_parse_integer(value, node, 'index') + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'AlternativeImage': obj_ = AlternativeImageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AlternativeImage.append(obj_) obj_.original_tagname_ = 'AlternativeImage' elif nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' elif nodeName_ == 'Baseline': obj_ = BaselineType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Baseline = obj_ obj_.original_tagname_ = 'Baseline' elif nodeName_ == 'Word': obj_ = WordType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Word.append(obj_) obj_.original_tagname_ = 'Word' elif nodeName_ == 'TextEquiv': obj_ = TextEquivType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextEquiv.append(obj_) obj_.original_tagname_ = 'TextEquiv' elif nodeName_ == 'TextStyle': obj_ = TextStyleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextStyle = obj_ obj_.original_tagname_ = 'TextStyle' elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' + def __hash__(self): + return hash(self.id) # end class TextLineType class WordType(GeneratedsSuper): - """Overrides primaryLanguage attribute of parent line and/or text - region The primary script used in the word The secondary script - used in the word The direction in which text within the word - should be read (order of characters). Overrides the production - attribute of the parent text line and/or text region. For - generic use""" + """Overrides primaryLanguage attribute of parent line + and/or text region + The primary script used in the word + The secondary script used in the word + The direction in which text within the word + should be read (order of characters). + Overrides the production attribute of the parent + text line and/or text region. + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('language', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None), + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + MemberSpec_('Glyph', 'GlyphType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Glyph', 'type': 'GlyphType'}, None), + MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None), + MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, language=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Glyph=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, **kwargs_): + def __init__(self, id=None, language=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Glyph=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.language = _cast(None, language) + self.language_nsprefix_ = None self.primaryScript = _cast(None, primaryScript) + self.primaryScript_nsprefix_ = None self.secondaryScript = _cast(None, secondaryScript) + self.secondaryScript_nsprefix_ = None self.readingDirection = _cast(None, readingDirection) + self.readingDirection_nsprefix_ = None self.production = _cast(None, production) + self.production_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None if AlternativeImage is None: self.AlternativeImage = [] else: self.AlternativeImage = AlternativeImage + self.AlternativeImage_nsprefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None if Glyph is None: self.Glyph = [] else: self.Glyph = Glyph + self.Glyph_nsprefix_ = None if TextEquiv is None: self.TextEquiv = [] else: self.TextEquiv = TextEquiv + self.TextEquiv_nsprefix_ = None self.TextStyle = TextStyle + self.TextStyle_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -2776,14 +3525,16 @@ def factory(*args_, **kwargs_): else: return WordType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_AlternativeImage(self): return self.AlternativeImage def set_AlternativeImage(self, AlternativeImage): self.AlternativeImage = AlternativeImage def add_AlternativeImage(self, value): self.AlternativeImage.append(value) - def add_AlternativeImage(self, value): - self.AlternativeImage.append(value) def insert_AlternativeImage_at(self, index, value): self.AlternativeImage.insert(index, value) def replace_AlternativeImage_at(self, index, value): @@ -2798,8 +3549,6 @@ def set_Glyph(self, Glyph): self.Glyph = Glyph def add_Glyph(self, value): self.Glyph.append(value) - def add_Glyph(self, value): - self.Glyph.append(value) def insert_Glyph_at(self, index, value): self.Glyph.insert(index, value) def replace_Glyph_at(self, index, value): @@ -2810,8 +3559,6 @@ def set_TextEquiv(self, TextEquiv): self.TextEquiv = TextEquiv def add_TextEquiv(self, value): self.TextEquiv.append(value) - def add_TextEquiv(self, value): - self.TextEquiv.append(value) def insert_TextEquiv_at(self, index, value): self.TextEquiv.insert(index, value) def replace_TextEquiv_at(self, index, value): @@ -2830,8 +3577,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -2868,6 +3613,58 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_LanguageSimpleType(self, value): + # Validate type pc:LanguageSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ScriptSimpleType(self, value): + # Validate type pc:ScriptSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ReadingDirectionSimpleType(self, value): + # Validate type pc:ReadingDirectionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ProductionSimpleType(self, value): + # Validate type pc:ProductionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.AlternativeImage or @@ -2881,7 +3678,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('WordType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -2889,8 +3686,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'WordType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -2902,56 +3701,67 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='WordType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='WordType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (quote_attrib(self.language), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.primaryScript is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') - outfile.write(' primaryScript=%s' % (quote_attrib(self.primaryScript), )) + outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), )) if self.secondaryScript is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') - outfile.write(' secondaryScript=%s' % (quote_attrib(self.secondaryScript), )) + outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), )) if self.readingDirection is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') - outfile.write(' readingDirection=%s' % (quote_attrib(self.readingDirection), )) + outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), )) if self.production is not None and 'production' not in already_processed: already_processed.add('production') - outfile.write(' production=%s' % (quote_attrib(self.production), )) + outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), )) if self.custom is not None and 'custom' not in already_processed: already_processed.add('custom') outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), )) if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for AlternativeImage_ in self.AlternativeImage: + namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else '' AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print) if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) for Glyph_ in self.Glyph: + namespaceprefix_ = self.Glyph_nsprefix_ + ':' if (UseCapturedNS_ and self.Glyph_nsprefix_) else '' Glyph_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Glyph', pretty_print=pretty_print) for TextEquiv_ in self.TextEquiv: + namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else '' TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print) if self.TextStyle is not None: + namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else '' self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -2962,22 +3772,27 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'language' not in already_processed: already_processed.add('language') self.language = value + self.validate_LanguageSimpleType(self.language) # validate type LanguageSimpleType value = find_attr_value_('primaryScript', node) if value is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') self.primaryScript = value + self.validate_ScriptSimpleType(self.primaryScript) # validate type ScriptSimpleType value = find_attr_value_('secondaryScript', node) if value is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') self.secondaryScript = value + self.validate_ScriptSimpleType(self.secondaryScript) # validate type ScriptSimpleType value = find_attr_value_('readingDirection', node) if value is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') self.readingDirection = value + self.validate_ReadingDirectionSimpleType(self.readingDirection) # validate type ReadingDirectionSimpleType value = find_attr_value_('production', node) if value is not None and 'production' not in already_processed: already_processed.add('production') self.production = value + self.validate_ProductionSimpleType(self.production) # validate type ProductionSimpleType value = find_attr_value_('custom', node) if value is not None and 'custom' not in already_processed: already_processed.add('custom') @@ -2986,76 +3801,114 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'AlternativeImage': obj_ = AlternativeImageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AlternativeImage.append(obj_) obj_.original_tagname_ = 'AlternativeImage' elif nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' elif nodeName_ == 'Glyph': obj_ = GlyphType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Glyph.append(obj_) obj_.original_tagname_ = 'Glyph' elif nodeName_ == 'TextEquiv': obj_ = TextEquivType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextEquiv.append(obj_) obj_.original_tagname_ = 'TextEquiv' elif nodeName_ == 'TextStyle': obj_ = TextStyleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextStyle = obj_ obj_.original_tagname_ = 'TextStyle' elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' + def __hash__(self): + return hash(self.id) # end class WordType class GlyphType(GeneratedsSuper): - """The script used for the glyph Overrides the production attribute of - the parent word / text line / text region. For generic use""" + """The script used for the glyph + Overrides the production attribute of the parent + word / text line / text region. + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('symbol', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('script', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None), + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + MemberSpec_('Graphemes', 'GraphemesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Graphemes', 'type': 'GraphemesType'}, None), + MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None), + MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, ligature=None, symbol=None, script=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Graphemes=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, **kwargs_): + def __init__(self, id=None, ligature=None, symbol=None, script=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Graphemes=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.ligature = _cast(bool, ligature) + self.ligature_nsprefix_ = None self.symbol = _cast(bool, symbol) + self.symbol_nsprefix_ = None self.script = _cast(None, script) + self.script_nsprefix_ = None self.production = _cast(None, production) + self.production_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None if AlternativeImage is None: self.AlternativeImage = [] else: self.AlternativeImage = AlternativeImage + self.AlternativeImage_nsprefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None self.Graphemes = Graphemes + self.Graphemes_nsprefix_ = None if TextEquiv is None: self.TextEquiv = [] else: self.TextEquiv = TextEquiv + self.TextEquiv_nsprefix_ = None self.TextStyle = TextStyle + self.TextStyle_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3067,14 +3920,16 @@ def factory(*args_, **kwargs_): else: return GlyphType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_AlternativeImage(self): return self.AlternativeImage def set_AlternativeImage(self, AlternativeImage): self.AlternativeImage = AlternativeImage def add_AlternativeImage(self, value): self.AlternativeImage.append(value) - def add_AlternativeImage(self, value): - self.AlternativeImage.append(value) def insert_AlternativeImage_at(self, index, value): self.AlternativeImage.insert(index, value) def replace_AlternativeImage_at(self, index, value): @@ -3093,8 +3948,6 @@ def set_TextEquiv(self, TextEquiv): self.TextEquiv = TextEquiv def add_TextEquiv(self, value): self.TextEquiv.append(value) - def add_TextEquiv(self, value): - self.TextEquiv.append(value) def insert_TextEquiv_at(self, index, value): self.TextEquiv.insert(index, value) def replace_TextEquiv_at(self, index, value): @@ -3113,8 +3966,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -3147,6 +3998,32 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_ScriptSimpleType(self, value): + # Validate type pc:ScriptSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ProductionSimpleType(self, value): + # Validate type pc:ProductionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.AlternativeImage or @@ -3160,7 +4037,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GlyphType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3168,8 +4045,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GlyphType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3181,7 +4060,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GlyphType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GlyphType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -3193,41 +4072,52 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' symbol="%s"' % self.gds_format_boolean(self.symbol, input_name='symbol')) if self.script is not None and 'script' not in already_processed: already_processed.add('script') - outfile.write(' script=%s' % (quote_attrib(self.script), )) + outfile.write(' script=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.script), input_name='script')), )) if self.production is not None and 'production' not in already_processed: already_processed.add('production') - outfile.write(' production=%s' % (quote_attrib(self.production), )) + outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), )) if self.custom is not None and 'custom' not in already_processed: already_processed.add('custom') outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), )) if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for AlternativeImage_ in self.AlternativeImage: + namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else '' AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print) if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) if self.Graphemes is not None: + namespaceprefix_ = self.Graphemes_nsprefix_ + ':' if (UseCapturedNS_ and self.Graphemes_nsprefix_) else '' self.Graphemes.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Graphemes', pretty_print=pretty_print) for TextEquiv_ in self.TextEquiv: + namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else '' TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print) if self.TextStyle is not None: + namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else '' self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -3256,10 +4146,12 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'script' not in already_processed: already_processed.add('script') self.script = value + self.validate_ScriptSimpleType(self.script) # validate type ScriptSimpleType value = find_attr_value_('production', node) if value is not None and 'production' not in already_processed: already_processed.add('production') self.production = value + self.validate_ProductionSimpleType(self.production) # validate type ProductionSimpleType value = find_attr_value_('custom', node) if value is not None and 'custom' not in already_processed: already_processed.add('custom') @@ -3268,65 +4160,89 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'AlternativeImage': obj_ = AlternativeImageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AlternativeImage.append(obj_) obj_.original_tagname_ = 'AlternativeImage' elif nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' elif nodeName_ == 'Graphemes': obj_ = GraphemesType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Graphemes = obj_ obj_.original_tagname_ = 'Graphemes' elif nodeName_ == 'TextEquiv': obj_ = TextEquivType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextEquiv.append(obj_) obj_.original_tagname_ = 'TextEquiv' elif nodeName_ == 'TextStyle': obj_ = TextStyleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextStyle = obj_ obj_.original_tagname_ = 'TextStyle' elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' + def __hash__(self): + return hash(self.id) # end class GlyphType class TextEquivType(GeneratedsSuper): - """Used for sort order in case multiple TextEquivs are defined. The - text content with the lowest index should be interpreted as the - main text content. OCR confidence value (between 0 and 1) Type - of text content (is it free text or a number, for instance). - This is only a descriptive attribute, the text type is not - checked during XML validation. Refinement for dataType - attribute. Can be a regular expression, for instance.""" + """Used for sort order in case multiple TextEquivs are defined. + The text content with the lowest index should be interpreted + as the main text content. + OCR confidence value (between 0 and 1) + Type of text content (is it free text or a number, for instance). + This is only a descriptive attribute, the text type + is not checked during XML validation. + Refinement for dataType attribute. Can be a regular expression, for + instance.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('index', 'integer', 0, 1, {'use': 'optional'}), + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('dataType', 'pc:TextDataTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('dataTypeDetails', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('PlainText', 'string', 0, 1, {'minOccurs': '0', 'name': 'PlainText', 'type': 'string'}, None), + MemberSpec_('Unicode', 'string', 0, 0, {'name': 'Unicode', 'type': 'string'}, None), + ] subclass = None superclass = None - def __init__(self, index=None, conf=None, dataType=None, dataTypeDetails=None, comments=None, PlainText=None, Unicode=None, **kwargs_): + def __init__(self, index=None, conf=None, dataType=None, dataTypeDetails=None, comments=None, PlainText=None, Unicode=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None self.dataType = _cast(None, dataType) + self.dataType_nsprefix_ = None self.dataTypeDetails = _cast(None, dataTypeDetails) + self.dataTypeDetails_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.PlainText = PlainText + self.PlainText_nsprefix_ = None self.Unicode = Unicode + self.Unicode_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3338,6 +4254,10 @@ def factory(*args_, **kwargs_): else: return TextEquivType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_PlainText(self): return self.PlainText def set_PlainText(self, PlainText): @@ -3366,6 +4286,34 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + def validate_TextDataTypeSimpleType(self, value): + # Validate type pc:TextDataTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['xsd:decimal', 'xsd:float', 'xsd:integer', 'xsd:boolean', 'xsd:date', 'xsd:time', 'xsd:dateTime', 'xsd:string', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextDataTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.PlainText is not None or @@ -3374,7 +4322,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextEquivType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextEquivType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3382,8 +4330,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TextEquivType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3395,56 +4345,62 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TextEquivType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextEquivType'): if self.index is not None and 'index' not in already_processed: already_processed.add('index') outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index')) if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) if self.dataType is not None and 'dataType' not in already_processed: already_processed.add('dataType') - outfile.write(' dataType=%s' % (quote_attrib(self.dataType), )) + outfile.write(' dataType=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataType), input_name='dataType')), )) if self.dataTypeDetails is not None and 'dataTypeDetails' not in already_processed: already_processed.add('dataTypeDetails') outfile.write(' dataTypeDetails=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataTypeDetails), input_name='dataTypeDetails')), )) if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextEquivType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.PlainText is not None: + namespaceprefix_ = self.PlainText_nsprefix_ + ':' if (UseCapturedNS_ and self.PlainText_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sPlainText>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.PlainText), input_name='PlainText')), namespaceprefix_ , eol_)) if self.Unicode is not None: + namespaceprefix_ = self.Unicode_nsprefix_ + ':' if (UseCapturedNS_ and self.Unicode_nsprefix_) else '' showIndent(outfile, level, pretty_print) outfile.write('<%sUnicode>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Unicode), input_name='Unicode')), namespaceprefix_ , eol_)) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType value = find_attr_value_('dataType', node) if value is not None and 'dataType' not in already_processed: already_processed.add('dataType') self.dataType = value + self.validate_TextDataTypeSimpleType(self.dataType) # validate type TextDataTypeSimpleType value = find_attr_value_('dataTypeDetails', node) if value is not None and 'dataTypeDetails' not in already_processed: already_processed.add('dataTypeDetails') @@ -3453,29 +4409,43 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'PlainText': - PlainText_ = child_.text - PlainText_ = self.gds_validate_string(PlainText_, node, 'PlainText') - self.PlainText = PlainText_ + value_ = child_.text + value_ = self.gds_parse_string(value_, node, 'PlainText') + value_ = self.gds_validate_string(value_, node, 'PlainText') + self.PlainText = value_ + self.PlainText_nsprefix_ = child_.prefix elif nodeName_ == 'Unicode': - Unicode_ = child_.text - Unicode_ = self.gds_validate_string(Unicode_, node, 'Unicode') - self.Unicode = Unicode_ + value_ = child_.text + value_ = self.gds_parse_string(value_, node, 'Unicode') + value_ = self.gds_validate_string(value_, node, 'Unicode') + self.Unicode = value_ + self.Unicode_nsprefix_ = child_.prefix + def __hash__(self): + return hash(self.id) # end class TextEquivType class GridType(GeneratedsSuper): """Matrix of grid points defining the table grid on the page.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('GridPoints', 'GridPointsType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '2', 'name': 'GridPoints', 'type': 'GridPointsType'}, None), + ] subclass = None superclass = None - def __init__(self, GridPoints=None, **kwargs_): + def __init__(self, GridPoints=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None if GridPoints is None: self.GridPoints = [] else: self.GridPoints = GridPoints + self.GridPoints_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3487,14 +4457,16 @@ def factory(*args_, **kwargs_): else: return GridType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_GridPoints(self): return self.GridPoints def set_GridPoints(self, GridPoints): self.GridPoints = GridPoints def add_GridPoints(self, value): self.GridPoints.append(value) - def add_GridPoints(self, value): - self.GridPoints.append(value) def insert_GridPoints_at(self, index, value): self.GridPoints.insert(index, value) def replace_GridPoints_at(self, index, value): @@ -3506,7 +4478,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3514,8 +4486,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GridType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3527,42 +4501,60 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GridType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for GridPoints_ in self.GridPoints: + namespaceprefix_ = self.GridPoints_nsprefix_ + ':' if (UseCapturedNS_ and self.GridPoints_nsprefix_) else '' GridPoints_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GridPoints', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'GridPoints': obj_ = GridPointsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.GridPoints.append(obj_) obj_.original_tagname_ = 'GridPoints' + def __hash__(self): + return hash(self.id) # end class GridType class GridPointsType(GeneratedsSuper): - """Points with x,y coordinates. The grid row index""" + """Points with x,y coordinates. + The grid row index""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('index', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required'}), + ] subclass = None superclass = None - def __init__(self, index=None, points=None, **kwargs_): + def __init__(self, index=None, points=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.points = _cast(None, points) + self.points_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3574,6 +4566,10 @@ def factory(*args_, **kwargs_): else: return GridPointsType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_index(self): return self.index def set_index(self, index): @@ -3582,6 +4578,17 @@ def get_points(self): return self.points def set_points(self, points): self.points = points + def validate_PointsType(self, value): + # Validate type pc:PointsType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + if not self.gds_validate_simple_patterns( + self.validate_PointsType_patterns_, value): + self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, )) + validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']] def hasContent_(self): if ( @@ -3589,7 +4596,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridPointsType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3597,8 +4604,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GridPointsType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3609,52 +4618,65 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GridPointsType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridPointsType'): if self.index is not None and 'index' not in already_processed: already_processed.add('index') outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index')) if self.points is not None and 'points' not in already_processed: already_processed.add('points') - outfile.write(' points=%s' % (quote_attrib(self.points), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', fromsubclass_=False, pretty_print=True): + outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('points', node) if value is not None and 'points' not in already_processed: already_processed.add('points') self.points = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_PointsType(self.points) # validate type PointsType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class GridPointsType class PrintSpaceType(GeneratedsSuper): - """Determines the effective area on the paper of a printed page. Its - size is equal for all pages of a book (exceptions: titlepage, - multipage pictures). It contains all living elements (except - marginals) like body type, footnotes, headings, running titles. + """Determines the effective area on the paper of a printed page. + Its size is equal for all pages of a book + (exceptions: titlepage, multipage pictures). + It contains all living elements (except marginals) + like body type, footnotes, headings, running titles. It does not contain pagenumber (if not part of running title), marginals, signature mark, preview words.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + ] subclass = None superclass = None - def __init__(self, Coords=None, **kwargs_): + def __init__(self, Coords=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3666,6 +4688,10 @@ def factory(*args_, **kwargs_): else: return PrintSpaceType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Coords(self): return self.Coords def set_Coords(self, Coords): @@ -3677,7 +4703,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('PrintSpaceType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3685,8 +4711,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'PrintSpaceType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3698,46 +4726,66 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='PrintSpaceType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PrintSpaceType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' + def __hash__(self): + return hash(self.id) # end class PrintSpaceType class ReadingOrderType(GeneratedsSuper): - """Definition of the reading order within the page. To express a - reading order between elements they have to be included in an - OrderedGroup. Groups may contain further groups. Confidence - value (between 0 and 1)""" + """Definition of the reading order within the page. + To express a reading order between elements + they have to be included in an OrderedGroup. + Groups may contain further groups. + Confidence value (between 0 and 1)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('OrderedGroup', 'OrderedGroupType', 0, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 2), + MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 0, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 2), + ] subclass = None superclass = None - def __init__(self, conf=None, OrderedGroup=None, UnorderedGroup=None, **kwargs_): + def __init__(self, conf=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None self.OrderedGroup = OrderedGroup + self.OrderedGroup_nsprefix_ = None self.UnorderedGroup = UnorderedGroup + self.UnorderedGroup_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3749,6 +4797,10 @@ def factory(*args_, **kwargs_): else: return ReadingOrderType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_OrderedGroup(self): return self.OrderedGroup def set_OrderedGroup(self, OrderedGroup): @@ -3761,6 +4813,21 @@ def get_conf(self): return self.conf def set_conf(self, conf): self.conf = conf + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False def hasContent_(self): if ( self.OrderedGroup is not None or @@ -3769,7 +4836,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('ReadingOrderType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3777,8 +4844,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'ReadingOrderType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3790,55 +4859,75 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='ReadingOrderType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ReadingOrderType'): if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', fromsubclass_=False, pretty_print=True): + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.OrderedGroup is not None: + namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else '' self.OrderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print) if self.UnorderedGroup is not None: + namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else '' self.UnorderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'OrderedGroup': obj_ = OrderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.OrderedGroup = obj_ obj_.original_tagname_ = 'OrderedGroup' elif nodeName_ == 'UnorderedGroup': obj_ = UnorderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnorderedGroup = obj_ obj_.original_tagname_ = 'UnorderedGroup' + def __hash__(self): + return hash(self.id) # end class ReadingOrderType class RegionRefIndexedType(GeneratedsSuper): - """Numbered regionPosition (order number) of this item within the - current hierarchy level.""" + """Numbered regionPosition (order number) of this item within the current + hierarchy level.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('index', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required'}), + ] subclass = None superclass = None - def __init__(self, index=None, regionRef=None, **kwargs_): + def __init__(self, index=None, regionRef=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3850,6 +4939,10 @@ def factory(*args_, **kwargs_): else: return RegionRefIndexedType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_index(self): return self.index def set_index(self, index): @@ -3865,7 +4958,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefIndexedType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -3873,8 +4966,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RegionRefIndexedType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -3885,76 +4980,114 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RegionRefIndexedType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefIndexedType'): if self.index is not None and 'index' not in already_processed: already_processed.add('index') outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index')) if self.regionRef is not None and 'regionRef' not in already_processed: already_processed.add('regionRef') outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('regionRef', node) if value is not None and 'regionRef' not in already_processed: already_processed.add('regionRef') self.regionRef = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class RegionRefIndexedType class OrderedGroupIndexedType(GeneratedsSuper): - """Indexed group containing ordered elements Optional link to a parent - region of nested regions. The parent region doubles as reading - order group. Only the nested regions should be allowed as group - members. Position (order number) of this item within the current - hierarchy level. Is this group a continuation of another group - (from previous column or page, for example)? For generic use""" + """Indexed group containing ordered elements + Optional link to a parent region of nested regions. + The parent region doubles as reading order group. + Only the nested regions should be allowed as group members. + Position (order number) of this item within the + current hierarchy level. + Is this group a continuation of another group (from + previous column or page, for example)? + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('index', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('caption', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 3), + MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 3), + MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 3), + ] subclass = None superclass = None - def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, **kwargs_): + def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.caption = _cast(None, caption) + self.caption_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.continuation = _cast(bool, continuation) + self.continuation_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None if RegionRefIndexed is None: self.RegionRefIndexed = [] else: self.RegionRefIndexed = RegionRefIndexed + self.RegionRefIndexed_nsprefix_ = None if OrderedGroupIndexed is None: self.OrderedGroupIndexed = [] else: self.OrderedGroupIndexed = OrderedGroupIndexed + self.OrderedGroupIndexed_nsprefix_ = None if UnorderedGroupIndexed is None: self.UnorderedGroupIndexed = [] else: self.UnorderedGroupIndexed = UnorderedGroupIndexed + self.UnorderedGroupIndexed_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -3966,6 +5099,10 @@ def factory(*args_, **kwargs_): else: return OrderedGroupIndexedType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_UserDefined(self): return self.UserDefined def set_UserDefined(self, UserDefined): @@ -3976,8 +5113,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -3988,8 +5123,6 @@ def set_RegionRefIndexed(self, RegionRefIndexed): self.RegionRefIndexed = RegionRefIndexed def add_RegionRefIndexed(self, value): self.RegionRefIndexed.append(value) - def add_RegionRefIndexed(self, value): - self.RegionRefIndexed.append(value) def insert_RegionRefIndexed_at(self, index, value): self.RegionRefIndexed.insert(index, value) def replace_RegionRefIndexed_at(self, index, value): @@ -4000,8 +5133,6 @@ def set_OrderedGroupIndexed(self, OrderedGroupIndexed): self.OrderedGroupIndexed = OrderedGroupIndexed def add_OrderedGroupIndexed(self, value): self.OrderedGroupIndexed.append(value) - def add_OrderedGroupIndexed(self, value): - self.OrderedGroupIndexed.append(value) def insert_OrderedGroupIndexed_at(self, index, value): self.OrderedGroupIndexed.insert(index, value) def replace_OrderedGroupIndexed_at(self, index, value): @@ -4012,8 +5143,6 @@ def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed): self.UnorderedGroupIndexed = UnorderedGroupIndexed def add_UnorderedGroupIndexed(self, value): self.UnorderedGroupIndexed.append(value) - def add_UnorderedGroupIndexed(self, value): - self.UnorderedGroupIndexed.append(value) def insert_UnorderedGroupIndexed_at(self, index, value): self.UnorderedGroupIndexed.insert(index, value) def replace_UnorderedGroupIndexed_at(self, index, value): @@ -4050,6 +5179,19 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_GroupTypeSimpleType(self, value): + # Validate type pc:GroupTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.UserDefined is not None or @@ -4061,7 +5203,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupIndexedType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -4069,8 +5211,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'OrderedGroupIndexedType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -4082,7 +5226,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='OrderedGroupIndexedType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupIndexedType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -4097,7 +5241,7 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.continuation is not None and 'continuation' not in already_processed: already_processed.add('continuation') outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation')) @@ -4107,27 +5251,36 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) for RegionRefIndexed_ in self.RegionRefIndexed: + namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else '' RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print) for OrderedGroupIndexed_ in self.OrderedGroupIndexed: + namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else '' OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print) for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed: + namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else '' UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -4141,10 +5294,7 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('caption', node) if value is not None and 'caption' not in already_processed: already_processed.add('caption') @@ -4153,6 +5303,7 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_GroupTypeSimpleType(self.type_) # validate type GroupTypeSimpleType value = find_attr_value_('continuation', node) if value is not None and 'continuation' not in already_processed: already_processed.add('continuation') @@ -4170,73 +5321,109 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'RegionRefIndexed': obj_ = RegionRefIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.RegionRefIndexed.append(obj_) obj_.original_tagname_ = 'RegionRefIndexed' elif nodeName_ == 'OrderedGroupIndexed': obj_ = OrderedGroupIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.OrderedGroupIndexed.append(obj_) obj_.original_tagname_ = 'OrderedGroupIndexed' elif nodeName_ == 'UnorderedGroupIndexed': obj_ = UnorderedGroupIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnorderedGroupIndexed.append(obj_) obj_.original_tagname_ = 'UnorderedGroupIndexed' + def __hash__(self): + return hash(self.id) # end class OrderedGroupIndexedType class UnorderedGroupIndexedType(GeneratedsSuper): - """Indexed group containing unordered elements Optional link to a - parent region of nested regions. The parent region doubles as - reading order group. Only the nested regions should be allowed - as group members. Position (order number) of this item within - the current hierarchy level. Is this group a continuation of - another group (from previous column or page, for example)? For - generic use""" + """Indexed group containing unordered elements + Optional link to a parent region of nested regions. + The parent region doubles as reading order group. + Only the nested regions should be allowed as group members. + Position (order number) of this item within the + current hierarchy level. + Is this group a continuation of another group + (from previous column or page, for example)? + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('index', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('caption', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 4), + MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 4), + MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 4), + ] subclass = None superclass = None - def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, **kwargs_): + def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.caption = _cast(None, caption) + self.caption_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.continuation = _cast(bool, continuation) + self.continuation_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None if RegionRef is None: self.RegionRef = [] else: self.RegionRef = RegionRef + self.RegionRef_nsprefix_ = None if OrderedGroup is None: self.OrderedGroup = [] else: self.OrderedGroup = OrderedGroup + self.OrderedGroup_nsprefix_ = None if UnorderedGroup is None: self.UnorderedGroup = [] else: self.UnorderedGroup = UnorderedGroup + self.UnorderedGroup_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -4248,6 +5435,10 @@ def factory(*args_, **kwargs_): else: return UnorderedGroupIndexedType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_UserDefined(self): return self.UserDefined def set_UserDefined(self, UserDefined): @@ -4258,8 +5449,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -4270,8 +5459,6 @@ def set_RegionRef(self, RegionRef): self.RegionRef = RegionRef def add_RegionRef(self, value): self.RegionRef.append(value) - def add_RegionRef(self, value): - self.RegionRef.append(value) def insert_RegionRef_at(self, index, value): self.RegionRef.insert(index, value) def replace_RegionRef_at(self, index, value): @@ -4282,8 +5469,6 @@ def set_OrderedGroup(self, OrderedGroup): self.OrderedGroup = OrderedGroup def add_OrderedGroup(self, value): self.OrderedGroup.append(value) - def add_OrderedGroup(self, value): - self.OrderedGroup.append(value) def insert_OrderedGroup_at(self, index, value): self.OrderedGroup.insert(index, value) def replace_OrderedGroup_at(self, index, value): @@ -4294,8 +5479,6 @@ def set_UnorderedGroup(self, UnorderedGroup): self.UnorderedGroup = UnorderedGroup def add_UnorderedGroup(self, value): self.UnorderedGroup.append(value) - def add_UnorderedGroup(self, value): - self.UnorderedGroup.append(value) def insert_UnorderedGroup_at(self, index, value): self.UnorderedGroup.insert(index, value) def replace_UnorderedGroup_at(self, index, value): @@ -4332,6 +5515,19 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_GroupTypeSimpleType(self, value): + # Validate type pc:GroupTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.UserDefined is not None or @@ -4343,7 +5539,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupIndexedType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -4351,8 +5547,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'UnorderedGroupIndexedType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -4364,7 +5562,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='UnorderedGroupIndexedType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupIndexedType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -4379,7 +5577,7 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.continuation is not None and 'continuation' not in already_processed: already_processed.add('continuation') outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation')) @@ -4389,27 +5587,36 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) for RegionRef_ in self.RegionRef: + namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else '' RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print) for OrderedGroup_ in self.OrderedGroup: + namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else '' OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print) for UnorderedGroup_ in self.UnorderedGroup: + namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else '' UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -4423,10 +5630,7 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('caption', node) if value is not None and 'caption' not in already_processed: already_processed.add('caption') @@ -4435,6 +5639,7 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_GroupTypeSimpleType(self.type_) # validate type GroupTypeSimpleType value = find_attr_value_('continuation', node) if value is not None and 'continuation' not in already_processed: already_processed.add('continuation') @@ -4452,42 +5657,52 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'RegionRef': obj_ = RegionRefType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.RegionRef.append(obj_) obj_.original_tagname_ = 'RegionRef' elif nodeName_ == 'OrderedGroup': obj_ = OrderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.OrderedGroup.append(obj_) obj_.original_tagname_ = 'OrderedGroup' elif nodeName_ == 'UnorderedGroup': obj_ = UnorderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnorderedGroup.append(obj_) obj_.original_tagname_ = 'UnorderedGroup' + def __hash__(self): + return hash(self.id) # end class UnorderedGroupIndexedType class RegionRefType(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required'}), + ] subclass = None superclass = None - def __init__(self, regionRef=None, **kwargs_): + def __init__(self, regionRef=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -4499,6 +5714,10 @@ def factory(*args_, **kwargs_): else: return RegionRefType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_regionRef(self): return self.regionRef def set_regionRef(self, regionRef): @@ -4510,7 +5729,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -4518,8 +5737,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RegionRefType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -4530,64 +5751,102 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RegionRefType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefType'): if self.regionRef is not None and 'regionRef' not in already_processed: already_processed.add('regionRef') outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('regionRef', node) if value is not None and 'regionRef' not in already_processed: already_processed.add('regionRef') self.regionRef = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class RegionRefType class OrderedGroupType(GeneratedsSuper): - """Numbered group (contains ordered elements) Optional link to a parent - region of nested regions. The parent region doubles as reading - order group. Only the nested regions should be allowed as group - members. Is this group a continuation of another group (from - previous column or page, for example)? For generic use""" + """Numbered group (contains ordered elements) + Optional link to a parent region of nested regions. + The parent region doubles as reading order group. + Only the nested regions should be allowed as group members. + Is this group a continuation of another group + (from previous column or page, for example)? + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('caption', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 5), + MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 5), + MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 5), + ] subclass = None superclass = None - def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, **kwargs_): + def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None self.caption = _cast(None, caption) + self.caption_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.continuation = _cast(bool, continuation) + self.continuation_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None if RegionRefIndexed is None: self.RegionRefIndexed = [] else: self.RegionRefIndexed = RegionRefIndexed + self.RegionRefIndexed_nsprefix_ = None if OrderedGroupIndexed is None: self.OrderedGroupIndexed = [] else: self.OrderedGroupIndexed = OrderedGroupIndexed + self.OrderedGroupIndexed_nsprefix_ = None if UnorderedGroupIndexed is None: self.UnorderedGroupIndexed = [] else: self.UnorderedGroupIndexed = UnorderedGroupIndexed + self.UnorderedGroupIndexed_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -4599,6 +5858,10 @@ def factory(*args_, **kwargs_): else: return OrderedGroupType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_UserDefined(self): return self.UserDefined def set_UserDefined(self, UserDefined): @@ -4609,8 +5872,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -4621,8 +5882,6 @@ def set_RegionRefIndexed(self, RegionRefIndexed): self.RegionRefIndexed = RegionRefIndexed def add_RegionRefIndexed(self, value): self.RegionRefIndexed.append(value) - def add_RegionRefIndexed(self, value): - self.RegionRefIndexed.append(value) def insert_RegionRefIndexed_at(self, index, value): self.RegionRefIndexed.insert(index, value) def replace_RegionRefIndexed_at(self, index, value): @@ -4633,8 +5892,6 @@ def set_OrderedGroupIndexed(self, OrderedGroupIndexed): self.OrderedGroupIndexed = OrderedGroupIndexed def add_OrderedGroupIndexed(self, value): self.OrderedGroupIndexed.append(value) - def add_OrderedGroupIndexed(self, value): - self.OrderedGroupIndexed.append(value) def insert_OrderedGroupIndexed_at(self, index, value): self.OrderedGroupIndexed.insert(index, value) def replace_OrderedGroupIndexed_at(self, index, value): @@ -4645,8 +5902,6 @@ def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed): self.UnorderedGroupIndexed = UnorderedGroupIndexed def add_UnorderedGroupIndexed(self, value): self.UnorderedGroupIndexed.append(value) - def add_UnorderedGroupIndexed(self, value): - self.UnorderedGroupIndexed.append(value) def insert_UnorderedGroupIndexed_at(self, index, value): self.UnorderedGroupIndexed.insert(index, value) def replace_UnorderedGroupIndexed_at(self, index, value): @@ -4679,6 +5934,19 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_GroupTypeSimpleType(self, value): + # Validate type pc:GroupTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.UserDefined is not None or @@ -4690,7 +5958,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -4698,8 +5966,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'OrderedGroupType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -4711,7 +5981,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='OrderedGroupType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -4723,7 +5993,7 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.continuation is not None and 'continuation' not in already_processed: already_processed.add('continuation') outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation')) @@ -4733,27 +6003,36 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) for RegionRefIndexed_ in self.RegionRefIndexed: + namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else '' RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print) for OrderedGroupIndexed_ in self.OrderedGroupIndexed: + namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else '' OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print) for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed: + namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else '' UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -4772,6 +6051,7 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_GroupTypeSimpleType(self.type_) # validate type GroupTypeSimpleType value = find_attr_value_('continuation', node) if value is not None and 'continuation' not in already_processed: already_processed.add('continuation') @@ -4789,70 +6069,104 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'RegionRefIndexed': obj_ = RegionRefIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.RegionRefIndexed.append(obj_) obj_.original_tagname_ = 'RegionRefIndexed' elif nodeName_ == 'OrderedGroupIndexed': obj_ = OrderedGroupIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.OrderedGroupIndexed.append(obj_) obj_.original_tagname_ = 'OrderedGroupIndexed' elif nodeName_ == 'UnorderedGroupIndexed': obj_ = UnorderedGroupIndexedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnorderedGroupIndexed.append(obj_) obj_.original_tagname_ = 'UnorderedGroupIndexed' + def __hash__(self): + return hash(self.id) # end class OrderedGroupType class UnorderedGroupType(GeneratedsSuper): - """Numbered group (contains unordered elements) Optional link to a - parent region of nested regions. The parent region doubles as - reading order group. Only the nested regions should be allowed - as group members. Is this group a continuation of another group - (from previous column or page, for example)? For generic use""" + """Numbered group (contains unordered elements) + Optional link to a parent region of nested regions. + The parent region doubles as reading order group. + Only the nested regions should be allowed as group members. + Is this group a continuation of another group + (from previous column or page, for example)? + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('caption', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 6), + MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 6), + MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 6), + ] subclass = None superclass = None - def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, **kwargs_): + def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.regionRef = _cast(None, regionRef) + self.regionRef_nsprefix_ = None self.caption = _cast(None, caption) + self.caption_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.continuation = _cast(bool, continuation) + self.continuation_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None if RegionRef is None: self.RegionRef = [] else: self.RegionRef = RegionRef + self.RegionRef_nsprefix_ = None if OrderedGroup is None: self.OrderedGroup = [] else: self.OrderedGroup = OrderedGroup + self.OrderedGroup_nsprefix_ = None if UnorderedGroup is None: self.UnorderedGroup = [] else: self.UnorderedGroup = UnorderedGroup + self.UnorderedGroup_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -4864,6 +6178,10 @@ def factory(*args_, **kwargs_): else: return UnorderedGroupType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_UserDefined(self): return self.UserDefined def set_UserDefined(self, UserDefined): @@ -4874,8 +6192,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -4886,8 +6202,6 @@ def set_RegionRef(self, RegionRef): self.RegionRef = RegionRef def add_RegionRef(self, value): self.RegionRef.append(value) - def add_RegionRef(self, value): - self.RegionRef.append(value) def insert_RegionRef_at(self, index, value): self.RegionRef.insert(index, value) def replace_RegionRef_at(self, index, value): @@ -4898,8 +6212,6 @@ def set_OrderedGroup(self, OrderedGroup): self.OrderedGroup = OrderedGroup def add_OrderedGroup(self, value): self.OrderedGroup.append(value) - def add_OrderedGroup(self, value): - self.OrderedGroup.append(value) def insert_OrderedGroup_at(self, index, value): self.OrderedGroup.insert(index, value) def replace_OrderedGroup_at(self, index, value): @@ -4910,8 +6222,6 @@ def set_UnorderedGroup(self, UnorderedGroup): self.UnorderedGroup = UnorderedGroup def add_UnorderedGroup(self, value): self.UnorderedGroup.append(value) - def add_UnorderedGroup(self, value): - self.UnorderedGroup.append(value) def insert_UnorderedGroup_at(self, index, value): self.UnorderedGroup.insert(index, value) def replace_UnorderedGroup_at(self, index, value): @@ -4944,6 +6254,19 @@ def get_comments(self): return self.comments def set_comments(self, comments): self.comments = comments + def validate_GroupTypeSimpleType(self, value): + # Validate type pc:GroupTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.UserDefined is not None or @@ -4955,7 +6278,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -4963,8 +6286,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'UnorderedGroupType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -4976,7 +6301,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='UnorderedGroupType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -4988,7 +6313,7 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.continuation is not None and 'continuation' not in already_processed: already_processed.add('continuation') outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation')) @@ -4998,27 +6323,36 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) for RegionRef_ in self.RegionRef: + namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else '' RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print) for OrderedGroup_ in self.OrderedGroup: + namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else '' OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print) for UnorderedGroup_ in self.UnorderedGroup: + namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else '' UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -5037,6 +6371,7 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_GroupTypeSimpleType(self.type_) # validate type GroupTypeSimpleType value = find_attr_value_('continuation', node) if value is not None and 'continuation' not in already_processed: already_processed.add('continuation') @@ -5054,44 +6389,54 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'RegionRef': obj_ = RegionRefType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.RegionRef.append(obj_) obj_.original_tagname_ = 'RegionRef' elif nodeName_ == 'OrderedGroup': obj_ = OrderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.OrderedGroup.append(obj_) obj_.original_tagname_ = 'OrderedGroup' elif nodeName_ == 'UnorderedGroup': obj_ = UnorderedGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnorderedGroup.append(obj_) obj_.original_tagname_ = 'UnorderedGroup' + def __hash__(self): + return hash(self.id) # end class UnorderedGroupType class BorderType(GeneratedsSuper): - """Border of the actual page (if the scanned image contains parts not - belonging to the page).""" + """Border of the actual page (if the scanned image + contains parts not belonging to the page).""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + ] subclass = None superclass = None - def __init__(self, Coords=None, **kwargs_): + def __init__(self, Coords=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5103,6 +6448,10 @@ def factory(*args_, **kwargs_): else: return BorderType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Coords(self): return self.Coords def set_Coords(self, Coords): @@ -5114,7 +6463,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('BorderType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5122,8 +6471,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'BorderType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5135,46 +6486,61 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='BorderType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BorderType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' + def __hash__(self): + return hash(self.id) # end class BorderType class LayersType(GeneratedsSuper): - """Can be used to express the z-index of overlapping regions. An - element with a greater z-index is always in front of another - element with lower z-index.""" + """Can be used to express the z-index of overlapping + regions. An element with a greater z-index is always in + front of another element with lower z-index.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Layer', 'LayerType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Layer', 'type': 'LayerType'}, None), + ] subclass = None superclass = None - def __init__(self, Layer=None, **kwargs_): + def __init__(self, Layer=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None if Layer is None: self.Layer = [] else: self.Layer = Layer + self.Layer_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5186,14 +6552,16 @@ def factory(*args_, **kwargs_): else: return LayersType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Layer(self): return self.Layer def set_Layer(self, Layer): self.Layer = Layer def add_Layer(self, value): self.Layer.append(value) - def add_Layer(self, value): - self.Layer.append(value) def insert_Layer_at(self, index, value): self.Layer.insert(index, value) def replace_Layer_at(self, index, value): @@ -5205,7 +6573,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayersType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5213,8 +6581,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'LayersType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5226,46 +6596,67 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='LayersType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayersType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Layer_ in self.Layer: + namespaceprefix_ = self.Layer_nsprefix_ + ':' if (UseCapturedNS_ and self.Layer_nsprefix_) else '' Layer_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layer', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Layer': obj_ = LayerType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Layer.append(obj_) obj_.original_tagname_ = 'Layer' + def __hash__(self): + return hash(self.id) # end class LayersType class LayerType(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('zIndex', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('caption', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'RegionRef', 'type': 'RegionRefType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, zIndex=None, caption=None, RegionRef=None, **kwargs_): + def __init__(self, id=None, zIndex=None, caption=None, RegionRef=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.zIndex = _cast(int, zIndex) + self.zIndex_nsprefix_ = None self.caption = _cast(None, caption) + self.caption_nsprefix_ = None if RegionRef is None: self.RegionRef = [] else: self.RegionRef = RegionRef + self.RegionRef_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5277,14 +6668,16 @@ def factory(*args_, **kwargs_): else: return LayerType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_RegionRef(self): return self.RegionRef def set_RegionRef(self, RegionRef): self.RegionRef = RegionRef def add_RegionRef(self, value): self.RegionRef.append(value) - def add_RegionRef(self, value): - self.RegionRef.append(value) def insert_RegionRef_at(self, index, value): self.RegionRef.insert(index, value) def replace_RegionRef_at(self, index, value): @@ -5308,7 +6701,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayerType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5316,8 +6709,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'LayerType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5329,7 +6724,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='LayerType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayerType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -5339,19 +6734,24 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.caption is not None and 'caption' not in already_processed: already_processed.add('caption') outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for RegionRef_ in self.RegionRef: + namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else '' RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -5361,32 +6761,41 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('zIndex', node) if value is not None and 'zIndex' not in already_processed: already_processed.add('zIndex') - try: - self.zIndex = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.zIndex = self.gds_parse_integer(value, node, 'zIndex') value = find_attr_value_('caption', node) if value is not None and 'caption' not in already_processed: already_processed.add('caption') self.caption = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'RegionRef': obj_ = RegionRefType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.RegionRef.append(obj_) obj_.original_tagname_ = 'RegionRef' + def __hash__(self): + return hash(self.id) # end class LayerType class BaselineType(GeneratedsSuper): """Confidence value (between 0 and 1)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required'}), + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, points=None, conf=None, **kwargs_): + def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.points = _cast(None, points) + self.points_nsprefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5398,6 +6807,10 @@ def factory(*args_, **kwargs_): else: return BaselineType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_points(self): return self.points def set_points(self, points): @@ -5406,6 +6819,32 @@ def get_conf(self): return self.conf def set_conf(self, conf): self.conf = conf + def validate_PointsType(self, value): + # Validate type pc:PointsType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + if not self.gds_validate_simple_patterns( + self.validate_PointsType_patterns_, value): + self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, )) + validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']] + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False def hasContent_(self): if ( @@ -5413,7 +6852,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('BaselineType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5421,8 +6860,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'BaselineType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5433,48 +6874,66 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='BaselineType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BaselineType'): if self.points is not None and 'points' not in already_processed: already_processed.add('points') - outfile.write(' points=%s' % (quote_attrib(self.points), )) + outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), )) if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', fromsubclass_=False, pretty_print=True): + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('points', node) if value is not None and 'points' not in already_processed: already_processed.add('points') self.points = value + self.validate_PointsType(self.points) # validate type PointsType value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class BaselineType class RelationsType(GeneratedsSuper): - """Container for one-to-one relations between layout objects (for - example: DropCap - paragraph, caption - image).""" + """Container for one-to-one relations between layout + objects (for example: DropCap - paragraph, caption - + image).""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Relation', 'RelationType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Relation', 'type': 'RelationType'}, None), + ] subclass = None superclass = None - def __init__(self, Relation=None, **kwargs_): + def __init__(self, Relation=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None if Relation is None: self.Relation = [] else: self.Relation = Relation + self.Relation_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5486,14 +6945,16 @@ def factory(*args_, **kwargs_): else: return RelationsType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Relation(self): return self.Relation def set_Relation(self, Relation): self.Relation = Relation def add_Relation(self, value): self.Relation.append(value) - def add_Relation(self, value): - self.Relation.append(value) def insert_Relation_at(self, index, value): self.Relation.insert(index, value) def replace_Relation_at(self, index, value): @@ -5505,7 +6966,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationsType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5513,8 +6974,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RelationsType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5526,61 +6989,91 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RelationsType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationsType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Relation_ in self.Relation: + namespaceprefix_ = self.Relation_nsprefix_ + ':' if (UseCapturedNS_ and self.Relation_nsprefix_) else '' Relation_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relation', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Relation': obj_ = RelationType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Relation.append(obj_) obj_.original_tagname_ = 'Relation' + def __hash__(self): + return hash(self.id) # end class RelationsType class RelationType(GeneratedsSuper): - """One-to-one relation between to layout object. Use 'link' for loose - relations and 'join' for strong relations (where something is - fragmented for instance). Examples for 'link': caption - image - floating - paragraph paragraph - paragraph (when a paragraph is - split across columns and the last word of the first paragraph - DOES NOT continue in the second paragraph) drop-cap - paragraph - (when the drop-cap is a whole word) Examples for 'join': word - - word (separated word at the end of a line) drop-cap - paragraph - (when the drop-cap is not a whole word) paragraph - paragraph - (when a pragraph is split across columns and the last word of - the first paragraph DOES continue in the second paragraph) For - generic use""" + """One-to-one relation between to layout object. Use 'link' + for loose relations and 'join' for strong relations + (where something is fragmented for instance). + Examples for 'link': caption - image floating - + paragraph paragraph - paragraph (when a paragraph is + split across columns and the last word of the first + paragraph DOES NOT continue in the second paragraph) + drop-cap - paragraph (when the drop-cap is a whole word) + Examples for 'join': word - word (separated word at the + end of a line) drop-cap - paragraph (when the drop-cap + is not a whole word) paragraph - paragraph (when a + pragraph is split across columns and the last word of + the first paragraph DOES continue in the second + paragraph) + For generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('type_', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('SourceRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'SourceRegionRef', 'type': 'RegionRefType'}, None), + MemberSpec_('TargetRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'TargetRegionRef', 'type': 'RegionRefType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, type_=None, custom=None, comments=None, Labels=None, SourceRegionRef=None, TargetRegionRef=None, **kwargs_): + def __init__(self, id=None, type_=None, custom=None, comments=None, Labels=None, SourceRegionRef=None, TargetRegionRef=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None self.SourceRegionRef = SourceRegionRef + self.SourceRegionRef_nsprefix_ = None self.TargetRegionRef = TargetRegionRef + self.TargetRegionRef_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5592,14 +7085,16 @@ def factory(*args_, **kwargs_): else: return RelationType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Labels(self): return self.Labels def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -5637,7 +7132,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5645,8 +7140,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RelationType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5658,7 +7155,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RelationType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -5671,23 +7168,30 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.comments is not None and 'comments' not in already_processed: already_processed.add('comments') outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) if self.SourceRegionRef is not None: + namespaceprefix_ = self.SourceRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.SourceRegionRef_nsprefix_) else '' self.SourceRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SourceRegionRef', pretty_print=pretty_print) if self.TargetRegionRef is not None: + namespaceprefix_ = self.TargetRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.TargetRegionRef_nsprefix_) else '' self.TargetRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TargetRegionRef', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -5706,65 +7210,123 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'comments' not in already_processed: already_processed.add('comments') self.comments = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'SourceRegionRef': obj_ = RegionRefType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.SourceRegionRef = obj_ obj_.original_tagname_ = 'SourceRegionRef' elif nodeName_ == 'TargetRegionRef': obj_ = RegionRefType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TargetRegionRef = obj_ obj_.original_tagname_ = 'TargetRegionRef' + def __hash__(self): + return hash(self.id) # end class RelationType class TextStyleType(GeneratedsSuper): - """Monospace (fixed-pitch, non-proportional) or proportional font. For - instance: Arial, Times New Roman. Add more information if - necessary (e.g. blackletter, antiqua). Serif or sans-serif - typeface. The size of the characters in points. The x-height or - corpus size refers to the distance between the baseline and the - mean line of lower-case letters in a typeface. The unit is - assumed to be pixels. The degree of space (in points) between - the characters in a string of text. Text colour in RGB encoded - format (red value) + (256 x green value) + (65536 x blue value). - Background colour Background colour in RGB encoded format (red - value) + (256 x green value) + (65536 x blue value). Specifies - whether the colour of the text appears reversed against a - background colour. Line style details if "underlined" is TRUE""" + """Monospace (fixed-pitch, non-proportional) or + proportional font. + For instance: Arial, Times New Roman. + Add more information if necessary + (e.g. blackletter, antiqua). + Serif or sans-serif typeface. + The size of the characters in points. + The x-height or corpus size refers to the distance + between the baseline and the mean line of + lower-case letters in a typeface. + The unit is assumed to be pixels. + The degree of space (in points) between + the characters in a string of text. + Text colour in RGB encoded format + (red value) + (256 x green value) + (65536 x blue value). + Background colour + Background colour in RGB encoded format + (red value) + (256 x green value) + (65536 x blue value). + Specifies whether the colour of the text appears + reversed against a background colour. + Line style details if "underlined" is TRUE""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('fontFamily', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('serif', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('monospace', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('fontSize', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('xHeight', 'integer', 0, 1, {'use': 'optional'}), + MemberSpec_('kerning', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('textColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('textColourRgb', 'integer', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColourRgb', 'integer', 0, 1, {'use': 'optional'}), + MemberSpec_('reverseVideo', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('bold', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('italic', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('underlined', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('underlineStyle', 'pc:underlineStyleType', 0, 1, {'use': 'optional'}), + MemberSpec_('doubleUnderlined', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('subscript', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('superscript', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('strikethrough', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('smallCaps', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('letterSpaced', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, fontFamily=None, serif=None, monospace=None, fontSize=None, xHeight=None, kerning=None, textColour=None, textColourRgb=None, bgColour=None, bgColourRgb=None, reverseVideo=None, bold=None, italic=None, underlined=None, underlineStyle=None, doubleUnderlined=None, subscript=None, superscript=None, strikethrough=None, smallCaps=None, letterSpaced=None, **kwargs_): + def __init__(self, fontFamily=None, serif=None, monospace=None, fontSize=None, xHeight=None, kerning=None, textColour=None, textColourRgb=None, bgColour=None, bgColourRgb=None, reverseVideo=None, bold=None, italic=None, underlined=None, underlineStyle=None, doubleUnderlined=None, subscript=None, superscript=None, strikethrough=None, smallCaps=None, letterSpaced=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.fontFamily = _cast(None, fontFamily) + self.fontFamily_nsprefix_ = None self.serif = _cast(bool, serif) + self.serif_nsprefix_ = None self.monospace = _cast(bool, monospace) + self.monospace_nsprefix_ = None self.fontSize = _cast(float, fontSize) + self.fontSize_nsprefix_ = None self.xHeight = _cast(int, xHeight) + self.xHeight_nsprefix_ = None self.kerning = _cast(int, kerning) + self.kerning_nsprefix_ = None self.textColour = _cast(None, textColour) + self.textColour_nsprefix_ = None self.textColourRgb = _cast(int, textColourRgb) + self.textColourRgb_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None self.bgColourRgb = _cast(int, bgColourRgb) + self.bgColourRgb_nsprefix_ = None self.reverseVideo = _cast(bool, reverseVideo) + self.reverseVideo_nsprefix_ = None self.bold = _cast(bool, bold) + self.bold_nsprefix_ = None self.italic = _cast(bool, italic) + self.italic_nsprefix_ = None self.underlined = _cast(bool, underlined) + self.underlined_nsprefix_ = None self.underlineStyle = _cast(None, underlineStyle) + self.underlineStyle_nsprefix_ = None self.doubleUnderlined = _cast(bool, doubleUnderlined) + self.doubleUnderlined_nsprefix_ = None self.subscript = _cast(bool, subscript) + self.subscript_nsprefix_ = None self.superscript = _cast(bool, superscript) + self.superscript_nsprefix_ = None self.strikethrough = _cast(bool, strikethrough) + self.strikethrough_nsprefix_ = None self.smallCaps = _cast(bool, smallCaps) + self.smallCaps_nsprefix_ = None self.letterSpaced = _cast(bool, letterSpaced) + self.letterSpaced_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -5776,6 +7338,10 @@ def factory(*args_, **kwargs_): else: return TextStyleType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_fontFamily(self): return self.fontFamily def set_fontFamily(self, fontFamily): @@ -5860,6 +7426,32 @@ def get_letterSpaced(self): return self.letterSpaced def set_letterSpaced(self, letterSpaced): self.letterSpaced = letterSpaced + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_underlineStyleType(self, value): + # Validate type pc:underlineStyleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['singleLine', 'doubleLine', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on underlineStyleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( @@ -5867,7 +7459,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextStyleType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -5875,8 +7467,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TextStyleType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -5887,7 +7481,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TextStyleType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextStyleType'): if self.fontFamily is not None and 'fontFamily' not in already_processed: already_processed.add('fontFamily') outfile.write(' fontFamily=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fontFamily), input_name='fontFamily')), )) @@ -5908,13 +7502,13 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' kerning="%s"' % self.gds_format_integer(self.kerning, input_name='kerning')) if self.textColour is not None and 'textColour' not in already_processed: already_processed.add('textColour') - outfile.write(' textColour=%s' % (quote_attrib(self.textColour), )) + outfile.write(' textColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textColour), input_name='textColour')), )) if self.textColourRgb is not None and 'textColourRgb' not in already_processed: already_processed.add('textColourRgb') outfile.write(' textColourRgb="%s"' % self.gds_format_integer(self.textColourRgb, input_name='textColourRgb')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) if self.bgColourRgb is not None and 'bgColourRgb' not in already_processed: already_processed.add('bgColourRgb') outfile.write(' bgColourRgb="%s"' % self.gds_format_integer(self.bgColourRgb, input_name='bgColourRgb')) @@ -5932,7 +7526,7 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' underlined="%s"' % self.gds_format_boolean(self.underlined, input_name='underlined')) if self.underlineStyle is not None and 'underlineStyle' not in already_processed: already_processed.add('underlineStyle') - outfile.write(' underlineStyle=%s' % (quote_attrib(self.underlineStyle), )) + outfile.write(' underlineStyle=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.underlineStyle), input_name='underlineStyle')), )) if self.doubleUnderlined is not None and 'doubleUnderlined' not in already_processed: already_processed.add('doubleUnderlined') outfile.write(' doubleUnderlined="%s"' % self.gds_format_boolean(self.doubleUnderlined, input_name='doubleUnderlined')) @@ -5951,14 +7545,18 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.letterSpaced is not None and 'letterSpaced' not in already_processed: already_processed.add('letterSpaced') outfile.write(' letterSpaced="%s"' % self.gds_format_boolean(self.letterSpaced, input_name='letterSpaced')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('fontFamily', node) @@ -5986,46 +7584,34 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('fontSize', node) if value is not None and 'fontSize' not in already_processed: already_processed.add('fontSize') - try: - self.fontSize = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (fontSize): %s' % exp) + value = self.gds_parse_float(value, node, 'fontSize') + self.fontSize = value value = find_attr_value_('xHeight', node) if value is not None and 'xHeight' not in already_processed: already_processed.add('xHeight') - try: - self.xHeight = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.xHeight = self.gds_parse_integer(value, node, 'xHeight') value = find_attr_value_('kerning', node) if value is not None and 'kerning' not in already_processed: already_processed.add('kerning') - try: - self.kerning = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.kerning = self.gds_parse_integer(value, node, 'kerning') value = find_attr_value_('textColour', node) if value is not None and 'textColour' not in already_processed: already_processed.add('textColour') self.textColour = value + self.validate_ColourSimpleType(self.textColour) # validate type ColourSimpleType value = find_attr_value_('textColourRgb', node) if value is not None and 'textColourRgb' not in already_processed: already_processed.add('textColourRgb') - try: - self.textColourRgb = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.textColourRgb = self.gds_parse_integer(value, node, 'textColourRgb') value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType value = find_attr_value_('bgColourRgb', node) if value is not None and 'bgColourRgb' not in already_processed: already_processed.add('bgColourRgb') - try: - self.bgColourRgb = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.bgColourRgb = self.gds_parse_integer(value, node, 'bgColourRgb') value = find_attr_value_('reverseVideo', node) if value is not None and 'reverseVideo' not in already_processed: already_processed.add('reverseVideo') @@ -6066,6 +7652,7 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'underlineStyle' not in already_processed: already_processed.add('underlineStyle') self.underlineStyle = value + self.validate_underlineStyleType(self.underlineStyle) # validate type underlineStyleType value = find_attr_value_('doubleUnderlined', node) if value is not None and 'doubleUnderlined' not in already_processed: already_processed.add('doubleUnderlined') @@ -6120,90 +7707,145 @@ def buildAttributes(self, node, attrs, already_processed): self.letterSpaced = False else: raise_parse_error(node, 'Bad boolean attribute') - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class TextStyleType class RegionType(GeneratedsSuper): - """For generic use Is this region a continuation of another region (in - previous column or page, for example)?""" + """For generic use + Is this region a continuation of another region + (in previous column or page, for example)?""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None), + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None), + MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None), + MemberSpec_('Roles', 'RolesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Roles', 'type': 'RolesType'}, None), + MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 7), + MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 7), + MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 7), + MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 7), + MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 7), + MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 7), + MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 7), + MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 7), + MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 7), + MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 7), + MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 7), + MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 7), + MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 7), + MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 7), + ] subclass = None superclass = None - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, extensiontype_=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, extensiontype_=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.continuation = _cast(bool, continuation) + self.continuation_nsprefix_ = None if AlternativeImage is None: self.AlternativeImage = [] else: self.AlternativeImage = AlternativeImage + self.AlternativeImage_nsprefix_ = None self.Coords = Coords + self.Coords_nsprefix_ = None self.UserDefined = UserDefined + self.UserDefined_nsprefix_ = None if Labels is None: self.Labels = [] else: self.Labels = Labels + self.Labels_nsprefix_ = None self.Roles = Roles + self.Roles_nsprefix_ = None if TextRegion is None: self.TextRegion = [] else: self.TextRegion = TextRegion + self.TextRegion_nsprefix_ = None if ImageRegion is None: self.ImageRegion = [] else: self.ImageRegion = ImageRegion + self.ImageRegion_nsprefix_ = None if LineDrawingRegion is None: self.LineDrawingRegion = [] else: self.LineDrawingRegion = LineDrawingRegion + self.LineDrawingRegion_nsprefix_ = None if GraphicRegion is None: self.GraphicRegion = [] else: self.GraphicRegion = GraphicRegion + self.GraphicRegion_nsprefix_ = None if TableRegion is None: self.TableRegion = [] else: self.TableRegion = TableRegion + self.TableRegion_nsprefix_ = None if ChartRegion is None: self.ChartRegion = [] else: self.ChartRegion = ChartRegion + self.ChartRegion_nsprefix_ = None if SeparatorRegion is None: self.SeparatorRegion = [] else: self.SeparatorRegion = SeparatorRegion + self.SeparatorRegion_nsprefix_ = None if MathsRegion is None: self.MathsRegion = [] else: self.MathsRegion = MathsRegion + self.MathsRegion_nsprefix_ = None if ChemRegion is None: self.ChemRegion = [] else: self.ChemRegion = ChemRegion + self.ChemRegion_nsprefix_ = None if MusicRegion is None: self.MusicRegion = [] else: self.MusicRegion = MusicRegion + self.MusicRegion_nsprefix_ = None if AdvertRegion is None: self.AdvertRegion = [] else: self.AdvertRegion = AdvertRegion + self.AdvertRegion_nsprefix_ = None if NoiseRegion is None: self.NoiseRegion = [] else: self.NoiseRegion = NoiseRegion + self.NoiseRegion_nsprefix_ = None if UnknownRegion is None: self.UnknownRegion = [] else: self.UnknownRegion = UnknownRegion + self.UnknownRegion_nsprefix_ = None if CustomRegion is None: self.CustomRegion = [] else: self.CustomRegion = CustomRegion + self.CustomRegion_nsprefix_ = None self.extensiontype_ = extensiontype_ def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: @@ -6216,14 +7858,16 @@ def factory(*args_, **kwargs_): else: return RegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_AlternativeImage(self): return self.AlternativeImage def set_AlternativeImage(self, AlternativeImage): self.AlternativeImage = AlternativeImage def add_AlternativeImage(self, value): self.AlternativeImage.append(value) - def add_AlternativeImage(self, value): - self.AlternativeImage.append(value) def insert_AlternativeImage_at(self, index, value): self.AlternativeImage.insert(index, value) def replace_AlternativeImage_at(self, index, value): @@ -6242,8 +7886,6 @@ def set_Labels(self, Labels): self.Labels = Labels def add_Labels(self, value): self.Labels.append(value) - def add_Labels(self, value): - self.Labels.append(value) def insert_Labels_at(self, index, value): self.Labels.insert(index, value) def replace_Labels_at(self, index, value): @@ -6258,8 +7900,6 @@ def set_TextRegion(self, TextRegion): self.TextRegion = TextRegion def add_TextRegion(self, value): self.TextRegion.append(value) - def add_TextRegion(self, value): - self.TextRegion.append(value) def insert_TextRegion_at(self, index, value): self.TextRegion.insert(index, value) def replace_TextRegion_at(self, index, value): @@ -6270,8 +7910,6 @@ def set_ImageRegion(self, ImageRegion): self.ImageRegion = ImageRegion def add_ImageRegion(self, value): self.ImageRegion.append(value) - def add_ImageRegion(self, value): - self.ImageRegion.append(value) def insert_ImageRegion_at(self, index, value): self.ImageRegion.insert(index, value) def replace_ImageRegion_at(self, index, value): @@ -6282,8 +7920,6 @@ def set_LineDrawingRegion(self, LineDrawingRegion): self.LineDrawingRegion = LineDrawingRegion def add_LineDrawingRegion(self, value): self.LineDrawingRegion.append(value) - def add_LineDrawingRegion(self, value): - self.LineDrawingRegion.append(value) def insert_LineDrawingRegion_at(self, index, value): self.LineDrawingRegion.insert(index, value) def replace_LineDrawingRegion_at(self, index, value): @@ -6294,8 +7930,6 @@ def set_GraphicRegion(self, GraphicRegion): self.GraphicRegion = GraphicRegion def add_GraphicRegion(self, value): self.GraphicRegion.append(value) - def add_GraphicRegion(self, value): - self.GraphicRegion.append(value) def insert_GraphicRegion_at(self, index, value): self.GraphicRegion.insert(index, value) def replace_GraphicRegion_at(self, index, value): @@ -6306,8 +7940,6 @@ def set_TableRegion(self, TableRegion): self.TableRegion = TableRegion def add_TableRegion(self, value): self.TableRegion.append(value) - def add_TableRegion(self, value): - self.TableRegion.append(value) def insert_TableRegion_at(self, index, value): self.TableRegion.insert(index, value) def replace_TableRegion_at(self, index, value): @@ -6318,8 +7950,6 @@ def set_ChartRegion(self, ChartRegion): self.ChartRegion = ChartRegion def add_ChartRegion(self, value): self.ChartRegion.append(value) - def add_ChartRegion(self, value): - self.ChartRegion.append(value) def insert_ChartRegion_at(self, index, value): self.ChartRegion.insert(index, value) def replace_ChartRegion_at(self, index, value): @@ -6330,8 +7960,6 @@ def set_SeparatorRegion(self, SeparatorRegion): self.SeparatorRegion = SeparatorRegion def add_SeparatorRegion(self, value): self.SeparatorRegion.append(value) - def add_SeparatorRegion(self, value): - self.SeparatorRegion.append(value) def insert_SeparatorRegion_at(self, index, value): self.SeparatorRegion.insert(index, value) def replace_SeparatorRegion_at(self, index, value): @@ -6342,8 +7970,6 @@ def set_MathsRegion(self, MathsRegion): self.MathsRegion = MathsRegion def add_MathsRegion(self, value): self.MathsRegion.append(value) - def add_MathsRegion(self, value): - self.MathsRegion.append(value) def insert_MathsRegion_at(self, index, value): self.MathsRegion.insert(index, value) def replace_MathsRegion_at(self, index, value): @@ -6354,8 +7980,6 @@ def set_ChemRegion(self, ChemRegion): self.ChemRegion = ChemRegion def add_ChemRegion(self, value): self.ChemRegion.append(value) - def add_ChemRegion(self, value): - self.ChemRegion.append(value) def insert_ChemRegion_at(self, index, value): self.ChemRegion.insert(index, value) def replace_ChemRegion_at(self, index, value): @@ -6366,8 +7990,6 @@ def set_MusicRegion(self, MusicRegion): self.MusicRegion = MusicRegion def add_MusicRegion(self, value): self.MusicRegion.append(value) - def add_MusicRegion(self, value): - self.MusicRegion.append(value) def insert_MusicRegion_at(self, index, value): self.MusicRegion.insert(index, value) def replace_MusicRegion_at(self, index, value): @@ -6378,8 +8000,6 @@ def set_AdvertRegion(self, AdvertRegion): self.AdvertRegion = AdvertRegion def add_AdvertRegion(self, value): self.AdvertRegion.append(value) - def add_AdvertRegion(self, value): - self.AdvertRegion.append(value) def insert_AdvertRegion_at(self, index, value): self.AdvertRegion.insert(index, value) def replace_AdvertRegion_at(self, index, value): @@ -6390,8 +8010,6 @@ def set_NoiseRegion(self, NoiseRegion): self.NoiseRegion = NoiseRegion def add_NoiseRegion(self, value): self.NoiseRegion.append(value) - def add_NoiseRegion(self, value): - self.NoiseRegion.append(value) def insert_NoiseRegion_at(self, index, value): self.NoiseRegion.insert(index, value) def replace_NoiseRegion_at(self, index, value): @@ -6402,8 +8020,6 @@ def set_UnknownRegion(self, UnknownRegion): self.UnknownRegion = UnknownRegion def add_UnknownRegion(self, value): self.UnknownRegion.append(value) - def add_UnknownRegion(self, value): - self.UnknownRegion.append(value) def insert_UnknownRegion_at(self, index, value): self.UnknownRegion.insert(index, value) def replace_UnknownRegion_at(self, index, value): @@ -6414,8 +8030,6 @@ def set_CustomRegion(self, CustomRegion): self.CustomRegion = CustomRegion def add_CustomRegion(self, value): self.CustomRegion.append(value) - def add_CustomRegion(self, value): - self.CustomRegion.append(value) def insert_CustomRegion_at(self, index, value): self.CustomRegion.insert(index, value) def replace_CustomRegion_at(self, index, value): @@ -6463,7 +8077,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -6471,8 +8085,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -6484,7 +8100,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -6500,56 +8116,83 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') - outfile.write(' xsi:type="%s"' % self.extensiontype_) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', fromsubclass_=False, pretty_print=True): + if ":" not in self.extensiontype_: + imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '') + outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_)) + else: + outfile.write(' xsi:type="%s"' % self.extensiontype_) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for AlternativeImage_ in self.AlternativeImage: + namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else '' AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print) if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) if self.UserDefined is not None: + namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else '' self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print) for Labels_ in self.Labels: + namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else '' Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print) if self.Roles is not None: + namespaceprefix_ = self.Roles_nsprefix_ + ':' if (UseCapturedNS_ and self.Roles_nsprefix_) else '' self.Roles.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Roles', pretty_print=pretty_print) for TextRegion_ in self.TextRegion: + namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else '' TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print) for ImageRegion_ in self.ImageRegion: + namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else '' ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print) for LineDrawingRegion_ in self.LineDrawingRegion: + namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else '' LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print) for GraphicRegion_ in self.GraphicRegion: + namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else '' GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print) for TableRegion_ in self.TableRegion: + namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else '' TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print) for ChartRegion_ in self.ChartRegion: + namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else '' ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print) for SeparatorRegion_ in self.SeparatorRegion: + namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else '' SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print) for MathsRegion_ in self.MathsRegion: + namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else '' MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print) for ChemRegion_ in self.ChemRegion: + namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else '' ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print) for MusicRegion_ in self.MusicRegion: + namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else '' MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print) for AdvertRegion_ in self.AdvertRegion: + namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else '' AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print) for NoiseRegion_ in self.NoiseRegion: + namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else '' NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print) for UnknownRegion_ in self.UnknownRegion: + namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else '' UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print) for CustomRegion_ in self.CustomRegion: + namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else '' CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -6577,115 +8220,129 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') self.extensiontype_ = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'AlternativeImage': obj_ = AlternativeImageType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AlternativeImage.append(obj_) obj_.original_tagname_ = 'AlternativeImage' elif nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' elif nodeName_ == 'UserDefined': obj_ = UserDefinedType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserDefined = obj_ obj_.original_tagname_ = 'UserDefined' elif nodeName_ == 'Labels': obj_ = LabelsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Labels.append(obj_) obj_.original_tagname_ = 'Labels' elif nodeName_ == 'Roles': obj_ = RolesType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Roles = obj_ obj_.original_tagname_ = 'Roles' elif nodeName_ == 'TextRegion': obj_ = TextRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextRegion.append(obj_) obj_.original_tagname_ = 'TextRegion' elif nodeName_ == 'ImageRegion': obj_ = ImageRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ImageRegion.append(obj_) obj_.original_tagname_ = 'ImageRegion' elif nodeName_ == 'LineDrawingRegion': obj_ = LineDrawingRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.LineDrawingRegion.append(obj_) obj_.original_tagname_ = 'LineDrawingRegion' elif nodeName_ == 'GraphicRegion': obj_ = GraphicRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.GraphicRegion.append(obj_) obj_.original_tagname_ = 'GraphicRegion' elif nodeName_ == 'TableRegion': obj_ = TableRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TableRegion.append(obj_) obj_.original_tagname_ = 'TableRegion' elif nodeName_ == 'ChartRegion': obj_ = ChartRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ChartRegion.append(obj_) obj_.original_tagname_ = 'ChartRegion' elif nodeName_ == 'SeparatorRegion': obj_ = SeparatorRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.SeparatorRegion.append(obj_) obj_.original_tagname_ = 'SeparatorRegion' elif nodeName_ == 'MathsRegion': obj_ = MathsRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MathsRegion.append(obj_) obj_.original_tagname_ = 'MathsRegion' elif nodeName_ == 'ChemRegion': obj_ = ChemRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.ChemRegion.append(obj_) obj_.original_tagname_ = 'ChemRegion' elif nodeName_ == 'MusicRegion': obj_ = MusicRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.MusicRegion.append(obj_) obj_.original_tagname_ = 'MusicRegion' elif nodeName_ == 'AdvertRegion': obj_ = AdvertRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.AdvertRegion.append(obj_) obj_.original_tagname_ = 'AdvertRegion' elif nodeName_ == 'NoiseRegion': obj_ = NoiseRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.NoiseRegion.append(obj_) obj_.original_tagname_ = 'NoiseRegion' elif nodeName_ == 'UnknownRegion': obj_ = UnknownRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UnknownRegion.append(obj_) obj_.original_tagname_ = 'UnknownRegion' elif nodeName_ == 'CustomRegion': obj_ = CustomRegionType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.CustomRegion.append(obj_) obj_.original_tagname_ = 'CustomRegion' + def __hash__(self): + return hash(self.id) # end class RegionType class AlternativeImageType(GeneratedsSuper): """Confidence value (between 0 and 1)""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('filename', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, filename=None, comments=None, conf=None, **kwargs_): + def __init__(self, filename=None, comments=None, conf=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.filename = _cast(None, filename) + self.filename_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None self.conf = _cast(float, conf) + self.conf_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -6697,6 +8354,10 @@ def factory(*args_, **kwargs_): else: return AlternativeImageType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_filename(self): return self.filename def set_filename(self, filename): @@ -6709,6 +8370,21 @@ def get_conf(self): return self.conf def set_conf(self, conf): self.conf = conf + def validate_ConfSimpleType(self, value): + # Validate type pc:ConfSimpleType, a restriction on float. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, float): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, }) + return False + if value < 0: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False + if value > 1: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} ) + result = False def hasContent_(self): if ( @@ -6716,7 +8392,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('AlternativeImageType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -6724,8 +8400,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'AlternativeImageType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -6736,7 +8414,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='AlternativeImageType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AlternativeImageType'): if self.filename is not None and 'filename' not in already_processed: already_processed.add('filename') outfile.write(' filename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.filename), input_name='filename')), )) @@ -6745,15 +8423,19 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), )) if self.conf is not None and 'conf' not in already_processed: already_processed.add('conf') - outfile.write(' conf=%s' % (quote_attrib(self.conf), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', fromsubclass_=False, pretty_print=True): + outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf')) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('filename', node) @@ -6767,32 +8449,48 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('conf', node) if value is not None and 'conf' not in already_processed: already_processed.add('conf') + value = self.gds_parse_float(value, node, 'conf') self.conf = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + self.validate_ConfSimpleType(self.conf) # validate type ConfSimpleType + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class AlternativeImageType class GraphemesType(GeneratedsSuper): - """Container for graphemes, grapheme groups and non-printing - characters.""" + """Container for graphemes, grapheme groups and + non-printing characters.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Grapheme', 'GraphemeType', 1, 0, {'name': 'Grapheme', 'type': 'GraphemeType'}, 8), + MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 0, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 8), + MemberSpec_('GraphemeGroup', 'GraphemeGroupType', 1, 0, {'name': 'GraphemeGroup', 'type': 'GraphemeGroupType'}, 8), + ] subclass = None superclass = None - def __init__(self, Grapheme=None, NonPrintingChar=None, GraphemeGroup=None, **kwargs_): + def __init__(self, Grapheme=None, NonPrintingChar=None, GraphemeGroup=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None if Grapheme is None: self.Grapheme = [] else: self.Grapheme = Grapheme + self.Grapheme_nsprefix_ = None if NonPrintingChar is None: self.NonPrintingChar = [] else: self.NonPrintingChar = NonPrintingChar + self.NonPrintingChar_nsprefix_ = None if GraphemeGroup is None: self.GraphemeGroup = [] else: self.GraphemeGroup = GraphemeGroup + self.GraphemeGroup_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -6804,14 +8502,16 @@ def factory(*args_, **kwargs_): else: return GraphemesType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Grapheme(self): return self.Grapheme def set_Grapheme(self, Grapheme): self.Grapheme = Grapheme def add_Grapheme(self, value): self.Grapheme.append(value) - def add_Grapheme(self, value): - self.Grapheme.append(value) def insert_Grapheme_at(self, index, value): self.Grapheme.insert(index, value) def replace_Grapheme_at(self, index, value): @@ -6822,8 +8522,6 @@ def set_NonPrintingChar(self, NonPrintingChar): self.NonPrintingChar = NonPrintingChar def add_NonPrintingChar(self, value): self.NonPrintingChar.append(value) - def add_NonPrintingChar(self, value): - self.NonPrintingChar.append(value) def insert_NonPrintingChar_at(self, index, value): self.NonPrintingChar.insert(index, value) def replace_NonPrintingChar_at(self, index, value): @@ -6834,8 +8532,6 @@ def set_GraphemeGroup(self, GraphemeGroup): self.GraphemeGroup = GraphemeGroup def add_GraphemeGroup(self, value): self.GraphemeGroup.append(value) - def add_GraphemeGroup(self, value): - self.GraphemeGroup.append(value) def insert_GraphemeGroup_at(self, index, value): self.GraphemeGroup.insert(index, value) def replace_GraphemeGroup_at(self, index, value): @@ -6849,7 +8545,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemesType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -6857,8 +8553,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GraphemesType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -6870,69 +8568,98 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GraphemesType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemesType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for Grapheme_ in self.Grapheme: + namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else '' Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print) for NonPrintingChar_ in self.NonPrintingChar: + namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else '' NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print) for GraphemeGroup_ in self.GraphemeGroup: + namespaceprefix_ = self.GraphemeGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphemeGroup_nsprefix_) else '' GraphemeGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphemeGroup', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Grapheme': obj_ = GraphemeType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Grapheme.append(obj_) obj_.original_tagname_ = 'Grapheme' elif nodeName_ == 'NonPrintingChar': obj_ = NonPrintingCharType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.NonPrintingChar.append(obj_) obj_.original_tagname_ = 'NonPrintingChar' elif nodeName_ == 'GraphemeGroup': obj_ = GraphemeGroupType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.GraphemeGroup.append(obj_) obj_.original_tagname_ = 'GraphemeGroup' + def __hash__(self): + return hash(self.id) # end class GraphemesType class GraphemeBaseType(GeneratedsSuper): - """Base type for graphemes, grapheme groups and non-printing - characters. Order index of grapheme, group, or non-printing - character within the parent container (graphemes or glyph or - grapheme group). Type of character represented by the grapheme, - group, or non-printing character element. For generic useFor - generic use""" + """Base type for graphemes, grapheme groups and non-printing characters. + Order index of grapheme, group, or non-printing character + within the parent container (graphemes or glyph or grapheme group). + Type of character represented by the + grapheme, group, or non-printing character element. + For generic useFor generic use""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('id', 'string', 0, 0, {'use': 'required'}), + MemberSpec_('index', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('charType', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('custom', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('comments', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None), + ] subclass = None superclass = None - def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, extensiontype_=None, **kwargs_): + def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, extensiontype_=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.id = _cast(None, id) + self.id_nsprefix_ = None self.index = _cast(int, index) + self.index_nsprefix_ = None self.ligature = _cast(bool, ligature) + self.ligature_nsprefix_ = None self.charType = _cast(None, charType) + self.charType_nsprefix_ = None self.custom = _cast(None, custom) + self.custom_nsprefix_ = None self.comments = _cast(None, comments) + self.comments_nsprefix_ = None if TextEquiv is None: self.TextEquiv = [] else: self.TextEquiv = TextEquiv + self.TextEquiv_nsprefix_ = None self.extensiontype_ = extensiontype_ def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: @@ -6945,14 +8672,16 @@ def factory(*args_, **kwargs_): else: return GraphemeBaseType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_TextEquiv(self): return self.TextEquiv def set_TextEquiv(self, TextEquiv): self.TextEquiv = TextEquiv def add_TextEquiv(self, value): self.TextEquiv.append(value) - def add_TextEquiv(self, value): - self.TextEquiv.append(value) def insert_TextEquiv_at(self, index, value): self.TextEquiv.insert(index, value) def replace_TextEquiv_at(self, index, value): @@ -6990,7 +8719,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeBaseType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -6998,8 +8727,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GraphemeBaseType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7011,7 +8742,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GraphemeBaseType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeBaseType'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) @@ -7033,20 +8764,29 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') - outfile.write(' xsi:type="%s"' % self.extensiontype_) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', fromsubclass_=False, pretty_print=True): + if ":" not in self.extensiontype_: + imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '') + outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_)) + else: + outfile.write(' xsi:type="%s"' % self.extensiontype_) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for TextEquiv_ in self.TextEquiv: + namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else '' TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('id', node) @@ -7056,10 +8796,7 @@ def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('index', node) if value is not None and 'index' not in already_processed: already_processed.add('index') - try: - self.index = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.index = self.gds_parse_integer(value, node, 'index') value = find_attr_value_('ligature', node) if value is not None and 'ligature' not in already_processed: already_processed.add('ligature') @@ -7085,25 +8822,36 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') self.extensiontype_ = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'TextEquiv': obj_ = TextEquivType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextEquiv.append(obj_) obj_.original_tagname_ = 'TextEquiv' + def __hash__(self): + return hash(self.id) # end class GraphemeBaseType class GraphemeType(GraphemeBaseType): - """Represents a sub-element of a glyph. Smallest graphical unit that - can be assigned a Unicode code point.""" + """Represents a sub-element of a glyph. + Smallest graphical unit that can be + assigned a Unicode code point.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None), + ] subclass = None superclass = GraphemeBaseType - def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Coords=None, **kwargs_): + def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Coords=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(GraphemeType, self).__init__(id, index, ligature, charType, custom, comments, TextEquiv, **kwargs_) self.Coords = Coords + self.Coords_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7115,6 +8863,10 @@ def factory(*args_, **kwargs_): else: return GraphemeType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Coords(self): return self.Coords def set_Coords(self, Coords): @@ -7127,7 +8879,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7135,8 +8887,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GraphemeType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7148,44 +8902,58 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GraphemeType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeType'): super(GraphemeType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeType') - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', fromsubclass_=False, pretty_print=True): - super(GraphemeType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', fromsubclass_=False, pretty_print=True): + super(GraphemeType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) if pretty_print: eol_ = '\n' else: eol_ = '' if self.Coords is not None: + namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else '' self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): super(GraphemeType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Coords': obj_ = CoordsType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Coords = obj_ obj_.original_tagname_ = 'Coords' super(GraphemeType, self).buildChildren(child_, node, nodeName_, True) + def __hash__(self): + return hash(self.id) # end class GraphemeType class NonPrintingCharType(GraphemeBaseType): - """A glyph component without visual representation but with Unicode - code point. Non-visual / non-printing / control character. Part - of grapheme container (of glyph) or grapheme sub group.""" + """A glyph component without visual representation + but with Unicode code point. + Non-visual / non-printing / control character. + Part of grapheme container (of glyph) or grapheme sub group.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + ] subclass = None superclass = GraphemeBaseType - def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, **kwargs_): + def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(NonPrintingCharType, self).__init__(id, index, ligature, charType, custom, comments, TextEquiv, **kwargs_) def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: @@ -7198,6 +8966,10 @@ def factory(*args_, **kwargs_): else: return NonPrintingCharType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def hasContent_(self): if ( super(NonPrintingCharType, self).hasContent_() @@ -7205,7 +8977,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('NonPrintingCharType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7213,8 +8985,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'NonPrintingCharType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7226,40 +9000,56 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='NonPrintingCharType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NonPrintingCharType'): super(NonPrintingCharType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NonPrintingCharType') - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', fromsubclass_=False, pretty_print=True): - super(NonPrintingCharType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', fromsubclass_=False, pretty_print=True): + super(NonPrintingCharType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): super(NonPrintingCharType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(NonPrintingCharType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class NonPrintingCharType class GraphemeGroupType(GraphemeBaseType): + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('Grapheme', 'GraphemeType', 1, 1, {'name': 'Grapheme', 'type': 'GraphemeType'}, 9), + MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 1, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 9), + ] subclass = None superclass = GraphemeBaseType - def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Grapheme=None, NonPrintingChar=None, **kwargs_): + def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Grapheme=None, NonPrintingChar=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(GraphemeGroupType, self).__init__(id, index, ligature, charType, custom, comments, TextEquiv, **kwargs_) if Grapheme is None: self.Grapheme = [] else: self.Grapheme = Grapheme + self.Grapheme_nsprefix_ = None if NonPrintingChar is None: self.NonPrintingChar = [] else: self.NonPrintingChar = NonPrintingChar + self.NonPrintingChar_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7271,14 +9061,16 @@ def factory(*args_, **kwargs_): else: return GraphemeGroupType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Grapheme(self): return self.Grapheme def set_Grapheme(self, Grapheme): self.Grapheme = Grapheme def add_Grapheme(self, value): self.Grapheme.append(value) - def add_Grapheme(self, value): - self.Grapheme.append(value) def insert_Grapheme_at(self, index, value): self.Grapheme.insert(index, value) def replace_Grapheme_at(self, index, value): @@ -7289,8 +9081,6 @@ def set_NonPrintingChar(self, NonPrintingChar): self.NonPrintingChar = NonPrintingChar def add_NonPrintingChar(self, value): self.NonPrintingChar.append(value) - def add_NonPrintingChar(self, value): - self.NonPrintingChar.append(value) def insert_NonPrintingChar_at(self, index, value): self.NonPrintingChar.insert(index, value) def replace_NonPrintingChar_at(self, index, value): @@ -7304,7 +9094,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeGroupType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7312,8 +9102,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GraphemeGroupType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7325,53 +9117,69 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GraphemeGroupType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeGroupType'): super(GraphemeGroupType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeGroupType') - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', fromsubclass_=False, pretty_print=True): - super(GraphemeGroupType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', fromsubclass_=False, pretty_print=True): + super(GraphemeGroupType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) if pretty_print: eol_ = '\n' else: eol_ = '' for Grapheme_ in self.Grapheme: + namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else '' Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print) for NonPrintingChar_ in self.NonPrintingChar: + namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else '' NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): super(GraphemeGroupType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Grapheme': obj_ = GraphemeType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Grapheme.append(obj_) obj_.original_tagname_ = 'Grapheme' elif nodeName_ == 'NonPrintingChar': obj_ = NonPrintingCharType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.NonPrintingChar.append(obj_) obj_.original_tagname_ = 'NonPrintingChar' super(GraphemeGroupType, self).buildChildren(child_, node, nodeName_, True) + def __hash__(self): + return hash(self.id) # end class GraphemeGroupType class UserDefinedType(GeneratedsSuper): """Container for user-defined attributes""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('UserAttribute', 'UserAttributeType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'UserAttribute', 'type': 'UserAttributeType'}, None), + ] subclass = None superclass = None - def __init__(self, UserAttribute=None, **kwargs_): + def __init__(self, UserAttribute=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None if UserAttribute is None: self.UserAttribute = [] else: self.UserAttribute = UserAttribute + self.UserAttribute_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7383,14 +9191,16 @@ def factory(*args_, **kwargs_): else: return UserDefinedType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_UserAttribute(self): return self.UserAttribute def set_UserAttribute(self, UserAttribute): self.UserAttribute = UserAttribute def add_UserAttribute(self, value): self.UserAttribute.append(value) - def add_UserAttribute(self, value): - self.UserAttribute.append(value) def insert_UserAttribute_at(self, index, value): self.UserAttribute.insert(index, value) def replace_UserAttribute_at(self, index, value): @@ -7402,7 +9212,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserDefinedType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7410,8 +9220,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'UserDefinedType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7423,44 +9235,65 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='UserDefinedType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserDefinedType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' for UserAttribute_ in self.UserAttribute: + namespaceprefix_ = self.UserAttribute_nsprefix_ + ':' if (UseCapturedNS_ and self.UserAttribute_nsprefix_) else '' UserAttribute_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserAttribute', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'UserAttribute': obj_ = UserAttributeType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.UserAttribute.append(obj_) obj_.original_tagname_ = 'UserAttribute' + def __hash__(self): + return hash(self.id) # end class UserDefinedType class UserAttributeType(GeneratedsSuper): """Structured custom data defined by name, type and value.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('name', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('description', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'string', 0, 1, {'use': 'optional'}), + MemberSpec_('value', 'string', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, name=None, description=None, type_=None, value=None, **kwargs_): + def __init__(self, name=None, description=None, type_=None, value=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.name = _cast(None, name) + self.name_nsprefix_ = None self.description = _cast(None, description) + self.description_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.value = _cast(None, value) + self.value_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7472,6 +9305,10 @@ def factory(*args_, **kwargs_): else: return UserAttributeType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_name(self): return self.name def set_name(self, name): @@ -7495,7 +9332,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserAttributeType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7503,8 +9340,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'UserAttributeType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7515,7 +9354,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='UserAttributeType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserAttributeType'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) @@ -7528,14 +9367,18 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.value is not None and 'value' not in already_processed: already_processed.add('value') outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('name', node) @@ -7554,26 +9397,44 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'value' not in already_processed: already_processed.add('value') self.value = value - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class UserAttributeType class TableCellRoleType(GeneratedsSuper): """Cell position in table starting with row 0Cell position in table - starting with column 0Number of rows the cell spans (optional; - default is 1)Number of columns the cell spans (optional; default - is 1) Is the cell a column or row header?""" + starting with column 0Number of rows the cell spans (optional; default + is 1)Number of columns the cell spans (optional; default is 1) + Is the cell a column or row header?""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('rowIndex', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('columnIndex', 'int', 0, 0, {'use': 'required'}), + MemberSpec_('rowSpan', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('colSpan', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('header', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = None - def __init__(self, rowIndex=None, columnIndex=None, rowSpan=None, colSpan=None, header=None, **kwargs_): + def __init__(self, rowIndex=None, columnIndex=None, rowSpan=None, colSpan=None, header=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.rowIndex = _cast(int, rowIndex) + self.rowIndex_nsprefix_ = None self.columnIndex = _cast(int, columnIndex) + self.columnIndex_nsprefix_ = None self.rowSpan = _cast(int, rowSpan) + self.rowSpan_nsprefix_ = None self.colSpan = _cast(int, colSpan) + self.colSpan_nsprefix_ = None self.header = _cast(bool, header) + self.header_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7585,6 +9446,10 @@ def factory(*args_, **kwargs_): else: return TableCellRoleType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_rowIndex(self): return self.rowIndex def set_rowIndex(self, rowIndex): @@ -7612,7 +9477,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableCellRoleType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7620,8 +9485,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TableCellRoleType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7632,7 +9499,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TableCellRoleType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableCellRoleType'): if self.rowIndex is not None and 'rowIndex' not in already_processed: already_processed.add('rowIndex') outfile.write(' rowIndex="%s"' % self.gds_format_integer(self.rowIndex, input_name='rowIndex')) @@ -7648,44 +9515,36 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' if self.header is not None and 'header' not in already_processed: already_processed.add('header') outfile.write(' header="%s"' % self.gds_format_boolean(self.header, input_name='header')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', fromsubclass_=False, pretty_print=True): pass - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('rowIndex', node) if value is not None and 'rowIndex' not in already_processed: already_processed.add('rowIndex') - try: - self.rowIndex = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.rowIndex = self.gds_parse_integer(value, node, 'rowIndex') value = find_attr_value_('columnIndex', node) if value is not None and 'columnIndex' not in already_processed: already_processed.add('columnIndex') - try: - self.columnIndex = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.columnIndex = self.gds_parse_integer(value, node, 'columnIndex') value = find_attr_value_('rowSpan', node) if value is not None and 'rowSpan' not in already_processed: already_processed.add('rowSpan') - try: - self.rowSpan = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.rowSpan = self.gds_parse_integer(value, node, 'rowSpan') value = find_attr_value_('colSpan', node) if value is not None and 'colSpan' not in already_processed: already_processed.add('colSpan') - try: - self.colSpan = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.colSpan = self.gds_parse_integer(value, node, 'colSpan') value = find_attr_value_('header', node) if value is not None and 'header' not in already_processed: already_processed.add('header') @@ -7695,18 +9554,28 @@ def buildAttributes(self, node, attrs, already_processed): self.header = False else: raise_parse_error(node, 'Bad boolean attribute') - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): pass + def __hash__(self): + return hash(self.id) # end class TableCellRoleType class RolesType(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('TableCellRole', 'TableCellRoleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TableCellRole', 'type': 'TableCellRoleType'}, None), + ] subclass = None superclass = None - def __init__(self, TableCellRole=None, **kwargs_): + def __init__(self, TableCellRole=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None self.TableCellRole = TableCellRole + self.TableCellRole_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7718,6 +9587,10 @@ def factory(*args_, **kwargs_): else: return RolesType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_TableCellRole(self): return self.TableCellRole def set_TableCellRole(self, TableCellRole): @@ -7729,7 +9602,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('RolesType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7737,8 +9610,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'RolesType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7750,45 +9625,61 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='RolesType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RolesType'): pass - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' if self.TableCellRole is not None: + namespaceprefix_ = self.TableCellRole_nsprefix_ + ':' if (UseCapturedNS_ and self.TableCellRole_nsprefix_) else '' self.TableCellRole.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableCellRole', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): pass - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'TableCellRole': obj_ = TableCellRoleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TableCellRole = obj_ obj_.original_tagname_ = 'TableCellRole' + def __hash__(self): + return hash(self.id) # end class RolesType class CustomRegionType(RegionType): - """Regions containing content that is not covered by the default types - (text, graphic, image, line drawing, chart, table, separator, - maths, map, music, chem, advert, noise, unknown). Information on - the type of content represented by this region""" + """Regions containing content that is not covered + by the default types (text, graphic, image, + line drawing, chart, table, separator, maths, + map, music, chem, advert, noise, unknown). + Information on the type of content represented by this region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('type_', 'string', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, type_=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, type_=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(CustomRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.type_ = _cast(None, type_) + self.type__nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -7800,6 +9691,10 @@ def factory(*args_, **kwargs_): else: return CustomRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_type(self): return self.type_ def set_type(self, type_): @@ -7811,7 +9706,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='CustomRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CustomRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('CustomRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7819,8 +9714,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'CustomRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7832,19 +9729,23 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='CustomRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CustomRegionType'): super(CustomRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CustomRegionType') if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='CustomRegionType', fromsubclass_=False, pretty_print=True): - super(CustomRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CustomRegionType', fromsubclass_=False, pretty_print=True): + super(CustomRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('type', node) @@ -7852,19 +9753,27 @@ def buildAttributes(self, node, attrs, already_processed): already_processed.add('type') self.type_ = value super(CustomRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(CustomRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class CustomRegionType class UnknownRegionType(RegionType): """To be used if the region type cannot be ascertained.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(UnknownRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: @@ -7877,6 +9786,10 @@ def factory(*args_, **kwargs_): else: return UnknownRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def hasContent_(self): if ( super(UnknownRegionType, self).hasContent_() @@ -7884,7 +9797,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='UnknownRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='UnknownRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnknownRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7892,8 +9805,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'UnknownRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7905,33 +9820,46 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='UnknownRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnknownRegionType'): super(UnknownRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnknownRegionType') - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='UnknownRegionType', fromsubclass_=False, pretty_print=True): - super(UnknownRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='UnknownRegionType', fromsubclass_=False, pretty_print=True): + super(UnknownRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): super(UnknownRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(UnknownRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class UnknownRegionType class NoiseRegionType(RegionType): - """Noise regions are regions where no real data lies, only false data - created by artifacts on the document or scanner noise.""" + """Noise regions are regions where no real data lies, only + false data created by artifacts on the document or + scanner noise.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(NoiseRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: @@ -7944,6 +9872,10 @@ def factory(*args_, **kwargs_): else: return NoiseRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def hasContent_(self): if ( super(NoiseRegionType, self).hasContent_() @@ -7951,7 +9883,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='NoiseRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='NoiseRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('NoiseRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -7959,8 +9891,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'NoiseRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -7972,39 +9906,57 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='NoiseRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NoiseRegionType'): super(NoiseRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NoiseRegionType') - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='NoiseRegionType', fromsubclass_=False, pretty_print=True): - super(NoiseRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='NoiseRegionType', fromsubclass_=False, pretty_print=True): + super(NoiseRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): super(NoiseRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(NoiseRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class NoiseRegionType class AdvertRegionType(RegionType): - """Regions containing advertisements. The angle the rectangle - encapsulating a region has to be rotated in clockwise direction - in order to correct the present skew (negative values indicate - anti-clockwise rotation). Range: -179.999,180 The background - colour of the region""" + """Regions containing advertisements. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The background colour of the region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(AdvertRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8016,6 +9968,10 @@ def factory(*args_, **kwargs_): else: return AdvertRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8024,6 +9980,19 @@ def get_bgColour(self): return self.bgColour def set_bgColour(self, bgColour): self.bgColour = bgColour + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(AdvertRegionType, self).hasContent_() @@ -8031,7 +10000,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='AdvertRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='AdvertRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('AdvertRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8039,8 +10008,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'AdvertRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8052,56 +10023,73 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='AdvertRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AdvertRegionType'): super(AdvertRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='AdvertRegionType', fromsubclass_=False, pretty_print=True): - super(AdvertRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='AdvertRegionType', fromsubclass_=False, pretty_print=True): + super(AdvertRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType super(AdvertRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(AdvertRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class AdvertRegionType class MusicRegionType(RegionType): - """Regions containing musical notations. The angle the rectangle - encapsulating a region has to be rotated in clockwise direction - in order to correct the present skew (negative values indicate - anti-clockwise rotation). Range: -179.999,180 The background - colour of the region""" + """Regions containing musical notations. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The background colour of the region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(MusicRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8113,6 +10101,10 @@ def factory(*args_, **kwargs_): else: return MusicRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8121,6 +10113,19 @@ def get_bgColour(self): return self.bgColour def set_bgColour(self, bgColour): self.bgColour = bgColour + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(MusicRegionType, self).hasContent_() @@ -8128,7 +10133,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MusicRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MusicRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('MusicRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8136,8 +10141,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'MusicRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8149,54 +10156,70 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='MusicRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MusicRegionType'): super(MusicRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MusicRegionType', fromsubclass_=False, pretty_print=True): - super(MusicRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MusicRegionType', fromsubclass_=False, pretty_print=True): + super(MusicRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType super(MusicRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(MusicRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class MusicRegionType class MapRegionType(RegionType): - """Regions containing maps. The angle the rectangle encapsulating a - region has to be rotated in clockwise direction in order to - correct the present skew (negative values indicate anti- - clockwise rotation). Range: -179.999,180""" + """Regions containing maps. + The angle the rectangle encapsulating a + region has to be rotated in clockwise + direction in order to correct the present + skew (negative values indicate + anti-clockwise rotation). Range: + -179.999,180""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(MapRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8208,6 +10231,10 @@ def factory(*args_, **kwargs_): else: return MapRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8219,7 +10246,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MapRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MapRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('MapRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8227,8 +10254,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'MapRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8240,49 +10269,66 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='MapRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MapRegionType'): super(MapRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MapRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MapRegionType', fromsubclass_=False, pretty_print=True): - super(MapRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MapRegionType', fromsubclass_=False, pretty_print=True): + super(MapRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value super(MapRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(MapRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class MapRegionType class ChemRegionType(RegionType): - """Regions containing chemical formulas. The angle the rectangle - encapsulating a region has to be rotated in clockwise direction - in order to correct the present skew (negative values indicate - anti-clockwise rotation). Range: -179.999,180 The background - colour of the region""" + """Regions containing chemical formulas. + The angle the rectangle encapsulating a + region has to be rotated in clockwise + direction in order to correct the present + skew (negative values indicate + anti-clockwise rotation). Range: + -179.999,180 + The background colour of the region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(ChemRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8294,6 +10340,10 @@ def factory(*args_, **kwargs_): else: return ChemRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8302,6 +10352,19 @@ def get_bgColour(self): return self.bgColour def set_bgColour(self, bgColour): self.bgColour = bgColour + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(ChemRegionType, self).hasContent_() @@ -8309,7 +10372,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ChemRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChemRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChemRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8317,8 +10380,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'ChemRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8330,57 +10395,74 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='ChemRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChemRegionType'): super(ChemRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ChemRegionType', fromsubclass_=False, pretty_print=True): - super(ChemRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChemRegionType', fromsubclass_=False, pretty_print=True): + super(ChemRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType super(ChemRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(ChemRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class ChemRegionType class MathsRegionType(RegionType): - """Regions containing equations and mathematical symbols should be - marked as maths regions. The angle the rectangle encapsulating a - region has to be rotated in clockwise direction in order to - correct the present skew (negative values indicate anti- - clockwise rotation). Range: -179.999,180 The background colour - of the region""" + """Regions containing equations and mathematical symbols + should be marked as maths regions. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The background colour of the region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(MathsRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8392,6 +10474,10 @@ def factory(*args_, **kwargs_): else: return MathsRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8400,6 +10486,19 @@ def get_bgColour(self): return self.bgColour def set_bgColour(self, bgColour): self.bgColour = bgColour + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(MathsRegionType, self).hasContent_() @@ -8407,7 +10506,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MathsRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MathsRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('MathsRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8415,8 +10514,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'MathsRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8428,57 +10529,75 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='MathsRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MathsRegionType'): super(MathsRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='MathsRegionType', fromsubclass_=False, pretty_print=True): - super(MathsRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MathsRegionType', fromsubclass_=False, pretty_print=True): + super(MathsRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType super(MathsRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(MathsRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class MathsRegionType class SeparatorRegionType(RegionType): - """Separators are lines that lie between columns and paragraphs and can - be used to logically separate different articles from each - other. The angle the rectangle encapsulating a region has to be - rotated in clockwise direction in order to correct the present - skew (negative values indicate anti-clockwise rotation). Range: - -179.999,180 The colour of the separator""" + """Separators are lines that lie between columns and + paragraphs and can be used to logically separate + different articles from each other. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The colour of the separator""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('colour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colour=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colour=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(SeparatorRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.colour = _cast(None, colour) + self.colour_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8490,6 +10609,10 @@ def factory(*args_, **kwargs_): else: return SeparatorRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8498,6 +10621,19 @@ def get_colour(self): return self.colour def set_colour(self, colour): self.colour = colour + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(SeparatorRegionType, self).hasContent_() @@ -8505,7 +10641,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='SeparatorRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SeparatorRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('SeparatorRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8513,8 +10649,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'SeparatorRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8526,62 +10664,88 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='SeparatorRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SeparatorRegionType'): super(SeparatorRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.colour is not None and 'colour' not in already_processed: already_processed.add('colour') - outfile.write(' colour=%s' % (quote_attrib(self.colour), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='SeparatorRegionType', fromsubclass_=False, pretty_print=True): - super(SeparatorRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + outfile.write(' colour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colour), input_name='colour')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SeparatorRegionType', fromsubclass_=False, pretty_print=True): + super(SeparatorRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('colour', node) if value is not None and 'colour' not in already_processed: already_processed.add('colour') self.colour = value + self.validate_ColourSimpleType(self.colour) # validate type ColourSimpleType super(SeparatorRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(SeparatorRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class SeparatorRegionType class ChartRegionType(RegionType): - """Regions containing charts or graphs of any type, should be marked as - chart regions. The angle the rectangle encapsulating a region - has to be rotated in clockwise direction in order to correct the - present skew (negative values indicate anti-clockwise rotation). - Range: -179.999,180 The type of chart in the region An - approximation of the number of colours used in the region The - background colour of the region Specifies whether the region - also contains text""" + """Regions containing charts or graphs of any type, should + be marked as chart regions. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The type of chart in the region + An approximation of the number of colours + used in the region + The background colour of the region + Specifies whether the region also contains + text""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:ChartTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, bgColour=None, embText=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(ChartRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.numColours = _cast(int, numColours) + self.numColours_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None self.embText = _cast(bool, embText) + self.embText_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8593,6 +10757,10 @@ def factory(*args_, **kwargs_): else: return ChartRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8613,6 +10781,32 @@ def get_embText(self): return self.embText def set_embText(self, embText): self.embText = embText + def validate_ChartTypeSimpleType(self, value): + # Validate type pc:ChartTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['bar', 'line', 'pie', 'scatter', 'surface', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ChartTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(ChartRegionType, self).hasContent_() @@ -8620,7 +10814,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ChartRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChartRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChartRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8628,8 +10822,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'ChartRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8641,55 +10837,56 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='ChartRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChartRegionType'): super(ChartRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChartRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.numColours is not None and 'numColours' not in already_processed: already_processed.add('numColours') outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours')) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) if self.embText is not None and 'embText' not in already_processed: already_processed.add('embText') outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ChartRegionType', fromsubclass_=False, pretty_print=True): - super(ChartRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChartRegionType', fromsubclass_=False, pretty_print=True): + super(ChartRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('type', node) if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_ChartTypeSimpleType(self.type_) # validate type ChartTypeSimpleType value = find_attr_value_('numColours', node) if value is not None and 'numColours' not in already_processed: already_processed.add('numColours') - try: - self.numColours = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.numColours = self.gds_parse_integer(value, node, 'numColours') value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType value = find_attr_value_('embText', node) if value is not None and 'embText' not in already_processed: already_processed.add('embText') @@ -8700,37 +10897,66 @@ def buildAttributes(self, node, attrs, already_processed): else: raise_parse_error(node, 'Bad boolean attribute') super(ChartRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(ChartRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class ChartRegionType class TableRegionType(RegionType): - """Tabular data in any form is represented with a table region. Rows - and columns may or may not have separator lines; these lines are - not separator regions. The angle the rectangle encapsulating a - region has to be rotated in clockwise direction in order to - correct the present skew (negative values indicate anti- - clockwise rotation). Range: -179.999,180 The number of rows - present in the table The number of columns present in the table - The colour of the lines used in the region The background colour - of the region Specifies the presence of line separators - Specifies whether the region also contains text""" + """Tabular data in any form is represented with a table + region. Rows and columns may or may not have separator + lines; these lines are not separator regions. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The number of rows present in the table + The number of columns present in the table + The colour of the lines used in the region + The background colour of the region + Specifies the presence of line separators + Specifies whether the region also contains + text""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('rows', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('columns', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('lineColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('lineSeparators', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('Grid', 'GridType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Grid', 'type': 'GridType'}, None), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, rows=None, columns=None, lineColour=None, bgColour=None, lineSeparators=None, embText=None, Grid=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, rows=None, columns=None, lineColour=None, bgColour=None, lineSeparators=None, embText=None, Grid=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(TableRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.rows = _cast(int, rows) + self.rows_nsprefix_ = None self.columns = _cast(int, columns) + self.columns_nsprefix_ = None self.lineColour = _cast(None, lineColour) + self.lineColour_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None self.lineSeparators = _cast(bool, lineSeparators) + self.lineSeparators_nsprefix_ = None self.embText = _cast(bool, embText) + self.embText_nsprefix_ = None self.Grid = Grid + self.Grid_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8742,6 +10968,10 @@ def factory(*args_, **kwargs_): else: return TableRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_Grid(self): return self.Grid def set_Grid(self, Grid): @@ -8774,6 +11004,19 @@ def get_embText(self): return self.embText def set_embText(self, embText): self.embText = embText + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.Grid is not None or @@ -8782,7 +11025,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='TableRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='TableRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8790,8 +11033,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TableRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8803,7 +11048,7 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TableRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableRegionType'): super(TableRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') @@ -8816,61 +11061,60 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' columns="%s"' % self.gds_format_integer(self.columns, input_name='columns')) if self.lineColour is not None and 'lineColour' not in already_processed: already_processed.add('lineColour') - outfile.write(' lineColour=%s' % (quote_attrib(self.lineColour), )) + outfile.write(' lineColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lineColour), input_name='lineColour')), )) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) if self.lineSeparators is not None and 'lineSeparators' not in already_processed: already_processed.add('lineSeparators') outfile.write(' lineSeparators="%s"' % self.gds_format_boolean(self.lineSeparators, input_name='lineSeparators')) if self.embText is not None and 'embText' not in already_processed: already_processed.add('embText') outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='TableRegionType', fromsubclass_=False, pretty_print=True): - super(TableRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='TableRegionType', fromsubclass_=False, pretty_print=True): + super(TableRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) if pretty_print: eol_ = '\n' else: eol_ = '' if self.Grid is not None: + namespaceprefix_ = self.Grid_nsprefix_ + ':' if (UseCapturedNS_ and self.Grid_nsprefix_) else '' self.Grid.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grid', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('rows', node) if value is not None and 'rows' not in already_processed: already_processed.add('rows') - try: - self.rows = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.rows = self.gds_parse_integer(value, node, 'rows') value = find_attr_value_('columns', node) if value is not None and 'columns' not in already_processed: already_processed.add('columns') - try: - self.columns = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.columns = self.gds_parse_integer(value, node, 'columns') value = find_attr_value_('lineColour', node) if value is not None and 'lineColour' not in already_processed: already_processed.add('lineColour') self.lineColour = value + self.validate_ColourSimpleType(self.lineColour) # validate type ColourSimpleType value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType value = find_attr_value_('lineSeparators', node) if value is not None and 'lineSeparators' not in already_processed: already_processed.add('lineSeparators') @@ -8890,35 +11134,55 @@ def buildAttributes(self, node, attrs, already_processed): else: raise_parse_error(node, 'Bad boolean attribute') super(TableRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'Grid': obj_ = GridType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.Grid = obj_ obj_.original_tagname_ = 'Grid' super(TableRegionType, self).buildChildren(child_, node, nodeName_, True) + def __hash__(self): + return hash(self.id) # end class TableRegionType class GraphicRegionType(RegionType): - """Regions containing simple graphics, such as a company logo, should - be marked as graphic regions. The angle the rectangle - encapsulating a region has to be rotated in clockwise direction - in order to correct the present skew (negative values indicate - anti-clockwise rotation). Range: -179.999,180 The type of - graphic in the region An approximation of the number of colours - used in the region Specifies whether the region also contains + """Regions containing simple graphics, such as a company + logo, should be marked as graphic regions. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The type of graphic in the region + An approximation of the number of colours + used in the region + Specifies whether the region also contains text.""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:GraphicsTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, embText=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, embText=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(GraphicRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.numColours = _cast(int, numColours) + self.numColours_nsprefix_ = None self.embText = _cast(bool, embText) + self.embText_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -8930,6 +11194,10 @@ def factory(*args_, **kwargs_): else: return GraphicRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -8946,6 +11214,19 @@ def get_embText(self): return self.embText def set_embText(self, embText): self.embText = embText + def validate_GraphicsTypeSimpleType(self, value): + # Validate type pc:GraphicsTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['logo', 'letterhead', 'decoration', 'frame', 'handwritten-annotation', 'stamp', 'signature', 'barcode', 'paper-grow', 'punch-hole', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GraphicsTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(GraphicRegionType, self).hasContent_() @@ -8953,7 +11234,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='GraphicRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GraphicRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphicRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -8961,8 +11242,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'GraphicRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -8974,48 +11257,48 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='GraphicRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphicRegionType'): super(GraphicRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.numColours is not None and 'numColours' not in already_processed: already_processed.add('numColours') outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours')) if self.embText is not None and 'embText' not in already_processed: already_processed.add('embText') outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True): - super(GraphicRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True): + super(GraphicRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('type', node) if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_GraphicsTypeSimpleType(self.type_) # validate type GraphicsTypeSimpleType value = find_attr_value_('numColours', node) if value is not None and 'numColours' not in already_processed: already_processed.add('numColours') - try: - self.numColours = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.numColours = self.gds_parse_integer(value, node, 'numColours') value = find_attr_value_('embText', node) if value is not None and 'embText' not in already_processed: already_processed.add('embText') @@ -9026,30 +11309,50 @@ def buildAttributes(self, node, attrs, already_processed): else: raise_parse_error(node, 'Bad boolean attribute') super(GraphicRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(GraphicRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class GraphicRegionType class LineDrawingRegionType(RegionType): - """A line drawing is a single colour illustration without solid areas. - The angle the rectangle encapsulating a region has to be rotated - in clockwise direction in order to correct the present skew - (negative values indicate anti-clockwise rotation). Range: - -179.999,180 The pen (foreground) colour of the region The - background colour of the region Specifies whether the region - also contains text""" + """A line drawing is a single colour illustration without + solid areas. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The pen (foreground) colour of the region + The background colour of the region + Specifies whether the region also contains + text""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('penColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, penColour=None, bgColour=None, embText=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, penColour=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(LineDrawingRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.penColour = _cast(None, penColour) + self.penColour_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None self.embText = _cast(bool, embText) + self.embText_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -9061,6 +11364,10 @@ def factory(*args_, **kwargs_): else: return LineDrawingRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -9077,6 +11384,19 @@ def get_embText(self): return self.embText def set_embText(self, embText): self.embText = embText + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(LineDrawingRegionType, self).hasContent_() @@ -9084,7 +11404,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='LineDrawingRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LineDrawingRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('LineDrawingRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -9092,8 +11412,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'LineDrawingRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -9105,45 +11427,49 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='LineDrawingRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LineDrawingRegionType'): super(LineDrawingRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.penColour is not None and 'penColour' not in already_processed: already_processed.add('penColour') - outfile.write(' penColour=%s' % (quote_attrib(self.penColour), )) + outfile.write(' penColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.penColour), input_name='penColour')), )) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) if self.embText is not None and 'embText' not in already_processed: already_processed.add('embText') outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True): - super(LineDrawingRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True): + super(LineDrawingRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('penColour', node) if value is not None and 'penColour' not in already_processed: already_processed.add('penColour') self.penColour = value + self.validate_ColourSimpleType(self.penColour) # validate type ColourSimpleType value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType value = find_attr_value_('embText', node) if value is not None and 'embText' not in already_processed: already_processed.add('embText') @@ -9154,30 +11480,50 @@ def buildAttributes(self, node, attrs, already_processed): else: raise_parse_error(node, 'Bad boolean attribute') super(LineDrawingRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(LineDrawingRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class LineDrawingRegionType class ImageRegionType(RegionType): - """An image is considered to be more intricate and complex than a - graphic. These can be photos or drawings. The angle the - rectangle encapsulating a region has to be rotated in clockwise - direction in order to correct the present skew (negative values - indicate anti-clockwise rotation). Range: -179.999,180 The - colour bit depth required for the region The background colour - of the region Specifies whether the region also contains text""" + """An image is considered to be more intricate and complex + than a graphic. These can be photos or drawings. + The angle the rectangle encapsulating a region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + The colour bit depth required for the region + The background colour of the region + Specifies whether the region also contains + text""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('colourDepth', 'pc:ColourDepthSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colourDepth=None, bgColour=None, embText=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colourDepth=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(ImageRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.colourDepth = _cast(None, colourDepth) + self.colourDepth_nsprefix_ = None self.bgColour = _cast(None, bgColour) + self.bgColour_nsprefix_ = None self.embText = _cast(bool, embText) + self.embText_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -9189,6 +11535,10 @@ def factory(*args_, **kwargs_): else: return ImageRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_orientation(self): return self.orientation def set_orientation(self, orientation): @@ -9205,6 +11555,32 @@ def get_embText(self): return self.embText def set_embText(self, embText): self.embText = embText + def validate_ColourDepthSimpleType(self, value): + # Validate type pc:ColourDepthSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['bilevel', 'greyscale', 'colour', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourDepthSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ColourSimpleType(self, value): + # Validate type pc:ColourSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( super(ImageRegionType, self).hasContent_() @@ -9212,7 +11588,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ImageRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ImageRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('ImageRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -9220,8 +11596,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'ImageRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -9233,45 +11611,49 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='ImageRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ImageRegionType'): super(ImageRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ImageRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.colourDepth is not None and 'colourDepth' not in already_processed: already_processed.add('colourDepth') - outfile.write(' colourDepth=%s' % (quote_attrib(self.colourDepth), )) + outfile.write(' colourDepth=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colourDepth), input_name='colourDepth')), )) if self.bgColour is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') - outfile.write(' bgColour=%s' % (quote_attrib(self.bgColour), )) + outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) if self.embText is not None and 'embText' not in already_processed: already_processed.add('embText') outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='ImageRegionType', fromsubclass_=False, pretty_print=True): - super(ImageRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) - def build(self, node): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ImageRegionType', fromsubclass_=False, pretty_print=True): + super(ImageRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('colourDepth', node) if value is not None and 'colourDepth' not in already_processed: already_processed.add('colourDepth') self.colourDepth = value + self.validate_ColourDepthSimpleType(self.colourDepth) # validate type ColourDepthSimpleType value = find_attr_value_('bgColour', node) if value is not None and 'bgColour' not in already_processed: already_processed.add('bgColour') self.bgColour = value + self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType value = find_attr_value_('embText', node) if value is not None and 'embText' not in already_processed: already_processed.add('embText') @@ -9282,61 +11664,112 @@ def buildAttributes(self, node, attrs, already_processed): else: raise_parse_error(node, 'Bad boolean attribute') super(ImageRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): super(ImageRegionType, self).buildChildren(child_, node, nodeName_, True) pass + def __hash__(self): + return hash(self.id) # end class ImageRegionType class TextRegionType(RegionType): - """Pure text is represented as a text region. This includes drop - capitals, but practically ornate text may be considered as a - graphic. The angle the rectangle encapsulating the region has to - be rotated in clockwise direction in order to correct the - present skew (negative values indicate anti-clockwise rotation). - (The rotated image can be further referenced via - “AlternativeImage”.) Range: -179.999,180 The nature of the text - in the region The degree of space in points between the lines of - text (line spacing) The direction in which text within lines - should be read (order of words and characters), in addition to - “textLineOrder”. The order of text lines within the block, in - addition to “readingDirection”. The angle the baseline of text - within the region has to be rotated (relative to the rectangle - encapsulating the region) in clockwise direction in order to - correct the present skew, in addition to “orientation” (negative - values indicate anti-clockwise rotation). Range: -179.999,180 - Defines whether a region of text is indented or not Text align - The primary language used in the region The secondary language - used in the region The primary script used in the region The - secondary script used in the region""" + """Pure text is represented as a text region. This includes + drop capitals, but practically ornate text may be + considered as a graphic. + The angle the rectangle encapsulating the region + has to be rotated in clockwise direction + in order to correct the present skew + (negative values indicate anti-clockwise rotation). + (The rotated image can be further referenced + via “AlternativeImage”.) + Range: -179.999,180 + The nature of the text in the region + The degree of space in points between the lines of + text (line spacing) + The direction in which text within lines + should be read (order of words and characters), + in addition to “textLineOrder”. + The order of text lines within the block, + in addition to “readingDirection”. + The angle the baseline of text within the region + has to be rotated (relative to the rectangle + encapsulating the region) in clockwise direction + in order to correct the present skew, + in addition to “orientation” + (negative values indicate anti-clockwise rotation). + Range: -179.999,180 + Defines whether a region of text is indented or not + Text align + The primary language used in the region + The secondary language used in the region + The primary script used in the region + The secondary script used in the region""" + __hash__ = GeneratedsSuper.__hash__ + member_data_items_ = [ + MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('type_', 'pc:TextTypeSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('leading', 'int', 0, 1, {'use': 'optional'}), + MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('readingOrientation', 'float', 0, 1, {'use': 'optional'}), + MemberSpec_('indented', 'boolean', 0, 1, {'use': 'optional'}), + MemberSpec_('align', 'pc:AlignSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional'}), + MemberSpec_('TextLine', 'TextLineType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextLine', 'type': 'TextLineType'}, None), + MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None), + MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None), + ] subclass = None superclass = RegionType - def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, leading=None, readingDirection=None, textLineOrder=None, readingOrientation=None, indented=None, align=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, production=None, TextLine=None, TextEquiv=None, TextStyle=None, **kwargs_): + def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, leading=None, readingDirection=None, textLineOrder=None, readingOrientation=None, indented=None, align=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, production=None, TextLine=None, TextEquiv=None, TextStyle=None, gds_collector_=None, **kwargs_): + self.gds_collector_ = gds_collector_ + self.gds_elementtree_node_ = None self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.ns_prefix_ = None super(TextRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion, **kwargs_) self.orientation = _cast(float, orientation) + self.orientation_nsprefix_ = None self.type_ = _cast(None, type_) + self.type__nsprefix_ = None self.leading = _cast(int, leading) + self.leading_nsprefix_ = None self.readingDirection = _cast(None, readingDirection) + self.readingDirection_nsprefix_ = None self.textLineOrder = _cast(None, textLineOrder) + self.textLineOrder_nsprefix_ = None self.readingOrientation = _cast(float, readingOrientation) + self.readingOrientation_nsprefix_ = None self.indented = _cast(bool, indented) + self.indented_nsprefix_ = None self.align = _cast(None, align) + self.align_nsprefix_ = None self.primaryLanguage = _cast(None, primaryLanguage) + self.primaryLanguage_nsprefix_ = None self.secondaryLanguage = _cast(None, secondaryLanguage) + self.secondaryLanguage_nsprefix_ = None self.primaryScript = _cast(None, primaryScript) + self.primaryScript_nsprefix_ = None self.secondaryScript = _cast(None, secondaryScript) + self.secondaryScript_nsprefix_ = None self.production = _cast(None, production) + self.production_nsprefix_ = None if TextLine is None: self.TextLine = [] else: self.TextLine = TextLine + self.TextLine_nsprefix_ = None if TextEquiv is None: self.TextEquiv = [] else: self.TextEquiv = TextEquiv + self.TextEquiv_nsprefix_ = None self.TextStyle = TextStyle + self.TextStyle_nsprefix_ = None def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -9348,14 +11781,16 @@ def factory(*args_, **kwargs_): else: return TextRegionType(*args_, **kwargs_) factory = staticmethod(factory) + def get_ns_prefix_(self): + return self.ns_prefix_ + def set_ns_prefix_(self, ns_prefix): + self.ns_prefix_ = ns_prefix def get_TextLine(self): return self.TextLine def set_TextLine(self, TextLine): self.TextLine = TextLine def add_TextLine(self, value): self.TextLine.append(value) - def add_TextLine(self, value): - self.TextLine.append(value) def insert_TextLine_at(self, index, value): self.TextLine.insert(index, value) def replace_TextLine_at(self, index, value): @@ -9366,8 +11801,6 @@ def set_TextEquiv(self, TextEquiv): self.TextEquiv = TextEquiv def add_TextEquiv(self, value): self.TextEquiv.append(value) - def add_TextEquiv(self, value): - self.TextEquiv.append(value) def insert_TextEquiv_at(self, index, value): self.TextEquiv.insert(index, value) def replace_TextEquiv_at(self, index, value): @@ -9428,6 +11861,97 @@ def get_production(self): return self.production def set_production(self, production): self.production = production + def validate_TextTypeSimpleType(self, value): + # Validate type pc:TextTypeSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['paragraph', 'heading', 'caption', 'header', 'footer', 'page-number', 'drop-capital', 'credit', 'floating', 'signature-mark', 'catch-word', 'marginalia', 'footnote', 'footnote-continued', 'endnote', 'TOC-entry', 'list-label', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ReadingDirectionSimpleType(self, value): + # Validate type pc:ReadingDirectionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_TextLineOrderSimpleType(self, value): + # Validate type pc:TextLineOrderSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_AlignSimpleType(self, value): + # Validate type pc:AlignSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['left', 'centre', 'right', 'justify'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on AlignSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_LanguageSimpleType(self, value): + # Validate type pc:LanguageSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ScriptSimpleType(self, value): + # Validate type pc:ScriptSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False + def validate_ProductionSimpleType(self, value): + # Validate type pc:ProductionSimpleType, a restriction on string. + if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) + return False + value = value + enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other'] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) + result = False def hasContent_(self): if ( self.TextLine or @@ -9438,7 +11962,7 @@ def hasContent_(self): return True else: return False - def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='TextRegionType', pretty_print=True): + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='TextRegionType', pretty_print=True): imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextRegionType') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ @@ -9446,8 +11970,10 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ eol_ = '\n' else: eol_ = '' - if self.original_tagname_ is not None: + if self.original_tagname_ is not None and name_ == 'TextRegionType': name_ = self.original_tagname_ + if UseCapturedNS_ and self.ns_prefix_: + namespaceprefix_ = self.ns_prefix_ + ':' showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() @@ -9459,23 +11985,23 @@ def export(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_ outfile.write('%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='pc:', name_='TextRegionType'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextRegionType'): super(TextRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextRegionType') if self.orientation is not None and 'orientation' not in already_processed: already_processed.add('orientation') outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (quote_attrib(self.type_), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) if self.leading is not None and 'leading' not in already_processed: already_processed.add('leading') outfile.write(' leading="%s"' % self.gds_format_integer(self.leading, input_name='leading')) if self.readingDirection is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') - outfile.write(' readingDirection=%s' % (quote_attrib(self.readingDirection), )) + outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), )) if self.textLineOrder is not None and 'textLineOrder' not in already_processed: already_processed.add('textLineOrder') - outfile.write(' textLineOrder=%s' % (quote_attrib(self.textLineOrder), )) + outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), )) if self.readingOrientation is not None and 'readingOrientation' not in already_processed: already_processed.add('readingOrientation') outfile.write(' readingOrientation="%s"' % self.gds_format_float(self.readingOrientation, input_name='readingOrientation')) @@ -9484,75 +12010,78 @@ def exportAttributes(self, outfile, level, already_processed, namespaceprefix_=' outfile.write(' indented="%s"' % self.gds_format_boolean(self.indented, input_name='indented')) if self.align is not None and 'align' not in already_processed: already_processed.add('align') - outfile.write(' align=%s' % (quote_attrib(self.align), )) + outfile.write(' align=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.align), input_name='align')), )) if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') - outfile.write(' primaryLanguage=%s' % (quote_attrib(self.primaryLanguage), )) + outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), )) if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed: already_processed.add('secondaryLanguage') - outfile.write(' secondaryLanguage=%s' % (quote_attrib(self.secondaryLanguage), )) + outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), )) if self.primaryScript is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') - outfile.write(' primaryScript=%s' % (quote_attrib(self.primaryScript), )) + outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), )) if self.secondaryScript is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') - outfile.write(' secondaryScript=%s' % (quote_attrib(self.secondaryScript), )) + outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), )) if self.production is not None and 'production' not in already_processed: already_processed.add('production') - outfile.write(' production=%s' % (quote_attrib(self.production), )) - def exportChildren(self, outfile, level, namespaceprefix_='pc:', namespacedef_='', name_='TextRegionType', fromsubclass_=False, pretty_print=True): - super(TextRegionType, self).exportChildren(outfile, level, namespaceprefix_, name_, True, pretty_print=pretty_print) + outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='TextRegionType', fromsubclass_=False, pretty_print=True): + super(TextRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) if pretty_print: eol_ = '\n' else: eol_ = '' for TextLine_ in self.TextLine: + namespaceprefix_ = self.TextLine_nsprefix_ + ':' if (UseCapturedNS_ and self.TextLine_nsprefix_) else '' TextLine_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextLine', pretty_print=pretty_print) for TextEquiv_ in self.TextEquiv: + namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else '' TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print) if self.TextStyle is not None: + namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else '' self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print) - def build(self, node): + def build(self, node, gds_collector_=None): + self.gds_collector_ = gds_collector_ + if SaveElementTreeNode: + self.gds_elementtree_node_ = node already_processed = set() + self.ns_prefix_ = node.prefix self.buildAttributes(node, node.attrib, already_processed) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self.buildChildren(child, node, nodeName_) + self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) return self def buildAttributes(self, node, attrs, already_processed): value = find_attr_value_('orientation', node) if value is not None and 'orientation' not in already_processed: already_processed.add('orientation') - try: - self.orientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (orientation): %s' % exp) + value = self.gds_parse_float(value, node, 'orientation') + self.orientation = value value = find_attr_value_('type', node) if value is not None and 'type' not in already_processed: already_processed.add('type') self.type_ = value + self.validate_TextTypeSimpleType(self.type_) # validate type TextTypeSimpleType value = find_attr_value_('leading', node) if value is not None and 'leading' not in already_processed: already_processed.add('leading') - try: - self.leading = int(value) - except ValueError as exp: - raise_parse_error(node, 'Bad integer attribute: %s' % exp) + self.leading = self.gds_parse_integer(value, node, 'leading') value = find_attr_value_('readingDirection', node) if value is not None and 'readingDirection' not in already_processed: already_processed.add('readingDirection') self.readingDirection = value + self.validate_ReadingDirectionSimpleType(self.readingDirection) # validate type ReadingDirectionSimpleType value = find_attr_value_('textLineOrder', node) if value is not None and 'textLineOrder' not in already_processed: already_processed.add('textLineOrder') self.textLineOrder = value + self.validate_TextLineOrderSimpleType(self.textLineOrder) # validate type TextLineOrderSimpleType value = find_attr_value_('readingOrientation', node) if value is not None and 'readingOrientation' not in already_processed: already_processed.add('readingOrientation') - try: - self.readingOrientation = float(value) - except ValueError as exp: - raise ValueError('Bad float/double attribute (readingOrientation): %s' % exp) + value = self.gds_parse_float(value, node, 'readingOrientation') + self.readingOrientation = value value = find_attr_value_('indented', node) if value is not None and 'indented' not in already_processed: already_processed.add('indented') @@ -9566,44 +12095,52 @@ def buildAttributes(self, node, attrs, already_processed): if value is not None and 'align' not in already_processed: already_processed.add('align') self.align = value + self.validate_AlignSimpleType(self.align) # validate type AlignSimpleType value = find_attr_value_('primaryLanguage', node) if value is not None and 'primaryLanguage' not in already_processed: already_processed.add('primaryLanguage') self.primaryLanguage = value + self.validate_LanguageSimpleType(self.primaryLanguage) # validate type LanguageSimpleType value = find_attr_value_('secondaryLanguage', node) if value is not None and 'secondaryLanguage' not in already_processed: already_processed.add('secondaryLanguage') self.secondaryLanguage = value + self.validate_LanguageSimpleType(self.secondaryLanguage) # validate type LanguageSimpleType value = find_attr_value_('primaryScript', node) if value is not None and 'primaryScript' not in already_processed: already_processed.add('primaryScript') self.primaryScript = value + self.validate_ScriptSimpleType(self.primaryScript) # validate type ScriptSimpleType value = find_attr_value_('secondaryScript', node) if value is not None and 'secondaryScript' not in already_processed: already_processed.add('secondaryScript') self.secondaryScript = value + self.validate_ScriptSimpleType(self.secondaryScript) # validate type ScriptSimpleType value = find_attr_value_('production', node) if value is not None and 'production' not in already_processed: already_processed.add('production') self.production = value + self.validate_ProductionSimpleType(self.production) # validate type ProductionSimpleType super(TextRegionType, self).buildAttributes(node, attrs, already_processed) - def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): if nodeName_ == 'TextLine': obj_ = TextLineType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextLine.append(obj_) obj_.original_tagname_ = 'TextLine' elif nodeName_ == 'TextEquiv': obj_ = TextEquivType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextEquiv.append(obj_) obj_.original_tagname_ = 'TextEquiv' elif nodeName_ == 'TextStyle': obj_ = TextStyleType.factory(parent_object_=self) - obj_.build(child_) + obj_.build(child_, gds_collector_=gds_collector_) self.TextStyle = obj_ obj_.original_tagname_ = 'TextStyle' super(TextRegionType, self).buildChildren(child_, node, nodeName_, True) + def __hash__(self): + return hash(self.id) # end class TextRegionType @@ -9630,7 +12167,26 @@ def get_root_tag(node): return tag, rootClass -def parse(inFileName, silence=False): +def get_required_ns_prefix_defs(rootNode): + '''Get all name space prefix definitions required in this XML doc. + Return a dictionary of definitions and a char string of definitions. + ''' + nsmap = { + prefix: uri + for node in rootNode.iter() + for (prefix, uri) in node.nsmap.items() + if prefix is not None + } + namespacedefs = ' '.join([ + 'xmlns:{}="{}"'.format(prefix, uri) + for prefix, uri in nsmap.items() + ]) + return nsmap, namespacedefs + + +def parse(inFileName, silence=False, print_warnings=True): + global CapturedNsmap_ + gds_collector = GdsCollector_() parser = None doc = parsexml_(inFileName, parser) rootNode = doc.getroot() @@ -9639,43 +12195,65 @@ def parse(inFileName, silence=False): rootTag = 'PcGts' rootClass = PcGts rootObj = rootClass.factory() - rootObj.build(rootNode) - # Enable Python to collect the space used by the DOM. - doc = None + rootObj.build(rootNode, gds_collector_=gds_collector) + CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) + if not SaveElementTreeNode: + doc = None + rootNode = None if not silence: sys.stdout.write('\n') rootObj.export( sys.stdout, 0, name_=rootTag, - namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', + namespacedef_=namespacedefs, pretty_print=True) + if print_warnings and len(gds_collector.get_messages()) > 0: + separator = ('-' * 50) + '\n' + sys.stderr.write(separator) + sys.stderr.write('----- Warnings -- count: {} -----\n'.format( + len(gds_collector.get_messages()), )) + gds_collector.write_messages(sys.stderr) + sys.stderr.write(separator) return rootObj -def parseEtree(inFileName, silence=False): +def parseEtree(inFileName, silence=False, print_warnings=True, + mapping=None, nsmap=None): parser = None doc = parsexml_(inFileName, parser) + gds_collector = GdsCollector_() rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: rootTag = 'PcGts' rootClass = PcGts rootObj = rootClass.factory() - rootObj.build(rootNode) + rootObj.build(rootNode, gds_collector_=gds_collector) # Enable Python to collect the space used by the DOM. - doc = None - mapping = {} - rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping) + if mapping is None: + mapping = {} + rootElement = rootObj.to_etree( + None, name_=rootTag, mapping_=mapping, nsmap_=nsmap) reverse_mapping = rootObj.gds_reverse_node_mapping(mapping) + if not SaveElementTreeNode: + doc = None + rootNode = None if not silence: content = etree_.tostring( rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8") - sys.stdout.write(content) + sys.stdout.write(str(content)) sys.stdout.write('\n') + if print_warnings and len(gds_collector.get_messages()) > 0: + separator = ('-' * 50) + '\n' + sys.stderr.write(separator) + sys.stderr.write('----- Warnings -- count: {} -----\n'.format( + len(gds_collector.get_messages()), )) + gds_collector.write_messages(sys.stderr) + sys.stderr.write(separator) return rootObj, rootElement, mapping, reverse_mapping -def parseString(inString, silence=False): +def parseString(inString, silence=False, print_warnings=True): '''Parse a string, create the object tree, and export it. Arguments: @@ -9686,39 +12264,58 @@ def parseString(inString, silence=False): ''' parser = None rootNode= parsexmlstring_(inString, parser) + gds_collector = GdsCollector_() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: rootTag = 'PcGts' rootClass = PcGts rootObj = rootClass.factory() - rootObj.build(rootNode) - # Enable Python to collect the space used by the DOM. + rootObj.build(rootNode, gds_collector_=gds_collector) + if not SaveElementTreeNode: + rootNode = None if not silence: sys.stdout.write('\n') rootObj.export( sys.stdout, 0, name_=rootTag, namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"') + if print_warnings and len(gds_collector.get_messages()) > 0: + separator = ('-' * 50) + '\n' + sys.stderr.write(separator) + sys.stderr.write('----- Warnings -- count: {} -----\n'.format( + len(gds_collector.get_messages()), )) + gds_collector.write_messages(sys.stderr) + sys.stderr.write(separator) return rootObj -def parseLiteral(inFileName, silence=False): +def parseLiteral(inFileName, silence=False, print_warnings=True): parser = None doc = parsexml_(inFileName, parser) + gds_collector = GdsCollector_() rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: rootTag = 'PcGts' rootClass = PcGts rootObj = rootClass.factory() - rootObj.build(rootNode) + rootObj.build(rootNode, gds_collector_=gds_collector) # Enable Python to collect the space used by the DOM. - doc = None + if not SaveElementTreeNode: + doc = None + rootNode = None if not silence: sys.stdout.write('#from ocrd_page_generateds import *\n\n') sys.stdout.write('import ocrd_page_generateds as model_\n\n') sys.stdout.write('rootObj = model_.rootClass(\n') rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) sys.stdout.write(')\n') + if print_warnings and len(gds_collector.get_messages()) > 0: + separator = ('-' * 50) + '\n' + sys.stderr.write(separator) + sys.stderr.write('----- Warnings -- count: {} -----\n'.format( + len(gds_collector.get_messages()), )) + gds_collector.write_messages(sys.stderr) + sys.stderr.write(separator) return rootObj @@ -9734,6 +12331,8 @@ def main(): #import pdb; pdb.set_trace() main() +RenameMappings_ = { +} __all__ = [ "AdvertRegionType", diff --git a/requirements_test.txt b/requirements_test.txt index c2cb72de1..9d421b070 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,5 +1,5 @@ pytest >= 4.0.0 -generateDS == 2.30.11 +generateDS == 2.35.18 coverage >= 4.5.2 sphinx codecov >= 2.0.15 diff --git a/tests/model/test_ocrd_page.py b/tests/model/test_ocrd_page.py index 7f53dff90..778ab3116 100644 --- a/tests/model/test_ocrd_page.py +++ b/tests/model/test_ocrd_page.py @@ -56,7 +56,7 @@ def test_to_xml(self): # with open('/tmp/test.xml', 'w') as f: # f.write(to_xml(self.pcgts)) self.assertIn(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15 http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15/pagecontent.xsd"', to_xml(self.pcgts)[:1000]) - self.assertIn('