Package pyxslt :: Module names
[frames | no frames]

Module pyxslt.names

Convert Python class and property names to valid XML tag names.

This module is used by the serialize module as part of the object serialization process. The only real function of interest is pythonNameToXmlTag, which converts a Python class or attribute name to an XML tag name.

Author: Michael Alyn Miller <malyn@strangeGizmo.com>

Copyright: 2006 by Michael Alyn Miller

License: BSD License (see source code for full license)

Function Summary
  pythonNameToXmlTag(pythonName)
Convert a bumpyCase name to a hyphenated-tag name.

Function Details

pythonNameToXmlTag(pythonName)

Convert a bumpyCase name to a hyphenated-tag name.

Each word in the Python name should begin with a capital letter. The first word may be either lowercase or uppercase:
>>> pythonNameToXmlTag('attributeName')
'attribute-name'

>>> pythonNameToXmlTag('ClassName')
'class-name'
Words with all capital letters (i.e.: acronyms) will be properly separated:
>>> pythonNameToXmlTag('IPAddress')
'ip-address'

>>> pythonNameToXmlTag('aURL')
'a-url'

>>> pythonNameToXmlTag('thisURLAndStuff')
'this-url-and-stuff'
Single words will not be transformed:
>>> pythonNameToXmlTag('attribute')
'attribute'
Unless they are entirely in uppercase, in which case they will be converted to lowercase:
>>> pythonNameToXmlTag('URL')
'url'
Multiple acronyms are properly handled:
>>> pythonNameToXmlTag('oneURLAndAnotherURLAndAnother')
'one-url-and-another-url-and-another'
Single-letter words at the end of the string are O.K. as well:
>>> pythonNameToXmlTag('exhibitA')
'exhibit-a'

Generated by Epydoc 2.1 on Wed Jul 12 11:19:10 2006 http://epydoc.sf.net