Issue with XSLT Processing on PHP

Posted by monksy on Stack Overflow See other posts from Stack Overflow or by monksy
Published on 2011-03-03T05:42:27Z Indexed on 2011/03/06 16:10 UTC
Read the original article Hit count: 324

Filed under:
|

I'm getting a few errors from XSLTProcessor:

XSLTProcessor::transformToDoc() [<a href='function.XSLTProcessor-transformToDoc'>function.XSLTProcessor-transformToDoc</a>]: Invalid or inclomplete context

XSLTProcessor::transformToDoc() [<a href='function.XSLTProcessor-transformToDoc'>function.XSLTProcessor-transformToDoc</a>]:

XSLTProcessor::transformToDoc() [<a href='function.XSLTProcessor-transformToDoc'>function.XSLTProcessor-transformToDoc</a>]: xsltValueOf: text copy failed in

Which is parsing this XSLT Line:

<xsl:apply-templates select="page/sections/section" mode="subset"/>

The section is:

<xsl:template match="page/sections/section" mode="subset">
    <a href="#{shorttitle}">
        <xsl:value-of select="title"/>
    </a>
    <xsl:if test="position() != last()"> | </xsl:if>
</xsl:template>

The XML that the section is parsing is:

   <shorttitle>About</shorttitle>
   <title>#~ About</title>

The PHP XSLT Code is:

$xslt = new XSLTProcessor();
$XSL = new DOMDocument();

$XSL->load( $xsltFile, LIBXML_NOCDATA);

$xslt->importStylesheet( $XSL );

print $xslt->transformToXML( $XML );

My suspicion about the the errors is due to content. I'm not getting these errors with Firefox's XSLT rendering, nor am I getting an invalid XML document on the backend.I'm not getting errors on the load, its just on the transformToXML function.

Does anyone have a clue on how to solve this?

This is with PHP5.

© Stack Overflow or respective owner

Related posts about php5

Related posts about xsltprocessor