def test_multiple(self): t = XSLTransformer(self.xsl_script) doc = t.transform(XMLFeatureInfoDoc.combine([ XMLFeatureInfoDoc(x) for x in [b'<a><b>ab</b></a>', b'<a><b>ab1</b><b>ab2</b><b>ab3</b></a>', b'<a><b>ab1</b><c>ac</c><b>ab2</b></a>', ]])) eq_(strip_whitespace(doc.as_string()), strip_whitespace(b''' <root> <foo>ab</foo> <foo>ab1</foo><foo>ab2</foo><foo>ab3</foo> <foo>ab1</foo><foo>ab2</foo> </root>''')) eq_(doc.info_type, 'xml')
def test_multiple(self): t = XSLTransformer(self.xsl_script) doc = t.transform( XMLFeatureInfoDoc.combine([ XMLFeatureInfoDoc(x) for x in [ b"<a><b>ab</b></a>", b"<a><b>ab1</b><b>ab2</b><b>ab3</b></a>", b"<a><b>ab1</b><c>ac</c><b>ab2</b></a>", ] ])) assert strip_whitespace(doc.as_string()) == strip_whitespace(b""" <root> <foo>ab</foo> <foo>ab1</foo><foo>ab2</foo><foo>ab3</foo> <foo>ab1</foo><foo>ab2</foo> </root>""") assert doc.info_type == "xml"
def test_combine_transform_xml(self, tmpdir): xsl = tmpdir.join("transform.xsl") xsl.write("""<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <root> <xsl:apply-templates select='/a/b'/> </root> </xsl:template> <xsl:template match="/a/b"> <foo><xsl:value-of select="text()" /></foo> </xsl:template> </xsl:stylesheet> """) transf = XSLTransformer(xsl.strpath) docs = [ XMLFeatureInfoDoc("<a><b>foo1</b></a>"), XMLFeatureInfoDoc("<a><b>foo2</b></a>"), ] result, infotype = combine_docs(docs, transf) assert b"""<root><foo>foo1</foo><foo>foo2</foo></root>""" == result assert infotype is None
def test_transformer(self): t = XSLTransformer(self.xsl_script) doc = t.transform(XMLFeatureInfoDoc('<a><b>Text</b></a>')) eq_(strip_whitespace(doc.as_string()), b'<root><foo>Text</foo></root>')
def test_transformer(self): t = XSLTransformer(self.xsl_script) doc = t.transform(XMLFeatureInfoDoc("<a><b>Text</b></a>")) assert strip_whitespace( doc.as_string()) == b"<root><foo>Text</foo></root>"