|
Posted by Daniel Lowes on 10/20/09 11:31
Hi
I've been using PHP 4 for the last year to do XSL transformations in one
of my applications. It worked like a charm, we never had any problems.
While I was investigating the feasability of moving to PHP 5, I
discovered that for some reason, the exact same XML/XSL fails to
transform properly. The relevant bit of XSL is below:
----------------------------
<xsl:param name="pageContext" select="UNDEFINED" />
<xsl:variable name="sections" select="document('../xml/sections.xml')" />
<xsl:variable name="targetID" select="//*[@context = $pageContext]/@id" />
<xsl:variable name="targetFileSrc"
select="$sections/sections/section[@id = $targetID]" />
<xsl:variable name="targetFile">
<xsl:choose>
<xsl:when test="($targetFileSrc/sectionContentSrc = 'none') or
(string-length($targetFileSrc/sectionContentSrc) = 0)">
<xsl:copy-of select="document('../xml/default.xml')" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="document(concat('../xml/',
$targetFileSrc/sectionContentSrc))" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cornerImage"
select="$targetFile/content/headerContent/headerCornerImage" />
<xsl:variable name="shadowImage"
select="$targetFile/content/headerContent/headerShadowImage" />
--------------------------------------
with some sample XML as follows:
--------------------------------------
<content>
<headerContent>
<headerCornerImage>home_nav_middle.gif</headerCornerImage>
<headerShadowImage>home_nav_bottom.gif</headerShadowImage>
</headerContent>
</content>
----------------------------------------
I've checked and confirmed that pageContext gets properly initialised,
that all the referenced documents exist and are well-formed, and that
they contain the expected nodes. The error I get is "evaluating variable
'cornerImage' failed", yet I cannot understand how this can be so. Apart
from the fact that it worked perfectly fine in PHP 4, all the XML and
XSL conforms to spec. Anyone have an idea? I'm using the PHP 5 DOM and
XSL libraries to handle everything in my upgraded version of the code;
the PHP 4 version used DOMXML and Sablotron.
--
Pleochism: a moment of perfect beauty, between the "before" and the "after".
Mr Daniel Lowes
Techteam
Department of Computer Science
Information Technology Building, 4-30
University of Pretoria
http://www.cs.up.ac.za/
This message and attachments are subject to a disclaimer. Please refer
to www.it.up.ac.za/documentation/governance/disclaimer/ for full details.
Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule onderhewig.
Volledige besonderhede is by
www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.
[Back to original message]
|