[Petal] Petal alters XML as if it is XHTML

Peter Rabbitson rabbit at rabbit.us
Wed May 23 15:32:20 BST 2007


Hi,
I might be doing something wrong, but when explicitly feeding XML and 
outputting XML, the result has all self closing tags (e.g. <br />) split 
into two tags (e.g. <br></br>). How can I stop this from happening?

Here is a simple test script:

==============================================================
use warnings;
use strict;

use File::Spec::Functions qw/splitpath/;
use File::Temp ();
use Petal;

print "====\n$Petal::VERSION\n====\n\n";

my $fh = File::Temp->new or die "$@\n";

print $fh <<'EOD'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="generator" content="vi" />
		<title>Test Page</title>
	</head>

	<body>
		<p>Paragraph with a<br />break</p>
	</body>

</html>
EOD
;

my $petal = Petal->new (
     base_dir => (splitpath ($fh->filename))[1],
     file => (splitpath ($fh->filename))[2],
     input => 'XML',
     output => 'XML',
);

print $petal->process();
=============================================================

and here is the output I get:

=============================================================

====
2.19
====

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8"></meta>
		<meta content="vi" name="generator"></meta>
		<title>Test Page</title>
	</head>

	<body>
		<p>Paragraph with a<br></br>break</p>
	</body>

</html>
=============================================================


Thanks!

Peter


More information about the Petal mailing list