Updates the xml element contents to matches the instance contents.

        :returns: Updated XML element.
        :rtype: lxml.etree._Element
349615
def update_xml_element(self):
        

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

        if hasattr(self, 'idref'):
            self.xml_element.set('idref', self.idref)

        return self.xml_element
681710
def xpathNewContext(self):
        
        ret = libxml2mod.xmlXPathNewContext(self._o)
        if ret is None:raise xpathError('xmlXPathNewContext() failed')
        __tmp = xpathContext(_obj=ret)
        return __tmp
1073915
def lxml(self) -> HtmlElement:
        
        if self._lxml is None:
            try:
                self._lxml = soup_parse(self.html, features='html.parser')
            except ValueError:
                self._lxml = lxml.html.fromstring(self.raw_html)

        return self._lxml
1076941
def xml(self) -> _BaseXML:
        
        if self._xml:
            return self.raw_xml.decode(self.encoding)
        else:
            return etree.tostring(self.element, encoding='unicode').strip()
376054
def update(self, use_template=False, **metadata_defaults):
        

        self.validate()

        tree_to_update = self._xml_tree if not use_template else self._get_template(**metadata_defaults)
        supported_props = self._metadata_props

        # Iterate over keys, and extract non-primitive root for all XPATHs
        #    xroot = identificationInfo/MD_DataIdentification/abstract/
        #    xpath = identificationInfo/MD_DataIdentification/abstract/CharacterString
        #
        # This prevents multiple primitive tags from being inserted under an element

        for prop, xpath in iteritems(self._data_map):
            if not prop.startswith('_') or prop.strip('_') in supported_props:
                # Send only public or alternate properties
                xroot = self._trim_xpath(xpath, prop)
                values = getattr(self, prop, u'')
                update_property(tree_to_update, xroot, xpath, prop, values, supported_props)

        return tree_to_update
1252323
def get_values(self):
        
        elements_selected = {}
        for index in range(self.tree_loaded_model.rowCount()):
            element_name = str(self.tree_loaded_model.item(index).text())
            if element_name in self.elements_old:
                elements_selected.update({element_name: self.elements_old[element_name]})
            elif element_name in self.elements_from_file:
                elements_selected.update({element_name: self.elements_from_file[element_name]})


        return elements_selected
414077
def import_element(self, xml_element):
        

        self.xml_element = xml_element

        uri, tag = Element.get_namespace_and_tag(self.xml_element.tag)
        self.namespace = uri
        self.name = tag

        self.load_xml_attrs()

        if self.xml_element.text is None:
            self.text = ''
        else:
            self.text = self.xml_element.text
171066
def update(self):
        """"""
        response = self.jss.session.post(self.url, data=self.auth)
        response_xml = ElementTree.fromstring(response.text.encode("utf_8"))

        # Remove previous data, if any, and then add in response's XML.
        self.clear()
        for child in response_xml.getchildren():
            self.append(child)
871593
def update_xml_element(self):
        

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

        self.xml_element.clear()

        if hasattr(self, 'abstract'):
            self.xml_element.set('abstract', self.abstract)
        if hasattr(self, 'prohibitChanges'):
            self.xml_element.set('prohibitChanges', self.prohibitChanges)
        self.xml_element.set('id', self.id)

        for child in self.children:
            if hasattr(child, 'update_xml_element'):
                child.update_xml_element()
                if hasattr(child, 'xml_element'):
                    self.xml_element.append(child.xml_element)

        return self.xml_element
740379
def _update_complex(self, **update_props):
        

        prop = update_props['prop']
        xpath_root = self._get_xroot_for(prop)
        xpath_map = self._data_structures[prop]

        return update_complex(xpath_root=xpath_root, xpath_map=xpath_map, **update_props)
327354
def update_xml_element(self):
        

        super(Description, self).update_xml_element()

        if hasattr(self, 'lang'):
            self.xml_element.set(
                '{http://www.w3.org/XML/1998/namespace}lang', self.lang)
        if hasattr(self, 'override'):
            self.xml_element.set('override', str(self.override))

        return self.xml_element
704861
def update_instance(self):
        """"""

        # NOTE: django model form has a save method - not applicable here,
        # since an XmlObject by itself is not expected to have a save method
        # (only likely to be saved in context of a fedora or exist object)

        if hasattr(self, 'cleaned_data'):   # possible to have an empty object/no data

            opts = self._meta

            # NOTE: _fields doesn't seem to order, which is
            # problematic for some xml (e.g., where order matters for validity)

            # use field order as declared in the form for update order
            # when possible.
            # (NOTE: this could be problematic also, since display order may
            # not always be the same as schema order)
            fields_in_order = []
            if hasattr(self.Meta, 'fields'):
                fields_in_order.extend(self.Meta.fields)
                fields_in_order.extend([name for name in six.iterkeys(self.instance._fields)
                                        if name in self.Meta.fields])
            else:
                fields_in_order = self.instance._fields.keys()

            for name in fields_in_order:
            # for name in self.instance._fields.iterkeys():
            # for name in self.declared_fields.iterkeys():
                if opts.fields and name not in opts.parsed_fields.fields:
                    continue
                if opts.exclude and name in opts.parsed_exclude.fields:
                    continue
                if name in self.cleaned_data:
                    # special case: we don't want empty attributes and elements
                    # for fields which returned no data from the form
                    # converting '' to None and letting XmlObject handle
                    if self.cleaned_data[name] == '':
                        self.cleaned_data[name] = None
                    setattr(self.instance, name, self.cleaned_data[name])

            # update sub-model portions via any subforms
            for name, subform in six.iteritems(self.subforms):
                self._update_subinstance(name, subform)
            for formset in six.itervalues(self.formsets):
                formset.update_instance()
        return self.instance
464343
def update_DOM(self):
        
        response = self.fetch()
        self._DOM = html.fromstring(response.text)
        return self
150505
def update(self, E=None, **F):
        
        _AutoDict = self.__class__

        def update_or_set(key, value):
            if isinstance(value, dict):
                self[key] = _AutoDict(obj=value, _root=self._root, _parent=self, _key=key)
            else:
                self[key] = value

        with self.lock() as lock_owner:
            # update E
            if hasattr(E, 'keys') and callable(E.keys):
                for k in E:
                    update_or_set(k, E[k])
            else:
                for k, v in E:
                    update_or_set(k, v)

            # update F
            for k in F:
                update_or_set(k, F[k])

            # save if original caller.
            if lock_owner:
                self._root.save()
395366
def element_to_extension_element(element):
    

    exel = ExtensionElement(element.c_tag, element.c_namespace,
                            text=element.text)

    exel.attributes.update(element.extension_attributes)
    exel.children.extend(element.extension_elements)

    for xml_attribute, (member_name, typ, req) in \
            iter(element.c_attributes.items()):
        member_value = getattr(element, member_name)
        if member_value is not None:
            exel.attributes[xml_attribute] = member_value

    exel.children.extend([element_to_extension_element(c) for c in
                          element.children_with_values()])

    return exel
706922
def assign_dict(self, node, xml_dict):
        
        new_node = etree.Element(node.tag)

        # Replaces the previous node with the new one
        self._xml.replace(node, new_node)

        # Copies #text and @attrs from the xml_dict
        helpers.dict_to_etree(xml_dict, new_node)
98258
def saveXml(self, xml):
        
        xscript = ElementTree.SubElement(xml, 'script')
        xscript.text = escape(self._edit.toPlainText())