3

Crashed at $xslt->importStyleSheet(); I got the Internal Server Error on my screen. But it works when I replace position()=1 with false in design.xsl.

  • PHP Version 5.3.29
  • XML Support active
  • XML Namespace Support active
  • libxml2 Version 2.9.1
  • XSL enabled
  • libxslt Version 1.1.14
  • libxslt compiled against libxml Version 2.6.19

testxslt.php

$xslt = new xsltProcessor;
$xslt->importStyleSheet(DomDocument::load('design.xsl'));
print $xslt->transformToXML(DomDocument::load('data.xml'));

data.xml

<?xml version="1.0" encoding="UTF-8"?>
<datalist>
    <data><title>title 1</title></data>
    <data><title>title 2</title></data>
    <data><title>title 3</title></data>
    <data><title>title 4</title></data>
</datalist>

design.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/datalist">
        <ul>
        <xsl:for-each select="data">
            <xsl:if test="position()=1">
                <li>top of entrylist</li>
            </xsl:if>
            <li><xsl:value-of select="title" /></li>
        </xsl:for-each>
        </ul>       
    </xsl:template>
</xsl:stylesheet>

Any advice? Thanks.

3
  • Is the XSLT you shown the one that generates the error, or a simplified version? What happens if you replace position() = 1 with true() in your actually XSLT? As an aside, if you type just false in your expression, this is simply looking for an element called false. You should use false() as a boolean expression.
    – Tim C
    Jul 1, 2015 at 11:44
  • This is one of the error I got, simplified version. false() is correct as you say. I'm sorry I made a mistake.
    – Jun1s
    Jul 2, 2015 at 3:09
  • I got the same error when I use "title!=''" or "string-length(title)=0" instead of "position()=1". Is it a bug of libxslt...?
    – Jun1s
    Jul 2, 2015 at 3:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.