pyxsd :: elementRepresentatives :: elementRepresentative :: ElementRepresentative :: Class ElementRepresentative
[hide private]
[frames] | no frames]

Class ElementRepresentative

source code

object --+
         |
        ElementRepresentative
Known Subclasses:
enumeration.Enumeration, length.Length, maxExclusive.MaxExclusive, maxInclusive.MaxInclusive, minExclusive.MinExclusive, minInclusive.MinInclusive, pattern.Pattern

ElementRepresentative is the base class for all of the tag type classes in the ElementRepresentative system, and it contains the methods that control movement around the tree. This class contains the most general ways to gather information from the schema.

Instance Methods [hide private]
  __init__(self, xsdElement, parent)
See the documentation for the ElementRepresentative system at the top of the ElementRepresentative module.
  __str__(self)
sets the str() function to print the ER information for a tag in the form: ClassName[TagName]
  processChildren(self)
Calls the factory on all of the children of an element.
  describe(self)
A debugging function that prints out the contents of the dictionary.
  findLayerNum(self)
Called by the ER __init__.
  checkTopLevelType(self)
Checks to see if an element is at the top-level.
  addSuperClassName(self, name)
Adds a base class name to containing type for a particular element.
  getContainingType(self)
Returns the parent's getContainingType() function.
  getSchema(self)
This method returns the parent's getSchema() function.
  getContainingTypeName(self)
Returns the name of the containingType.
  getName(self)
Returns the name field in the ElementTree element.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__


Class Methods [hide private]
  factory(cls, xsdElement, parent)
A classmethod.
  typeFromName(cls, xsdTypeName, pyXSD)
A classmethod.
  register(cls, name, obj)
The registry stores all ER objs in a dictionary with their name as a key.
  getFromName(cls, name)
Retrieve an entry in the registry by its name.
  classNameFor(cls, xsdElement, parent)
returns the name of the class that the factory should find.

Static Methods [hide private]
  tryConvert(variable)
Tries to convert a variable from a string in the xsd to a python value.

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, xsdElement, parent)
(Constructor)

source code 
See the documentation for the ElementRepresentative system at the top of the ElementRepresentative module.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
sets the str() function to print the ER information for a tag in the form: ClassName[TagName]
Overrides: object.__str__

processChildren(self)

source code 

Calls the factory on all of the children of an element.

No parameters.

factory(cls, xsdElement, parent)
Class Method

source code 

A classmethod. Initializes the tag-specific class for a particular ElementTree schema element. See the ER system documentation.

usage: ElementRepresentative.factory(xsdElement, parent)

Parameters:

  • cls- The class to operate under (this method is a classmethod). Normally just ElementRepresentative.
  • xsdElement- the ElementTree element that is being converted to an ER
  • parent- the parent ER for the tag being processed. 'None' when being called on the root schema element.

describe(self)

source code 

A debugging function that prints out the contents of the dictionary.

No parameters

findLayerNum(self)

source code 
Called by the ER __init__. Returns an integer tha specifies how deep in the tree a particular element is. The schema element, which is the root element, is '1'.

checkTopLevelType(self)

source code 

Checks to see if an element is at the top-level. Returns True if it is, False if it is not. The top level elements are all the children of the root Schema tag.

No parameters

typeFromName(cls, xsdTypeName, pyXSD)
Class Method

source code 

A classmethod. Used with the clsFor() function in xsdDataType. Returns a schema type given the type's name. Returns data type classes from xsdDataTypes for primitive data types. Calls clsFor on ERs.

Parameters:

  • cls- The class that it is working with (it is a classmethod). Usually ElementRepresentative.
  • xsdTypeName- the name of the type to be returned
  • pyXSD- the instance of the PyXSD class. Included so it can be used as an argument with the clsFor() method. See clsFor() in XsdType for more information.

addSuperClassName(self, name)

source code 

Adds a base class name to containing type for a particular element. Calls come from Restiction and Extension.

Parameters:

  • name- the name of the base class to add to the base class list

getContainingType(self)

source code 

Returns the parent's getContainingType() function. If this function is being called from schema, an error is returned. This method is one of a few getContaingType() functions. When a function is a containing type, the function should return that ER.

No parameters.

getSchema(self)

source code 

This method returns the parent's getSchema() function. getSchema() should return the containing instance when it is a schema tag from the getSchema() function in the schema class.

No parameters

getContainingTypeName(self)

source code 

Returns the name of the containingType.

No parameters.

getName(self)

source code 

Returns the name field in the ElementTree element. One of many getName() function.

No parameters.

register(cls, name, obj)
Class Method

source code 

The registry stores all ER objs in a dictionary with their name as a key. This is why all names must be unique. Helps find objs. A classmethod, but could be changed to staticmethod.

Parameters:

  • cls- The class that is being used (classmethod). Usually Element Representative
  • name- The name of the ER obj.
  • obj- The ER obj.

getFromName(cls, name)
Class Method

source code 

Retrieve an entry in the registry by its name. A classmethod, but could be staticmethod.

Parameters:

  • cls- The class that is being used (classmethod). Usually Element Representative
  • name- The name of the ER obj.

tryConvert(variable)
Static Method

source code 

Tries to convert a variable from a string in the xsd to a python value. Returns the entry if it cannot be converted.

Parameters:

  • variable- the value of a variable that the method is trying to convert.

classNameFor(cls, xsdElement, parent)
Class Method

source code 

returns the name of the class that the factory should find. A classmethod.

usage: ElementRepresentative.classNameFor(xsdElement, parent)

Parameters:

  • cls- The class to operate under (this method is a classmethod). Comes from factory
  • xsdElement- the ElementTree element that is being converted to an ER
  • parent- the parent ER for the tag being processed. 'None' when being called on the root schema element.