Package pyxb :: Package xmlschema :: Module structures :: Class SimpleTypeDefinition
[hide private]
[frames] | no frames]

Class SimpleTypeDefinition

source code

                       object --+                
                                |                
                          cscRoot --+            
                                    |            
 utils.utility.PrivateTransient_mixin --+        
                                        |        
                           object --+   |        
                                    |   |        
                              cscRoot --+        
                                        |        
     namespace._ComponentDependency_mixin --+    
                                            |    
                           object --+       |    
                                    |       |    
                              cscRoot --+   |    
                                        |   |    
namespace.archive._ArchivableObject_mixin --+    
                                            |    
                           object --+       |    
                                    |       |    
                              cscRoot --+   |    
                                        |   |    
     utils.utility.PrivateTransient_mixin --+    
                                            |    
                           object --+       |    
                                    |       |    
                              cscRoot --+   |    
                                        |   |    
            utils.utility.Locatable_mixin --+    
                                            |    
                       _SchemaComponent_mixin --+
                                                |
                           object --+           |
                                    |           |
                              cscRoot --+       |
                                        |       |
     utils.utility.PrivateTransient_mixin --+   |
                                            |   |
                               object --+   |   |
                                        |   |   |
                                  cscRoot --+   |
                                            |   |
                        _NamedComponent_mixin --+
                                                |
                               object --+       |
                                        |       |
                                  cscRoot --+   |
                                            |   |
       namespace.resolution._Resolvable_mixin --+
                                                |
                               object --+       |
                                        |       |
                                  cscRoot --+   |
                                            |   |
                             _Annotated_mixin --+
                                                |
                                               SimpleTypeDefinition
Known Subclasses:

An XMLSchema Simple Type Definition component.

Instance Methods [hide private]
 
baseTypeDefinition(self) source code
 
facets(self) source code
 
fundamentalFacets(self)
A frozenset of instances of facets.FundamentallFacet.
source code
 
_derivationAlternative(self) source code
 
variety(self) source code
 
primitiveTypeDefinition(self, throw_if_absent=True) source code
 
itemTypeDefinition(self) source code
 
memberTypeDefinitions(self) source code
frozenset
_bindingRequires_vx(self, include_lax)
Implement base class method.
source code
 
__init__(self, *args, **kw)
Initialize portions of a component.
source code
 
__setstate__(self, state)
Extend base class unpickle support to retain link between this instance and the Python class that it describes.
source code
 
__str__(self)
str(x)
source code
 
_updateFromOther_csc(self, other)
Override fields in this instance with those from the other.
source code
 
isBuiltin(self)
Indicate whether this simple type is a built-in type.
source code
 
__singleSimpleTypeChild(self, body, other_elts_ok=False) source code
 
__initializeFromList(self, body, **kw) source code
 
__initializeFromRestriction(self, body, **kw) source code
 
__initializeFromUnion(self, body, **kw) source code
 
__resolveBuiltin(self) source code
 
__defineDefaultFacets(self, variety)
Create facets for varieties that can take facets that are undeclared.
source code
 
__processHasFacetAndProperty(self, variety)
Identify the facets and properties for this stype.
source code
 
__updateFacets(self, body) source code
SimpleTypeDefinition
_createRestriction(self, owner, body)
Create a new simple type with this as its base.
source code
 
__completeResolution(self, body, variety, alternative) source code
 
isResolved(self)
Indicate whether this simple type is fully defined.
source code
 
_resolve(self)
Attempt to resolve the type.
source code
 
_setPythonSupport(self, python_support) source code
 
hasPythonSupport(self) source code
 
pythonSupport(self) source code
 
stringToPython(self, string) source code
 
pythonToString(self, value) source code

Inherited from _SchemaComponent_mixin: bestNCName, hasBinding, isTypeDefinition, isUrTypeDefinition, nameInBinding, owner, setNameInBinding

Inherited from namespace._ComponentDependency_mixin: bindingRequires

Inherited from _NamedComponent_mixin: __getnewargs__, __getstate__, bindingNamespace, expandedName, isAnonymous, isDerivationConsistent, isNameEquivalent, isTypeEquivalent, name, targetNamespace

Inherited from _Annotated_mixin: annotation

Inherited from _Annotated_mixin (private): _annotationFromDOM

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
 
_FinalToString(cls, final_value)
Convert a final value to a string.
source code
 
VarietyToString(cls, variety)
Convert a variety value to a string.
source code
 
SimpleUrTypeDefinition(cls, schema=None, in_builtin_definition=False)
Create the SimpleTypeDefinition instance that approximates the simple ur-type.
source code
 
_CreateXMLInstance(cls, name, schema)
Create STD instances for built-in types.
source code
 
CreatePrimitiveInstance(cls, name, schema, python_support)
Create a primitive simple type in the target namespace.
source code
 
CreateDerivedInstance(cls, name, schema, parent_std, python_support)
Create a derived simple type in the target namespace.
source code
 
CreateListInstance(cls, name, schema, item_std, python_support)
Create a list simple type in the target namespace.
source code
 
CreateUnionInstance(cls, name, schema, member_stds)
(Placeholder) Create a union simple type in the target namespace.
source code
 
CreateFromDOM(cls, node, **kw) source code
Static Methods [hide private]

Inherited from _NamedComponent_mixin: __new__

Class Variables [hide private]
  __baseTypeDefinition = None
hash(x)
  __memberTypes = None
hash(x)
  __itemTypeAttribute = None
hash(x)
  __baseAttribute = None
hash(x)
  __memberTypesAttribute = None
hash(x)
  __localFacets = None
hash(x)
  __facets = None
hash(x)
  __fundamentalFacets = None
hash(x)
  STD_empty = 0
  STD_extension = 1
  STD_list = 2
  STD_restriction = 4
  STD_union = 8
  _STD_Map = {'extension': 1, 'list': 2, 'restriction': 4, 'unio...
  __final = 0
  VARIETY_absent = 1
  VARIETY_atomic = 2
  VARIETY_list = 3
  VARIETY_union = 4
  _DA_empty = 'none specified'
  _DA_restriction = 'restriction'
  _DA_list = 'list'
  _DA_union = 'union'
  __derivationAlternative = None
hash(x)
  __variety = None
hash(x)
  __primitiveTypeDefinition = None
hash(x)
  __itemTypeDefinition = None
hash(x)
  __memberTypeDefinitions = None
hash(x)
  __domNode = None
hash(x)
  __isBuiltin = False
  __SimpleUrTypeDefinition = None
  __localMemberTypes = None
hash(x)
  __pythonSupport = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_bindingRequires_vx(self, include_lax)

source code 

Implement base class method.

This STD depends on its baseTypeDefinition, unless its variety is absent. Other dependencies are on item, primitive, or member type definitions.

Returns: frozenset
The component instances on which this component depends
Raises:
  • LogicError - A subclass failed to implement this method
Overrides: namespace._ComponentDependency_mixin._bindingRequires_vx

__init__(self, *args, **kw)
(Constructor)

source code 

Initialize portions of a component.

Parameters:
  • scope - The scope in which the component is defined
  • namespace_context - The NamespaceContext to use within this component
  • node - If no namespace_context is provided, a DOM node must be provided from which a namespace context can be identified.
  • owner - Reference to the component that owns this one (the immediately enclosing component). Is None in the case of top-level components.
  • schema - Reference to the Schema component to which the component belongs. Required for every component except Schema, Annotation, and Wildcard.
Overrides: object.__init__
(inherited documentation)

__setstate__(self, state)

source code 

Extend base class unpickle support to retain link between this instance and the Python class that it describes.

This is because the pythonSupport value is a class reference, not an instance reference, so it wasn't deserialized, and its class member link was never set.

Overrides: _NamedComponent_mixin.__setstate__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

_updateFromOther_csc(self, other)

source code 

Override fields in this instance with those from the other.

This method is invoked only by Schema._addNamedComponent, and then only when a built-in type collides with a schema-defined type. Material like facets is not (currently) held in the built-in copy, so the DOM information is copied over to the built-in STD, which is subsequently re-resolved.

Returns self.

Overrides: _Annotated_mixin._updateFromOther_csc

SimpleUrTypeDefinition(cls, schema=None, in_builtin_definition=False)
Class Method

source code 

Create the SimpleTypeDefinition instance that approximates the simple ur-type.

See section 3.14.7.

_CreateXMLInstance(cls, name, schema)
Class Method

source code 

Create STD instances for built-in types.

For example, xml:space is a restriction of NCName; xml:lang is a union.

CreatePrimitiveInstance(cls, name, schema, python_support)
Class Method

source code 

Create a primitive simple type in the target namespace.

This is mainly used to pre-load standard built-in primitive types, such as those defined by XMLSchema Datatypes. You can use it for your own schemas as well, if you have special types that require explicit support to for Pythonic conversion.

All parameters are required and must be non-None.

CreateDerivedInstance(cls, name, schema, parent_std, python_support)
Class Method

source code 

Create a derived simple type in the target namespace.

This is used to pre-load standard built-in derived types. You can use it for your own schemas as well, if you have special types that require explicit support to for Pythonic conversion.

CreateListInstance(cls, name, schema, item_std, python_support)
Class Method

source code 

Create a list simple type in the target namespace.

This is used to preload standard built-in list types. You can use it for your own schemas as well, if you have special types that require explicit support to for Pythonic conversion; but note that such support is identified by the item_std.

CreateUnionInstance(cls, name, schema, member_stds)
Class Method

source code 

(Placeholder) Create a union simple type in the target namespace.

This function has not been implemented.

__defineDefaultFacets(self, variety)

source code 

Create facets for varieties that can take facets that are undeclared.

This means unions, which per section 4.1.2.3 of http://www.w3.org/TR/xmlschema-2/ can have enumeration or pattern restrictions.

__processHasFacetAndProperty(self, variety)

source code 

Identify the facets and properties for this stype.

This method simply identifies the facets that apply to this specific type, and records property values. Only explicitly-associated facets and properties are stored; others from base types will also affect this type. The information is taken from the applicationInformation children of the definition's annotation node, if any. If there is no support for the XMLSchema_hasFacetAndProperty namespace, this is a no-op.

Upon return, self.__facets is a map from the class for an associated fact to None, and self.__fundamentalFacets is a frozenset of instances of FundamentalFacet.

The return value is self.

_createRestriction(self, owner, body)

source code 

Create a new simple type with this as its base.

The type is owned by the provided owner, and may have facet restrictions defined by the body.

Parameters:
  • owner (ComplexTypeDefinition) - the owner for the newly created type
  • body (xml.dom.Node) - the DOM node from which facet information will be extracted
Returns: SimpleTypeDefinition

isResolved(self)

source code 

Indicate whether this simple type is fully defined.

Type resolution for simple types means that the corresponding schema component fields have been set. Specifically, that means variety, baseTypeDefinition, and the appropriate additional fields depending on variety. See _resolve() for more information.

Overrides: namespace.resolution._Resolvable_mixin.isResolved

_resolve(self)

source code 

Attempt to resolve the type.

Type resolution for simple types means that the corresponding schema component fields have been set. Specifically, that means variety, baseTypeDefinition, and the appropriate additional fields depending on variety.

All built-in STDs are resolved upon creation. Schema-defined STDs are held unresolved until the schema has been completely read, so that references to later schema-defined STDs can be resolved. Resolution is performed after the entire schema has been scanned and STD instances created for all topLevelSimpleTypes.

If a built-in STD is also defined in a schema (which it should be for XMLSchema), the built-in STD is kept, with the schema-related information copied over from the matching schema-defined STD. The former then replaces the latter in the list of STDs to be resolved.

Types defined by restriction have the same variety as the type they restrict. If a simple type restriction depends on an unresolved type, this method simply queues it for resolution in a later pass and returns.

Returns:
self, whether or not resolution succeeds.
Raises:
Overrides: namespace.resolution._Resolvable_mixin._resolve

Class Variable Details [hide private]

_STD_Map

Value:
{'extension': 1, 'list': 2, 'restriction': 4, 'union': 8}