How to use the extruct.rdflibxml.utils.return_XML function in extruct

To help you get started, we’ve selected a few extruct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapinghub / extruct / extruct / rdflibxml / property.py View on Github external
def _get_XML_literal(self, Pnode) :
        """
        Get (recursively) the XML Literal content of a DOM Node.

        @param Pnode: DOM Node
        @return: string
        """
        rc = ""
        for node in Pnode.childNodes:
            if node.nodeType == Node.TEXT_NODE:
                rc = rc + self._putBackEntities(node.data)
            elif node.nodeType == Node.ELEMENT_NODE :
                rc = rc + return_XML(self.state, node, base = False)
        return rc
    # end getXMLLiteral
github scrapinghub / extruct / extruct / rdflibxml / property.py View on Github external
def _get_HTML_literal(self, Pnode) :
        """
        Get (recursively) the XML Literal content of a DOM Node.

        @param Pnode: DOM Node
        @return: string
        """
        rc = ""
        for node in Pnode.childNodes:
            if node.nodeType == Node.TEXT_NODE:
                rc = rc + self._putBackEntities(node.data)
            elif node.nodeType == Node.ELEMENT_NODE :
                rc = rc + return_XML(self.state, node, base = False, xmlns = False )
        return rc
    # end getHTMLLLiteral
github scrapinghub / extruct / extruct / rdflibxml / embeddedRDF.py View on Github external
if state.options.host_language in accept_embedded_turtle and node.nodeName.lower() == "script" :
            if node.hasAttribute("type") and node.getAttribute("type") == "text/turtle" :
                #prefixes = _get_prefixes_in_turtle()
                #content  = _get_literal(node)
                #rdf = StringIO(prefixes + content)
                content  = _get_literal(node)
                rdf = StringIO(content)
                try :
                    graph.parse(rdf, format="n3", publicID = state.base)
                    state.options.add_info("The output graph includes triples coming from an embedded Turtle script")
                except :
                    (type,value,traceback) = sys.exc_info()
                    state.options.add_error("Embedded Turtle content could not be parsed (problems with %s?); ignored" % value)
            return True
        elif state.options.host_language in accept_embedded_rdf_xml and node.localName == "RDF" and node.namespaceURI == "http://www.w3.org/1999/02/22-rdf-syntax-ns#" :
            rdf = StringIO(return_XML(state, node))
            try :
                graph.parse(rdf)
                state.options.add_info("The output graph includes triples coming from an embedded RDF/XML subtree")
            except :
                (type,value,traceback) = sys.exc_info()
                state.options.add_error("Embedded RDF/XML content could not parsed (problems with %s?); ignored" % value)
            return True
        else :
            return False
    else :
        return False