Package pyxsd :: Package writers :: Module xmlTagWriter :: Class XmlTagWriter
[hide private]
[frames] | no frames]

Class XmlTagWriter

source code

object --+
         |
        XmlTagWriter

This class writes one element. Each tag has its own instance of this class. it contains a function to write the end tag if the element has children, but this function is called from the tree writer. See XmlTreeWriter for the API and other information. This class should only be initialized by XmlTreeWriter.

Instance Methods [hide private]
  __init__(self, name, attribs, value, hasChildren, hasValue, tabs, output)
Initializes the tag writer
  writeTag(self)
Writes the tag.
  writeComment(self)
If name is set to '_comment_' this function is called.
  writeEndTag(self)
Writes the ending tag for an element.
  writeTabs(self, tabSpec=None, tabs=None)
Writes out the tabs before an element.

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


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, name, attribs, value, hasChildren, hasValue, tabs, output)
(Constructor)

source code 

Initializes the tag writer

parameters:

  • name: A string of the name of the tag
  • attribs: A dictionary of the tag attributes
  • value: A list of the element values or None if there are no values
  • hasChildren: a boolean to indicate if the tag has children
  • hasValue: a boolean to indicate if the tag any value
  • tabs: an integer that indicates the number of tabs over the element is in the document
  • output: the file object to write to
Overrides: object.__init__

writeTag(self)

source code 

Writes the tag. Called from the init function. All its non-necessary formatting is standard and is not dependant apon specifics of the format of the data.

No parameters

writeComment(self)

source code 

If name is set to '_comment_' this function is called. A comment can be in the tree only if it is included in a transform or the writer is used by another program.

No parameters

writeEndTag(self)

source code 

Writes the ending tag for an element. Called by the tree writer if the element has children.
It is called only after the other children have been written.
An end tag appear as follows::
    </TagName>

no parameters

writeTabs(self, tabSpec=None, tabs=None)

source code 

Writes out the tabs before an element. Can also write a certain number of spaces after the tabs have been written, if tabSpec is specified.

parameters:

  • tabSpec: An integer. By default, it is a NoneType. If specified, the program will make the specified number of spaces after the tab it writes.
  • tabs: n integer that indicates the number of tabs over the element is in the document. By default, it is set to self.tabs, which is the tabs

value provided in the initialization.