Wix: Registration form management (not finished yet)

- impoved xml conversion in xml_tools
This commit is contained in:
Goffi 2009-12-13 20:24:48 +11:00
commit 245325cea7

View file

@ -30,9 +30,20 @@ class XMLTools:
@staticmethod
def dataForm2xml(form):
"""Take a data form (xep-0004, Wokkel's implementation) and convert it to a SàT xml"""
result_xml = ["<form>", "</form>"]
impl = minidom.getDOMImplementation()
doc = impl.createDocument(None, "form", None)
top_element = doc.documentElement
#result_xml = ["<form>", "</form>"]
if form.instructions:
result_xml.insert(1,"<elem name='instructions' value='%s' type='text' />" % '\n'.join(form.instructions))
elem = doc.createElement('elem')
elem.setAttribute('name','instructions')
elem.setAttribute('type','text')
text = doc.createTextNode('\n'.join(form.instructions))
elem.appendChild(text)
top_element.appendChild(elem)
for field in form.fieldList:
if field.fieldType == 'text-single':
__field_type = "string"
@ -42,11 +53,14 @@ class XMLTools:
error (u"FIXME FIXME FIXME: Type [%s] is not managed yet by SàT" % field.fieldType)
__field_type = "string_field"
result_xml.insert(-1,"<elem name='%s' type='%s' label='%s'>" % (field.var, __field_type, field.label))
return '\n'.join(result_xml)
pdb.set_trace()
elem = doc.createElement('elem')
elem.setAttribute('name', field.var)
elem.setAttribute('type', __field_type)
elem.setAttribute('label', field.label)
#text = doc.createTextNode(field.value)
#elem.appendChild(text)
top_element.appendChild(elem)
result = doc.toxml()
doc.unlink()
return result