def toXML(self, owner): '''Yield this query as an XML DOM. ''' query = owner.createElement('query') query.appendChild(self.header.toXML(owner)) xmlutils.add(query, u'queryResultModeId', self.resultModeID) xmlutils.add(query, u'queryPropogationType', self.propType) xmlutils.add(query, u'queryPropogationLevels', self.propLevels) for mimeType in self.mimeAccept: xmlutils.add(query, u'queryMimeAccept', mimeType) xmlutils.add(query, u'queryMaxResults', str(self.maxResults)) xmlutils.add(query, u'queryKWQString', self.keywordQuery) selects = owner.createElement(u'querySelectSet') query.appendChild(selects) for select in self.selects: selects.appendChild(select.toXML(owner)) fromElement = owner.createElement(u'queryFromSet') query.appendChild(fromElement) for i in self.froms: fromElement.appendChild(i.toXML(owner)) wheres = owner.createElement(u'queryWhereSet') query.appendChild(wheres) for where in self.wheres: wheres.appendChild(where.toXML(owner)) query.appendChild(self.resultSet.toXML(owner)) return query
def toXML(self, owner): '''Convert this object into XML owned by the given `owner` document. ''' root = owner.createElement('profElement') xmlutils.add(root, u'elemId', self.name) xmlutils.add(root, u'elemName', self.name) xmlutils.add(root, u'elemDesc', self.description) xmlutils.add(root, u'elemType', self.type) xmlutils.add(root, u'elemUnit', self.units) if self.isEnumerated(): flag = 'T' else: flag = 'F' xmlutils.add(root, u'elemEnumFlag', flag) for value in self.getValues(): elem = owner.createElement('elemValue') root.appendChild(elem) elem.appendChild(owner.createCDATASection(value)) if not self.isEnumerated(): xmlutils.add(root, u'elemMinValue', str(self.getMinValue())) xmlutils.add(root, u'elemMaxValue', str(self.getMaxValue())) xmlutils.add(root, u'elemSynonym', self.synonyms) xmlutils.add(root, u'elemComment', self.comment) return root