garlik-gag / dokuwiki-plugin-odt2dw

Import odt file in dokuwiki page
10 stars 10 forks source link

Using embedded xsl leads to an er_xslt_invalid error #1

Closed Glandos closed 12 years ago

Glandos commented 12 years ago

I am using PHP 5.1.2 (yes, I'm forced to stick to that version), but the php5-xsl package is correctly installed. Do you have any idea?

garlik-gag commented 12 years ago

Hi,

er_xslt_invalid error mean the xsltProcessor object is correctly implement (php5-xsl package is installed), but can't load the xslt file. I ll give you in week a less complex xslt-file. The current version used EXSLT. Perhaps some functions wasn't implemented in older library.

Which version of php5-xsl's package is installed ? Have you some elements from apache log file ? Could you try this command in a script ? XSLTProcessor->hasExsltSupport(); Return true if "EXSLT" is supported

Glandos commented 12 years ago
<?
$xslt = new XSLTProcessor;
$has_support = $xslt->hasExsltSupport();
echo "XLST has support for EXSLT: "; var_dump($has_support);
?>

This outputs:

XLST has support for EXSLT: bool(true)

php5-xsl is version 5.1.2

garlik-gag commented 12 years ago

I ve got 2 line of thought.

1. Could you try to comment the following lines in the xsl file. Line 328 to 339 :

<xsl:template match="//draw:frame">
<!--    <xsl:param name="cmtopx" value="37.795275591"/>
    <xsl:text disable-output-escaping="yes" >{{</xsl:text>
    <xsl:value-of select="substring-after(draw:image/@xlink:href,'/')"/>
      <xsl:if test="not (@svg:width = '' or @svg:height = '')">
      <xsl:choose>--><!-- check cm, px, in, etc... -->
<!--        <xsl:when test="contains( @svg:width,'cm' )">?<xsl:value-of select="floor(number(substring-before(@svg:width,'cm')) * 37.795275591)"/></xsl:when>
        <xsl:otherwise/>
      </xsl:choose>
    </xsl:if>
    <xsl:text disable-output-escaping="yes" >}}</xsl:text>-->
  </xsl:template>

It disables the images import.

I think one of the "floor", "number", "substring-after" or "substring-before" functions make it crashes.

2. I make an error like yours (er_xslt_invalid) on my wiki. In the apache error log file, I find these lines which give me the line number in the xsl file where the problem occur. (121 in this case)

[Tue Apr 10 15:18:09 2012] [error] [anonymized] PHP Warning: XSLTProcessor::importStylesheet(): Invalid expression in /var/www/html/wiki/lib/plugins/odt2dw/action.php on line 330, referer: [anonymized] [Tue Apr 10 15:18:09 2012] [error] [anonymized] PHP Warning: XSLTProcessor::importStylesheet(): compilation error: file /var/www/html/wiki/lib/plugins/odt2dw/odt2dw.xsl line 121 element when in /var/www/html/wiki/lib/plugins/odt2dw/action.php on line 330, referer: [anonymized] [Tue Apr 10 15:18:09 2012] [error] [anonymized] PHP Warning: XSLTProcessor::importStylesheet(): xsl:when : could not compile test expression 'not (ancestor::table:table or ancestor::text:list) nd $title_style and $title_style/text:index-source-style[@text:style-name = $real_style]' in /var/www/html/wiki/lib/plugins/odt2dw/action.php on line 330, referer: [anonymized]

My error is a "a" is missing to complet the "and" word after the first ')'. You can see it on the third log line.

Could you copy some anonymized lines from your log (which contain "xsltProcessor") here to help us to solve you problem ?

Glandos commented 12 years ago

Commenting out the draw:frame doesn't succeed.

I don't have any suspicious log in Apache logs. However, when I modified the XSL, I had the following warning:

[Thu Apr 12 09:31:19 2012] [error] [client 10.35.203.93] PHP Warning:  DOMDocument::load() [<a href='function.load'>function.load</a>]: Comment not terminated \n&lt;!--\n    &lt;xsl:param name=&quot;cmtopx&quot; value=&quot;37.795275591&quot; in /export/www/htdocs/wiki/lib/plugins/odt2dw/odt2dw.xsl, line: 334 in /export/www/htdocs/wiki/lib/plugins/odt2dw/action.php on line 175, referer: […]

meaning that I should see warnings if there is some.

garlik-gag commented 12 years ago

Hi, I ve got no more idea. (edit: below some idea nevertheless ;) )

I try to install an old Sles10, but the php is version 5.2.5 Dokuwiki + odt2dw work.

Perhaps the char encoding is not enabled on your apache or not supported by the 5.1 library. The xslt file is encoding in utf8.

You can try to disabled each block like draw:frame to show if one goes wrong, starting with the last one (name="boucle").

Otherwise, you can try to disabled the error trigger in the php file. line 330

    #if ( ! $this->XSLT->importStylesheet( $this->XSL ) ) return $this->_msg('er_xslt_invalid');
    $this->XSLT->importStylesheet( $this->XSL );

The importStylesheet may return wrong value and works.

garlik-gag commented 12 years ago

Hi,

Are you still having problems?

Glandos commented 11 years ago

No, I'm not dead, but yes, this issue can be closed, cause I've no time to reproduce it… Sorry.