Ejemplo n.º 1
0
            return StylesheetReader.fromUri(self, uri, baseUri, ownerDoc,
                                            stripElements)


if __name__ == "__main__":
    # the sample stylesheet repository
    internal_stylesheets = {
        'second-author.xsl':
        """
            <person xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
            <xsl:value-of select="books/book/author[2]"/>
            </person>
        """
    }

    # the sample document, referring to an "internal" stylesheet
    xmldoc = """
      <?xml-stylesheet href="internal:second-author.xsl" type="text/xml"?>
      <books>
        <book title="Python Essential Reference">
          <author>David M. Beazley</author>
          <author>Guido van Rossum</author>
        </book>
      </books>
    """

    # create XSLT processor and run it
    processor = Processor()
    processor.setStylesheetReader(StylesheetFromDict(internal_stylesheets))
    print processor.runString(xmldoc)