xml representation of the metadata.

        :return: xml representation of the metadata
        :rtype: ElementTree.Element
964805
def xml(self):
        
        tree = ElementTree.parse(METADATA_XML_TEMPLATE)
        root = tree.getroot()

        for name, prop in list(self.properties.items()):
            path = prop.xml_path
            elem = root.find(path, XML_NS)
            if elem is None:
                # create elem
                elem = insert_xml_element(root, path)
            elem.text = self.get_xml_value(name)

        return root
1294790
def toxml(self):
        

        return '<ComponentReference name="{0}" type="{1}"'.format(self.name, self.type) + \
          (' local = "{0}"'.format(self.local) if self.local else '') + \
            '/>'
599109
def to_dict(self):
        
        if not hasattr(self, '_fields'):
            return self.__dict__
        result = dict()
        for field_name, field in self._fields.items():
            if isinstance(field, xmlmap.NodeField):
                obj = getattr(self, field_name)
                if obj is None:
                    result[field_name] = None
                elif not hasattr(obj, 'to_dict'):
                    result[field_name] = obj.__dict__
                else:
                    result[field_name] = obj.to_dict()
            elif isinstance(field, xmlmap.NodeListField):
                objs = getattr(self, field_name)
                result[field_name] = list()
                for obj in objs:
                    if not hasattr(obj, 'to_dict'):
                        result[field_name].append(obj.__dict__)
                    else:
                        result[field_name].append(obj.to_dict())
            else:
                result[field_name] = getattr(self, field_name)
        return result
35193
def toxml(self):
        

        return '<ComponentRequirement name="{0}"'.format(self.name) + '' + \
            (' description = "{0}"'.format(self.description) if self.description else '') +\
            '/>'
38071
def update_xml_element(self):
        

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

        self.xml_element.set('system', str(self.system))
        self.xml_element.text = self.text

        return self.xml_element
540727
def xml(self):
        
        root = Element('Security', ns=wssens)
        root.set('mustUnderstand', str(self.mustUnderstand).lower())
        for t in self.tokens:
            root.append(t.xml())
        return root
1257654
def toXml(self, xparent):
        
        for key, value in self.items():
            elem = ElementTree.SubElement(xparent, 'entry')
            typ = type(elem).__name__

            elem.set('key', key)
            elem.set('type', typ)

            if typ in DataSet._xmlTypes:
                DataSet._xmlTypes[typ][0](elem, value)
            else:
                elem.set('value', nstr(value))
999691
def toxml(self):
        

        return '<Constant' +\
          (' name = "{0}"'.format(self.name) if self.name else '') +\
          (' symbol = "{0}"'.format(self.symbol) if self.symbol else '') +\
          (' value = "{0}"'.format(self.value) if self.value else '') +\
          (' dimension = "{0}"'.format(self.dimension) if self.dimension else '') +\
          (' description = "{0}"'.format(self.description) if self.description else '') +\
          '/>'
399121
def as_dict(self):
        

        element_dict = dict()
        if hasattr(self, 'namespace'):
            element_dict['namespace'] = self.namespace
        if hasattr(self, 'name'):
            element_dict['name'] = self.name
        if hasattr(self, 'text'):
            element_dict['text'] = self.text

        attr_dict = dict()
        for attr in self.attrs:
            if hasattr(self, attr):
                attr_dict[attr] = getattr(self, attr)
        element_dict['attrs'] = attr_dict

        return element_dict
1331119
def toxml(self):
        

        return '<With ' + \
          (' instance="{0}"'.format(self.instance) if self.instance else '') +\
          (' list="{0}"'.format(self.list) if self.list else '') + \
          (' index="{0}"'.format(self.index) if self.index else '') + \
          ' as="{1}"/>'.format(self.instance, self.as_)
837588
def to_etree(self):
        
        attribs = {
            '{{{pre}}}type'.format(pre=NAMESPACES['xsi']): self.xsi_type,
            'namespace': self.namespace, 'name': self.name,
            'value': self.hexvalue, 'valueString': self.value}
        non_empty_attribs = {key: val for (key, val) in attribs.items()
                             if val is not None}
        E = ElementMaker()
        return E('labels', non_empty_attribs)
77114
def metadata(self):
        
        if self._metadata is None:
            try:
                with open(self.paths.metadata()) as metadata_fd:
                    self._metadata = json.load(metadata_fd)
            except IOError:
                self._metadata = {}
        return self._metadata
372615
def toXml(self, xparent=None):
        
        if xparent is None:
            xml = ElementTree.Element('object')
        else:
            xml = ElementTree.SubElement(xparent, 'object')

        xml.set('class', self.__class__.__name__)
        for name, value in self._xmlData.items():
            xprop = ElementTree.SubElement(xml, 'property')
            xprop.set('name', name)
            XmlDataIO.toXml(value, xprop)
        return xml
88601
def _xml_to_dict(self, element):
        
        return_dict = {}
        for el in element:
            return_dict[el.tag] = None
            children = el.getchildren()
            if children:
                return_dict[el.tag] = self._xml_to_dict(children)
            else:
                return_dict[el.tag] = el.text
        return return_dict
229662
def xml(self):
        
        root = Element('UsernameToken', ns=wssens)
        u = Element('Username', ns=wssens)
        u.setText(self.username)
        root.append(u)
        p = Element('Password', ns=wssens)
        p.setText(self.password)
        if self.password_digest:
            p.set("Type", wsdigest)
            p.setText(self.password_digest)
        root.append(p)
        if self.nonce is not None:
            n = Element('Nonce', ns=wssens)
            if self.nonce_has_encoding:
                n.set("EncodingType", nonce_encoding_type)
            n.setText(self.nonce)
            root.append(n)
        if self.created is not None:
            n = Element('Created', ns=wsuns)
            n.setText(str(DateTime(self.created)))
            root.append(n)
        return root
567052
def xml(self):
        
        rels_elm = CT_Relationships.new()
        for rel in self.values():
            rels_elm.add_rel(
                rel.rId, rel.reltype, rel.target_ref, rel.is_external
            )
        return rels_elm.xml
280749
def pydict2xmlstring(metadata_dict, **kwargs):
    """"""
    ordering = kwargs.get('ordering', UNTL_XML_ORDER)
    root_label = kwargs.get('root_label', 'metadata')
    root_namespace = kwargs.get('root_namespace', None)
    elements_namespace = kwargs.get('elements_namespace', None)
    namespace_map = kwargs.get('namespace_map', None)
    root_attributes = kwargs.get('root_attributes', None)
    # Set any root namespace and namespace map.
    if root_namespace and namespace_map:
        root = Element(root_namespace + root_label, nsmap=namespace_map)
    elif namespace_map:
        root = Element(root_label, nsmap=namespace_map)
    else:
        root = Element(root_label)
    # Set any root element attributes.
    if root_attributes:
        for key, value in root_attributes.items():
            root.attrib[key] = value
    # Create an XML structure from field list.
    for metadata_key in ordering:
        if metadata_key in metadata_dict:
            for element in metadata_dict[metadata_key]:
                if 'content' in element and 'qualifier' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'qualifier': element['qualifier']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element and 'role' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'role': element['role']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element and 'scheme' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'scheme': element['scheme']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        namespace=elements_namespace,
                    )
    # Create the XML tree.
    return '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring(
        root,
        pretty_print=True
    )