Serialize this SubSection and all children to lxml Element and return it.

        :param str now: Default value for CREATED if none set
        :return: dmdSec/techMD/rightsMD/sourceMD/digiprovMD Element with all children
342240
def serialize(self, now=None):
        
        created = self.created if self.created is not None else now
        el = etree.Element(utils.lxmlns("mets") + self.subsection, ID=self.id_string)
        if created:  # Don't add CREATED if none was parsed
            el.set("CREATED", created)
        status = self.get_status()
        if status:
            el.set("STATUS", status)
        if self.contents:
            el.append(self.contents.serialize())
        return el
1109317
def serialize(self, q):
        
        children = []
        for child in q.children:
            if isinstance(child, Q):
                children.append(self.serialize(child))
            else:
                children.append(child)
        serialized = q.__dict__
        serialized['children'] = children
        return serialized
647201
def saveXml( self, xparent, item ):
        
        key = nativestring(unwrapVariant(item.data(0, Qt.UserRole)))
        
        if ( key == 'separator' ):
            ElementTree.SubElement(xparent, 'separator')
        elif ( key == 'menu' ):
            elem = ElementTree.SubElement(xparent, 'menu')
            elem.set('title', nativestring(item.text(0)))
            
            for c in range(item.childCount()):
                self.saveXml(elem, item.child(c))
        else:
            elem = ElementTree.SubElement(xparent, 'action')
            elem.set('name', key)
808758
def serialize(self, fully_qualified=True):
        
        now = datetime.utcnow().replace(microsecond=0).isoformat("T")
        files = self.all_files()
        mdsecs = self._collect_mdsec_elements(files)
        root = self._document_root(fully_qualified=fully_qualified)
        root.append(self._mets_header(now=now))
        for section in mdsecs:
            root.append(section.serialize(now=now))
        root.append(self._filesec(files))
        root.append(self._structmap())
        root.append(self._normative_structmap())
        return root
985087
def toxml(self):
        

        xmlstr = '<ComponentType name="{0}"'.format(self.name) +\
          (' extends="{0}"'.format(self.extends) if self.extends else '') +\
          (' description="{0}"'.format(self.description) if self.description else '')

        chxmlstr = ''

        for property in self.properties:
            chxmlstr += property.toxml()

        for parameter in self.parameters:
            chxmlstr += parameter.toxml()
            
        for derived_parameter in self.derived_parameters:
            chxmlstr += derived_parameter.toxml()
            
        for index_parameter in self.index_parameters:
            chxmlstr += index_parameter.toxml()

        for constant in self.constants:
            chxmlstr += constant.toxml()
            
        childxml = ''
        childrenxml = ''
        
        for children in self.children:
            if children.multiple:
                childrenxml += children.toxml()
            else:
                childxml += children.toxml()
            
        chxmlstr += childxml
        chxmlstr += childrenxml
            
        for link in self.links:
            chxmlstr += link.toxml()
            
        for component_reference in self.component_references:
            chxmlstr += component_reference.toxml()
            
        for attachment in self.attachments:
            chxmlstr += attachment.toxml()
            
        for event_port in self.event_ports:
            chxmlstr += event_port.toxml()
            
        for exposure in self.exposures:
            chxmlstr += exposure.toxml()
            
        for requirement in self.requirements:
            chxmlstr += requirement.toxml()
            
        for component_requirement in self.component_requirements:
            chxmlstr += component_requirement.toxml()
            
        for instance_requirement in self.instance_requirements:
            chxmlstr += instance_requirement.toxml()
            
        for path in self.paths:
            chxmlstr += path.toxml()
            
        for text in self.texts:
            chxmlstr += text.toxml()

        chxmlstr += self.dynamics.toxml()
        chxmlstr += self.structure.toxml()
        chxmlstr += self.simulation.toxml()
            
        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</ComponentType>'
        else:
            xmlstr += '/>'

        return xmlstr
839829
def raw(self, url, extra_headers=None, params=None):
        ''
        r = self.request(url, extra_headers=extra_headers, params=params)
        # uncomment to dump raw xml
#         with open('/tmp/%s.xml' % time.time(), 'wb') as f:
#             f.write(r.content)

        if not r.ok:
            o = lxml.objectify.fromstring(r.content)
            JFSError.raiseError(o, url)
        return r.content
861370
def to_xml(self):
        
        root = ET.Element("scheme")

        ET.SubElement(root, "title").text = self.title

        # add a description subelement if it's defined
        if self.description is not None:
            ET.SubElement(root, "description").text = self.description

        # add all other subelements to this Scheme, represented by (tag, text)
        subelements = [
            ("use_external_validation", self.use_external_validation),
            ("use_single_instance", self.use_single_instance),
            ("streaming_mode", self.streaming_mode)
        ]
        for name, value in subelements:
            ET.SubElement(root, name).text = str(value).lower()

        endpoint = ET.SubElement(root, "endpoint")

        args = ET.SubElement(endpoint, "args")

        # add arguments as subelements to the <args> element
        for arg in self.arguments:
            arg.add_to_document(args)

        return root
962082
def xml(self, attribs = None,elements = None, skipchildren = False):
        """"""
        E = ElementMaker(namespace=NSFOLIA,nsmap={None: NSFOLIA, 'xml' : "http://www.w3.org/XML/1998/namespace"})

        if not attribs: attribs = {}
        if not elements: elements = []

        if self.id:
            attribs['id'] = self.id
            try:
                w = self.doc[self.id]
                attribs['t'] = w.text()
            except KeyError:
                pass

        e  = makeelement(E, '{' + NSFOLIA + '}' + self.XMLTAG, **attribs)
        return e
921691
def update_xml_element(self):
        

        if not hasattr(self, 'xml_element'):
            self.xml_element = etree.Element(self.name, nsmap=NSMAP)

        self.xml_element.clear()
        self.xml_element.set('id', self.id)

        for child in self.children:
            child.update_xml_element()
            self.xml_element.append(child.xml_element)

        return self.xml_element
976130
def xpathNextChild(self, cur):
        
        if cur is None: cur__o = None
        else: cur__o = cur._o
        ret = libxml2mod.xmlXPathNextChild(self._o, cur__o)
        if ret is None:raise xpathError('xmlXPathNextChild() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
1005197
def to_xml(self):
        
        root = ET.Element("entry")
        for x in self.xml_tags:
            if getattr(self, x):
                if x in ['episodes', 'scores', 'status', 'dates', 'storage', 'rewatched', 'flags', 'tags']:
                    if x == 'episodes':
                        if self.episodes.current:
                            temp = ET.SubElement(root, 'episode')
                            temp.text = str(self.episodes.current)
                    elif x == 'scores':
                        if self.scores.user:
                            temp = ET.SubElement(root, 'score')
                            temp.text = str(self.scores.user)
                    elif x == 'status':
                        if self.status.user:
                            temp = ET.SubElement(root, 'status')
                            temp.text = str(self.status.user)
                    elif x == 'dates':
                        if self.dates.user.start:
                            start = ET.SubElement(root, 'date_start')
                            start.text = format_date(self.dates.user.start)
                        if self.dates.user.end:
                            end = ET.SubElement(root, 'date_finish')
                            end.text = format_date(self.dates.user.end)
                    elif x == 'storage':
                        if self.storage.type:
                            stype = ET.SubElement(root, 'storage_type')
                            stype.text = str(self.storage.type)
                        if self.storage.value:
                            sval = ET.SubElement(root, 'storage_value')
                            sval.text = str(self.storage.value)
                    elif x == 'rewatched':
                        if self.rewatched.times:
                            rt = ET.SubElement(root, 'times_rewatched')
                            rt.text = str(self.rewatched.times)
                        if self.rewatched.value:
                            rv = ET.SubElement(root, 'rewatch_value')
                            rv.text = str(self.rewatched.value)
                    elif x == 'flags':
                        if self.flags.discussion:
                            df = ET.SubElement(root, 'enable_discussion')
                            df.text = '1' if self.flags.discussion else '0'
                        if self.flags.rewatching:
                            rf = ET.SubElement(root, 'enable_rewatching')
                            rf.text = '1' if self.flags.rewatching else '0'
                    else:
                        if self.tags:
                            temp = ET.SubElement(root, 'tags')
                            temp.text = ','.join(self.tags)
                else:
                    temp = ET.SubElement(root, x)
                    temp.text = str(getattr(self, x))
        return '<?xml version="1.0" encoding="UTF-8"?>{}'.format(ET.tostring(root, encoding="unicode"))
513259
def _create_raw_data(self):
        
        result = {}
        for section in self.get_sections():
            result[section.get('id')] = 'all'
        return result
239671
def newDocFragment(self):
        
        ret = libxml2mod.xmlNewDocFragment(self._o)
        if ret is None:raise treeError('xmlNewDocFragment() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
1177198
def data(self, root, preserve_root=False):
        ''''''
        # If preserve_root is False, return the root element. This is easiest
        # done by wrapping the XML in a dummy root element that will be ignored.
        if preserve_root:
            new_root = root.makeelement('dummy_root', {})
            new_root.insert(0, root)
            root = new_root

        # If no children, just return the text
        children = [node for node in root if isinstance(node.tag, basestring)]
        if len(children) == 0:
            return self._fromstring(root.text)

        # Element names become object properties
        count = Counter(child.tag for child in children)
        result = self.dict()
        for child in children:
            if count[child.tag] == 1:
                result[child.tag] = self.data(child)
            else:
                result.setdefault(child.tag, self.list()).append(self.data(child))

        return result
221322
def xml
      h = Element.new('history')
      events.each do |event| h << event.xml end
      h
    end
700795
def saveXml(self, xml):
        
        lvls = []
        for logger, level in self.loggerLevels().items():
            lvls.append('{0}:{1}'.format(logger, level))
        
        xlevels = ElementTree.SubElement(xml, 'levels')
        xlevels.text = ','.join(map(str, self.activeLevels()))
        
        xloggerlevels = ElementTree.SubElement(xml, 'logger_levels')
        xloggerlevels.text = ','.join(lvls)
        
        xml.set('filter', wrapVariant(self.uiFilterTXT.text()))
        
        xtree = ElementTree.SubElement(xml, 'tree')
        self.uiRecordTREE.saveXml(xtree)
307325
def newDocText(self, content):
        
        ret = libxml2mod.xmlNewDocText(self._o, content)
        if ret is None:raise treeError('xmlNewDocText() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp