コード例 #1
0
ファイル: core.py プロジェクト: MechanisM/Telemeta
    def get_xml(self):
        """Return a string containing the XML representation of the collection 
        and related items
        """
        impl = getDOMImplementation()
        doc = impl.createDocument(None, "telemeta", None)
        coll_doc = self.collection.to_dom()
        coll_node = doc.documentElement.appendChild(coll_doc.documentElement)
        coll_doc.unlink()
        items_node_name = MediaItem.get_dom_name() + "List"
        items_node = doc.createElement(items_node_name)
        coll_node.appendChild(items_node)

        items = self.collection.items.all()
        for item in items:
            if item.file:
                item.file = self.__get_media_filename(item)
            item_doc = item.to_dom()
            items_node.appendChild(item_doc.documentElement)
            item_doc.unlink()
        doc.normalize()

        # libxml2 has prettier output than xml.dom:
        tree = libxml2.parseDoc(doc.toxml(encoding="utf-8"))
        doc.unlink()
        xml = unicode(tree.serialize(encoding="utf-8", format=1), "utf-8")
        tree.free()

        return xml
コード例 #2
0
ファイル: core.py プロジェクト: palsa/Telemeta
    def get_xml(self):
        """Return a string containing the XML representation of the collection 
        and related items
        """
        impl = getDOMImplementation()
        doc = impl.createDocument(None, "telemeta", None)
        coll_doc = self.collection.to_dom()
        coll_node = doc.documentElement.appendChild(coll_doc.documentElement)
        coll_doc.unlink()
        items_node_name = MediaItem.get_dom_name() + "List"
        items_node = doc.createElement(items_node_name)
        coll_node.appendChild(items_node)

        items = self.collection.items.all()
        for item in items:
            if item.file:
                item.file = self.__get_media_filename(item)
            item_doc = item.to_dom()
            items_node.appendChild(item_doc.documentElement)
            item_doc.unlink()
        doc.normalize()

        # libxml2 has prettier output than xml.dom:
        tree = libxml2.parseDoc(doc.toxml(encoding="utf-8"))
        doc.unlink()
        xml = unicode(tree.serialize(encoding="utf-8", format=1), "utf-8")
        tree.free()

        return xml
コード例 #3
0
ファイル: core.py プロジェクト: raoufCNRS/Telemeta
    def get_xml(self):
        """Return a string containing the XML representation of the collection
        and related items
        """
        impl = getDOMImplementation()
        doc = impl.createDocument(None, "telemeta", None)
        coll_doc = self.collection.to_dom()
        coll_node = doc.documentElement.appendChild(coll_doc.documentElement)
        coll_doc.unlink()
        items_node_name = MediaItem.get_dom_name() + "List"
        items_node = doc.createElement(items_node_name)
        coll_node.appendChild(items_node)

        items = self.collection.items.all()
        for item in items:
            if item.file:
                item.file = self.__get_media_filename(item)
            item_doc = item.to_dom()
            items_node.appendChild(item_doc.documentElement)
            item_doc.unlink()
        doc.normalize()

        return doc.toxml()
コード例 #4
0
ファイル: core.py プロジェクト: srcoria/Telemeta
    def get_xml(self):
        """Return a string containing the XML representation of the collection
        and related items
        """
        impl = getDOMImplementation()
        doc = impl.createDocument(None, "telemeta", None)
        coll_doc = self.collection.to_dom()
        coll_node = doc.documentElement.appendChild(coll_doc.documentElement)
        coll_doc.unlink()
        items_node_name = MediaItem.get_dom_name() + "List"
        items_node = doc.createElement(items_node_name)
        coll_node.appendChild(items_node)

        items = self.collection.items.all()
        for item in items:
            if item.file:
                item.file = self.__get_media_filename(item)
            item_doc = item.to_dom()
            items_node.appendChild(item_doc.documentElement)
            item_doc.unlink()
        doc.normalize()

        return doc.toxml()