cvs: php-src /ext/xsl/tests prepare.inc xslt.xml xslt.xsl xslt001.phpt xslt002.phpt xslt003.phpt xslt004.phpt xslt005.phpt xslt006.phpt xslt007.phpt

From: Date: Mon, 27 Oct 2003 08:46:56 +0000
Subject: cvs: php-src /ext/xsl/tests prepare.inc xslt.xml xslt.xsl xslt001.phpt xslt002.phpt xslt003.phpt xslt004.phpt xslt005.phpt xslt006.phpt xslt007.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-24299@lists.php.net to get a copy of this message
chregu Mon Oct 27 03:46:56 2003 EDT Added files: /php-src/ext/xsl/tests prepare.inc xslt.xml xslt.xsl xslt001.phpt xslt002.phpt xslt003.phpt xslt004.phpt xslt005.phpt xslt006.phpt xslt007.phpt Log: some tests (test #3 is currently broken due to memleak, fix is on the way) Index: php-src/ext/xsl/tests/prepare.inc +++ php-src/ext/xsl/tests/prepare.inc <?php $dom = new domDocument; $dom->load(dirname(__FILE__)."/xslt.xml"); if(!$dom) { echo "Error while parsing the document\n"; exit; } $xsl = new domDocument; $xsl->load(dirname(__FILE__)."/xslt.xsl"); if(!$xsl) { echo "Error while parsing the document\n"; exit; } $proc = new xsltprocessor; if(!$xsl) { echo "Error while making xsltprocessor object\n"; exit; } ?> Index: php-src/ext/xsl/tests/xslt.xml +++ php-src/ext/xsl/tests/xslt.xml <?xml version='1.0' encoding="iso-8859-1" ?> <chapter language="en"> <title language="en">Title</title> <para language="ge"> <!-- comment --> <informaltable> <tgroup cols="3"> <tbody> <row> <entry>a1</entry> <entry morerows="1">b1</entry> <entry>c1</entry> </row> <row> <entry>a2</entry> <entry>c2</entry> </row> <row> <entry>ä3</entry> <entry>b3</entry> <entry>c3</entry> </row> </tbody> </tgroup> </informaltable> </para> </chapter> Index: php-src/ext/xsl/tests/xslt.xsl +++ php-src/ext/xsl/tests/xslt.xsl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Id: xslt.xsl,v 1.1 2003/10/27 08:46:55 chregu Exp $ --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" encoding="iso-8859-1" indent="no"/> <xsl:param name="foo" select="'bar'"/> <xsl:template match="/"> <html> <body> <xsl:value-of select="$foo"/><xsl:text> </xsl:text> <xsl:apply-templates select="/chapter/para/informaltable/tgroup/tbody/row"/> </body> </html> </xsl:template> <xsl:template match="row"> <xsl:for-each select="entry"> <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:for-each> <br/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> Index: php-src/ext/xsl/tests/xslt001.phpt +++ php-src/ext/xsl/tests/xslt001.phpt --TEST-- Test 1: Transform To XML String --FILE-- <?php echo "Test 1: Transform To XML String"; include("prepare.inc"); $proc->importStylesheet($xsl); print "\n"; print $proc->transformToXml($dom); print "\n"; --EXPECT-- Test 1: Transform To XML String <?xml version="1.0" encoding="iso-8859-1"?> <html><body>bar a1 b1 c1 <br/> a2 c2 <br/> ä3 b3 c3 <br/> </body></html> Index: php-src/ext/xsl/tests/xslt002.phpt +++ php-src/ext/xsl/tests/xslt002.phpt --TEST-- Test 2: Transform To HTML String --FILE-- <?php echo "Test 2: Transform To HTML String"; include("prepare.inc"); // changing output method to html $xp = new domxpath($xsl); $res = $xp->query("/xsl:stylesheet/xsl:output/@method"); if (count($res) != 1) { print "No or more than one xsl:output/@method found"; exit; } $res[0]->value = "html"; $proc->importStylesheet($xsl); print "\n"; print $proc->transformToXml($dom); print "\n"; --EXPECT-- Test 2: Transform To HTML String <html><body>bar a1 b1 c1 <br> a2 c2 <br> ä3 b3 c3 <br> </body></html> Index: php-src/ext/xsl/tests/xslt003.phpt +++ php-src/ext/xsl/tests/xslt003.phpt --TEST-- Test 1: Using Parameters --FILE-- <?php echo "Test 1: Using Parameters"; include("prepare.inc"); $proc->importStylesheet($xsl); $proc->setParameter( "", "foo","hello world"); print "\n"; print $proc->transformToXml($dom); print "\n"; --EXPECT-- Test 1: Transform To XML String <?xml version="1.0" encoding="iso-8859-1"?> <html><body>bar a1 b1 c1 <br/> a2 c2 <br/> a3 b3 c3 <br/> </body></html> Index: php-src/ext/xsl/tests/xslt004.phpt +++ php-src/ext/xsl/tests/xslt004.phpt --TEST-- Test 4: Checking UTF8 Output --FILE-- <?php echo "Test 4: Checking UTF8 Output"; include("prepare.inc"); $xp = new domxpath($xsl); $res = $xp->query("/xsl:stylesheet/xsl:output/@encoding"); if (count($res) != 1) { print "No or more than one xsl:output/@encoding found"; exit; } $res[0]->value = "utf-8"; $proc->importStylesheet($xsl); print "\n"; print $proc->transformToXml($dom); print "\n"; --EXPECT-- Test 4: Checking UTF8 Output <?xml version="1.0" encoding="utf-8"?> <html><body>bar a1 b1 c1 <br/> a2 c2 <br/> ä3 b3 c3 <br/> </body></html> Index: php-src/ext/xsl/tests/xslt005.phpt +++ php-src/ext/xsl/tests/xslt005.phpt --TEST-- Test 5: Checking Indent --FILE-- <?php echo "Test 5: Checking Indent"; include("prepare.inc"); $xp = new domxpath($xsl); $res = $xp->query("/xsl:stylesheet/xsl:output/@indent"); if (count($res) != 1) { print "No or more than one xsl:output/@indent found"; exit; } $res[0]->value = "yes"; $proc->importStylesheet($xsl); print "\n"; print $proc->transformToXml($dom); print "\n"; --EXPECT-- Test 5: Checking Indent <?xml version="1.0" encoding="iso-8859-1"?> <html> <body>bar a1 b1 c1 <br/> a2 c2 <br/> ä3 b3 c3 <br/> </body> </html> Index: php-src/ext/xsl/tests/xslt006.phpt +++ php-src/ext/xsl/tests/xslt006.phpt --TEST-- Test 6: Transform To Doc --FILE-- <?php echo "Test 6: Transform To Doc"; include("prepare.inc"); $proc->importStylesheet($xsl); print "\n"; $doc = $proc->transformToDoc($dom); print $doc->saveXML(); print "\n"; --EXPECT-- Test 6: Transform To Doc <?xml version="1.0" encoding="iso-8859-1"?> <html><body>bar a1 b1 c1 <br/> a2 c2 <br/> ä3 b3 c3 <br/> </body></html> Index: php-src/ext/xsl/tests/xslt007.phpt +++ php-src/ext/xsl/tests/xslt007.phpt --TEST-- Test 7: Transform To Uri --FILE-- <?php echo "Test 7: Transform To Uri"; include("prepare.inc"); $proc->importStylesheet($xsl); print "\n"; $doc = $proc->transformToUri($dom, "file://".dirname(__FILE__)."/out.xml"); print file_get_contents(dirname(__FILE__)."/out.xml"); unlink(dirname(__FILE__)."/out.xml"); print "\n"; --EXPECT-- Test 7: Transform To Uri <?xml version="1.0" encoding="iso-8859-1"?> <html><body>bar a1 b1 c1 <br/> a2 c2 <br/> ä3 b3 c3 <br/> </body></html>

« previous php.cvs (#24299) next »