Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: XML::XSLT problem

by bosshoff (Novice)
on Apr 24, 2005 at 17:08 UTC ( #451003=note: print w/replies, xml ) Need Help??

in reply to Re: XML::XSLT problem
in thread XML::XSLT problem

I already tried that, and here is the new code:

use strict; use XML::XSLT; myy $xslt = XML::XSLT->new ("blog.xsl", warnings => 1, debug => 1); $xslt->transform ("posts.xml"); print $xslt->toString; $xslt->dispose();
Alas, same error. I was already making sure that the files did exist and that the variables were being filled, by outputing the vars; I know this isn't a simple file I/O error, in other words.

What I find rather funny is that, when I use the deprecated document_transform function, it kindof works; it prints out only the first template match="/" stylesheet declaration and nothing else.

Furthermore, I know it isn't my XSL or XML files because Xalan works flawlessly. There must be something I'm doing wrong, I just can't find out what, and that error message is not very descriptive (couldn't find anything at byte -1, really? lol)

Replies are listed 'Best First'.
Re^3: XML::XSLT problem
by rg0now (Chaplain) on Apr 24, 2005 at 17:53 UTC
    Ok, now the only thing remained to be done is to have a look at your actual blog.xsl and posts.xml files. A useful way to tackle these kinds of problems is if you try to find the minimal working and non-working examples, which then can be posted here. My guess is that either your XSL or XML is invalid, since the problem seems to rise right at the first line. You might not have the usual <xsl:stylesheet version="1.0" blablabla at the first line? Try to find some very basic XML and XSL files that do not work and try to find, what makes your specific version to fail.

    I myself have often found the solution for various problems just to try to create a basic test case, which can be posted to PerlMonks...

      I will prepare these test cases, but I've alread mentioned that these files work flawlessly with Xalan, which is a C-based validating XSLT processor. I assume that XML::XSLT is keeping with the same standard. Also, if it were simply a problem with the xsl/xml, wouldn't you think there would be a more descriptive error, such as: "element illegal" or "element {some element} not found" as opposed to a generic "element not found," as if there was no input at all?

      If anyone else has had success with XML::XSLT, please post your code; I'm certain I am just doing something wrong when calling it, but I don't know what. Thanks.

      Oh, and here are the links for my current .xsl and .xml files:
      XSL XML
        For me it appears that XML::XSLT croaks when it tries to open an external XML file. Line 62 of blog.xsl confirms it:
        <xsl:for-each select="document('menu.xml')/menu/item">
        Have you provided the file menu.xml for the XSLT processor? I guess you have not...:-)

        What really makes me wonder here is that XML::LibXSLT gives fairly sane output, even without the menu.xml file. Now this is really strange! Though, I admit that I am not really an expert of XSLT....

        Update: after setting the debug_callback for XML::LibXSLT it seems that the parser just silently ignores the missing file here (only noing that the for-each did not produce a node list). XML::XSLT appears to be much more picky here...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://451003]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-01-28 10:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found