For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > November 2007 > XML::XSLT does not accept an absolute path









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XML::XSLT does not accept an absolute path
Nick Monyatovsky

2007-11-15, 7:26 pm

I've run into a bug in XML::XSLT. If you give it an .xsl file by an
absolute name, it fails with the message:

Error while parsing: no element found at line 1, column 0, byte -1 at
C:/Perl/site/lib/XML/Parser.pm line 185

If you use relative path, no problems.

The line that's casuing the error is this:

my $xslt = XML::XSLT->new( $xslfile, warnings => 1, debug => 1);

There are no spaces anything else "weird" in the absolute path.
But this is on Windows, so it begins with "D:\users".

This looks like a minor omission somewhere in the module.
How can this be corrected?

Thanks,
-- Nick Monyatovsky
Nick Monyatovsky

2007-11-15, 7:26 pm

On Thu, 15 Nov 2007 17:02:18 -0500, Nick Monyatovsky
<no.such@address.com> wrote:

>I've run into a bug in XML::XSLT. If you give it an .xsl file by an
>absolute name, it fails with the message:
>
>Error while parsing: no element found at line 1, column 0, byte -1 at
>C:/Perl/site/lib/XML/Parser.pm line 185
>
>If you use relative path, no problems.
>
>The line that's casuing the error is this:
>
>my $xslt = XML::XSLT->new( $xslfile, warnings => 1, debug => 1);
>
>There are no spaces anything else "weird" in the absolute path.
>But this is on Windows, so it begins with "D:\users".
>
>This looks like a minor omission somewhere in the module.
>How can this be corrected?
>
>Thanks,
>-- Nick Monyatovsky


This is what happens under the hood:

creating parser object:
opening xsl...
SOURCE = D:\users\nmw\work\udev_appver\t\portfoli
o.xsl
opening document
Opening URL
FILENAME 0 = D:\users\nmw\work\udev_appver\t\portfoli
o.xsl
FILENAME URI:
D:%5Cusers%5Cnmw%5Cwork%5Cudev_appver%5C
t%5Cportfolio.xsl
NEW FILENAME:
*** Error: Could not create an instance of the XSL Processor using
D:\users\nmw\work\udev_appver\t\p
ortfolio.xsl: Error while parsing:
no element found at line 1, column 0, byte -1 at
C:/Perl/site/lib/XML/Parser.pm line 185

So,

either XSL::XSLT is wrong by calling

URI->new_abs( $filename, $base );

or URI is wrong by returning a string that no FileHandle will be able
to open

D:%5Cusers%5Cnmw%5Cwork%5Cudev_appver%5C
t%5Cportfolio.xsl

What do you think?

-- Nick Monyatovsky
Mumia W.

2007-11-16, 4:29 am

On 11/15/2007 04:02 PM, Nick Monyatovsky wrote:
> I've run into a bug in XML::XSLT. If you give it an .xsl file by an
> absolute name, it fails with the message:
>
> Error while parsing: no element found at line 1, column 0, byte -1 at
> C:/Perl/site/lib/XML/Parser.pm line 185
>
> If you use relative path, no problems.
>
> The line that's casuing the error is this:
>
> my $xslt = XML::XSLT->new( $xslfile, warnings => 1, debug => 1);
>
> There are no spaces anything else "weird" in the absolute path.
> But this is on Windows, so it begins with "D:\users".
>
> This looks like a minor omission somewhere in the module.
> How can this be corrected?
>
> Thanks,
> -- Nick Monyatovsky


Can't you use forward slashes?

D:/users/thefile.xml


Nick Monyatovsky

2007-11-16, 7:00 pm

On Thu, 15 Nov 2007 19:45:47 -0600, "Mumia W."
<paduille.4061.mumia.w+nospam@earthlink.net> wrote:

>On 11/15/2007 04:02 PM, Nick Monyatovsky wrote:
>
>Can't you use forward slashes?
>
>D:/users/thefile.xml
>


No, no luck there either. Same error.
Christian Winter

2007-11-16, 7:00 pm

Nick Monyatovsky wrote:
> On Thu, 15 Nov 2007 19:45:47 -0600, "Mumia W."
> <paduille.4061.mumia.w+nospam@earthlink.net> wrote:
>
>
> No, no luck there either. Same error.


Try passing the absolute path as a file URI:
file:///D:/users/thefile.xml

Neither XML::XSLT nor URI make a distinction between
local paths and URLs as their arguments, so to satisfy
LWP::Simple's get() method, one needs to prefix with
the correct scheme.

-Chris
--Nya--

2007-11-16, 7:00 pm

On Fri, 16 Nov 2007 18:02:39 +0100, Christian Winter
<thepoet_nospam@arcor.de> wrote:

>Nick Monyatovsky wrote:
>
>Try passing the absolute path as a file URI:
>file:///D:/users/thefile.xml
>
>Neither XML::XSLT nor URI make a distinction between
>local paths and URLs as their arguments, so to satisfy
>LWP::Simple's get() method, one needs to prefix with
>the correct scheme.
>
>-Chris


Ah! That's the trick!..

"file:///D:\users\thefile.xsl" fixed it.

Many thanks, Chris.




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com