php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37042 libxml_get_last_error always returns error after importStylesheet
Submitted: 2006-04-11 17:40 UTC Modified: 2006-04-11 18:12 UTC
From: php at xmlnode dot com Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.1.2 OS: Solaris, Debian, Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at xmlnode dot com
New email:
PHP Version: OS:

 

 [2006-04-11 17:40 UTC] php at xmlnode dot com
Description:
------------
It seems that libxml_get_last_error always has an error after importing a perfectly valid, well-formed, xsl stylesheet.  

This makes it difficult to determine if there is really a problem with the stylesheet versus 'noise'. :(

Reproduce code:
---------------
<?php

libxml_use_internal_errors(true);
$x = new DomDocument;
$y = new XSLTProcessor;
$x->load('foo.xsl');
$y->importStyleSheet($x);
var_dump(libxml_get_last_error());

// not needed to show the problem, but if uncommented works
// $x->loadxml('<FOO />');
// echo $y->transformToXML($x);
?>

// the stylesheet which opens without error in other parsers

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" encoding="iso-8859-1" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />

<xsl:template match="/">
hi
</xsl:template>
</xsl:stylesheet>

Expected result:
----------------
No errors.  In fact, if you comment the vardump and uncomment the last two lines of the reproducable code above, it will transform the document as expected, but there's still an error in libxml.  I recognize that libxml is outside of your immediate jurisdiction, but was hoping you could alter libxml_get_last_error to be smarter or something... not sure what I'm hoping for exactly.

Actual result:
--------------
object(LibXMLError)#3 (6) { 
   ["level"]=>  int(3) 
   ["code"]=>  int(77) 
   ["column"]=>  int(1) 
   ["message"]=>  string(47) "Premature end of data in tag stylesheet line 2 " 
   ["file"]=>  string(37) "file:///c%3A/xampplite/htdocs/foo.xsl" 
   ["line"]=>  int(11) 
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-11 17:58 UTC] chregu@php.net
which libxml2/libxslt versions are you using.

It works for me and prints
bool(false)

And you're right, it's nothing we can do about it. File a bug 
at xmlsoft.org, if you can reproduce the error with the latest 
libraries
 [2006-04-11 17:58 UTC] chregu@php.net
which libxml2/libxslt versions are you using.

It works for me and prints
bool(false)

And you're right, it's nothing we can do about it. File a bug 
at xmlsoft.org, if you can reproduce the error with the latest 
libraries
 [2006-04-11 18:12 UTC] php at xmlnode dot com
sorry, libxml version 2.6.220.  I'll drop this off at xmlsoft. For my workaround I'm checking sizeof(libxml_get_errors) which is 0 even when libxml_get_last_error has it's 'error'.

Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC