By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,714 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,714 IT Pros & Developers. It's quick & easy.

Confusing message when using XML::Writer module in Perl

P: n/a
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>
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
da******@pacbell.net (David McBride) writes:
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
Jul 20 '05 #2

P: n/a
David Megginson <no****@attglobal.net> wrote in message news:<87************@megginson.com>...
da******@pacbell.net (David McBride) writes:
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

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
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.