Confusing message when using XML::Writer module in Perl

D

David McBride

I'm getting the following message when I run my Perl script that uses
the XML::Writer module:

"Processing instruction target begins with 'xml' at
.../makeconf/LW/LWTest.pm line 75"

The pi() statement is almost identical to the example for the module
at cpan.org. In fact, I tried replacing my use with the example and
got the same result. Can anyone tell me why I'm getting this warning,
even though I'm getting the correct output?

Here is the code snippet where I'm using XML::Writer:

###BEGIN SNIP
my $output = new IO::File(">$out_file_path");
my $writer = new XML::Writer( OUTPUT => $output, DATA_MODE => 1,
DATA_INDENT => 4 );

$writer->xmlDecl( 'ISO-8859-1', 'yes' );
$writer->pi('xml-stylesheet', 'type="text/xsl" href="LW_Test.xsl"');
#line 75
$writer->startTag( 'testcase' );
$writer->dataElement( "name", $test_case_name);
$writer->dataElement( "timestamp", $test_case_timestamp);
$writer->dataElement( "overview", $test_case_overview);

foreach(@conditions) {
my $cond_id = LW::TestCondition->getConditionID($_);
my $cond_comp = LW::TestCondition->getConditionComp($_);
my $cond_pass_fail = LW::TestCondition->getConditionPassFail($_);
my $cond_pass_desc = LW::TestCondition->getConditionDesc($_);
my $cond_err_msg = LW::TestCondition->getConditionErrMsg($_);

$writer->startTag( 'condition', 'id' => $cond_id,
'completed' => $cond_comp,
'pass_fail' => $cond_pass_fail);

$writer->dataElement( "description", $cond_pass_desc);
$writer->dataElement( "err_msg", $cond_err_msg);
$writer->endTag( 'condition' );
}

$writer->endTag( 'testcase' );
###END SNIP

The output file looks like this (which is what I wanted):

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<?xml-stylesheet href="style.css" type="text/css"?>

<testcase>
<name>my test case</name>
<timestamp>Tue Sep 30 11:19:55 2003</timestamp>
<overview>text containing many wise and wonderful
things</overview>
<condition id="1" completed="yes" pass_fail="pass">
<description>this is the description for condition
1</description>
<err_msg>none</err_msg>
</condition>
<condition id="2" completed="no" pass_fail="fail">
<description>this is the description for condition
2</description>
<err_msg>condition 1 failed</err_msg>
</condition>
<condition id="3" completed="yes" pass_fail="pass">
<description>this is the description for condition
3</description>
<err_msg>none</err_msg>
</condition>
<condition id="4" completed="yes" pass_fail="fail">
<description>this is the description for condition
4</description>
<err_msg>files not the same</err_msg>
</condition>
</testcase>
 
D

David Megginson

The pi() statement is almost identical to the example for the module
at cpan.org. In fact, I tried replacing my use with the example and
got the same result. Can anyone tell me why I'm getting this warning,
even though I'm getting the correct output?

Because the XML-Writer module is getting a little old, and I haven't
been maintaining it actively. This recommendation

http://www.w3.org/TR/xml-stylesheet/

did not exist (or at least, wasn't a REC) when I wrote the module, and
the XML spec reserves PI's starting with "xml". I seem to remember
that there was a way to disable this kind of strict checking, but I
haven't look at the code for a few years.


All the best,


David
 
D

David McBride

David Megginson said:
Because the XML-Writer module is getting a little old, and I haven't
been maintaining it actively. This recommendation

http://www.w3.org/TR/xml-stylesheet/

did not exist (or at least, wasn't a REC) when I wrote the module, and
the XML spec reserves PI's starting with "xml". I seem to remember
that there was a way to disable this kind of strict checking, but I
haven't look at the code for a few years.


All the best,


David


David,

Thanks for responding.

According to the documentation, strict checking can be turned off by
using "UNSAFE" as follows:

my $writer = new XML::Writer( OUTPUT => $output, DATA_MODE => 1,
DATA_INDENT => 4, UNSAFE => 1);

I didn't quite understand your statement, though:
... This recommendation

http://www.w3.org/TR/xml-stylesheet/

did not exist (or at least, wasn't a REC) when I wrote the module, and
the XML spec reserves PI's starting with "xml".

This seems odd to me because one of the examples in the documentation
for XML::Writer at cpan.org actually uses xml-stylesheet to
demonstrate the use of pi(). Maybe I'm just naive, but it seems like
this example would not have been used if xml-stylesheet was
incompatible with XML::Writer->pi();

One final thought: assuming that the module is a little out of date,
have you given any thought to another revision? It's such a useful
tool, I think that it would be a great service to keep it up to date.

Thanks again for your response.

v/r

David McBride
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top