forked from pool/perl-XML-LibXSLT
67 lines
1.7 KiB
Diff
67 lines
1.7 KiB
Diff
![]() |
--- t/10functions.t
|
||
|
+++ t/10functions.t
|
||
|
@@ -1,5 +1,5 @@
|
||
|
use Test;
|
||
|
-BEGIN { plan tests => 33 }
|
||
|
+BEGIN { plan tests => 31 }
|
||
|
use XML::LibXSLT;
|
||
|
|
||
|
{
|
||
|
@@ -86,56 +86,6 @@
|
||
|
}
|
||
|
}
|
||
|
|
||
|
-{
|
||
|
- # testcase by Elizabeth Mattijsen
|
||
|
- my $parser = XML::LibXML->new;
|
||
|
- my $xsltproc = XML::LibXSLT->new;
|
||
|
-
|
||
|
- my $xml = $parser->parse_string( <<'XML' );
|
||
|
-<html><head/></html>
|
||
|
-XML
|
||
|
- my $xslt = $parser->parse_string( <<'XSLT' );
|
||
|
-<xsl:stylesheet
|
||
|
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||
|
- xmlns:foo="http://foo"
|
||
|
- version="1.0">
|
||
|
-<xsl:template match="/html">
|
||
|
- <html>
|
||
|
- <xsl:apply-templates/>
|
||
|
- </html>
|
||
|
-</xsl:template>
|
||
|
-<xsl:template match="/html/head">
|
||
|
- <head>
|
||
|
- <xsl:copy-of select="foo:custom()/foo"/>
|
||
|
- <xsl:apply-templates/>
|
||
|
- </head>
|
||
|
-</xsl:template>
|
||
|
-</xsl:stylesheet>
|
||
|
-XSLT
|
||
|
-
|
||
|
- my $aux = <<'XML';
|
||
|
-<bar>
|
||
|
- <y><foo>1st</foo></y>
|
||
|
- <y><foo>2nd</foo></y>
|
||
|
-</bar>
|
||
|
-XML
|
||
|
- {
|
||
|
- XML::LibXSLT->register_function(
|
||
|
- ('http://foo', 'custom') => sub { $parser->parse_string( $aux )->findnodes('//y') }
|
||
|
- );
|
||
|
- my $stylesheet = $xsltproc->parse_stylesheet($xslt);
|
||
|
- my $result = $stylesheet->transform($xml);
|
||
|
- ok ($result->serialize,qq(<?xml version="1.0"?>\n<html xmlns:foo="http://foo"><head><foo>1st</foo><foo>2nd</foo></head></html>\n));
|
||
|
- }
|
||
|
- {
|
||
|
- XML::LibXSLT->register_function(
|
||
|
- ('http://foo', 'custom') => sub { $parser->parse_string( $aux )->findnodes('//y')->[0]; });
|
||
|
- my $stylesheet = $xsltproc->parse_stylesheet($xslt);
|
||
|
- my $result = $stylesheet->transform($xml);
|
||
|
- ok ($result->serialize,qq(<?xml version="1.0"?>\n<html xmlns:foo="http://foo"><head><foo>1st</foo></head></html>\n));
|
||
|
- }
|
||
|
-}
|
||
|
-
|
||
|
{
|
||
|
my $parser = XML::LibXML->new;
|
||
|
my $xsltproc = XML::LibXSLT->new;
|