Jon Weir
03-30-2006, 12:44 PM
Hi,
Anyone any idea why the JavaScript code below displays the variable I explicitly declared but not the variable defined by the result of the XSL transform? i.e. when you change $foo to $earth there is no output. (my xsl fragment is at the bottom of this message).
Thanks.
PHP Code:
<?php
//XMLXSL Transformation class
require_once('includes/MM_XSLTransform/MM_XSLTransform.class.php');
?>
<html>
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("http://feeds.feedburner.com/usgs/eqs1day-M25");
$mm_xsl->setXSL("earthquake.xsl");
$earth = $mm_xsl->Transform();
$foo = 'bar';
?>
<?php
echo $earth;
echo $foo;
?>
<script>
var a = "<?php echo $foo;?>";
document.write(a);
</script>
</html>
XSL fragment:
<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="http://feeds.feedburner.com/usgs/eqs1day-M25" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "*">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="ItemsPerPage" select="20"/>
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<xsl:sort select="title" order="descending"/>
<xsl:if test="position() < 2">
<xsl:value-of select="title"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Anyone any idea why the JavaScript code below displays the variable I explicitly declared but not the variable defined by the result of the XSL transform? i.e. when you change $foo to $earth there is no output. (my xsl fragment is at the bottom of this message).
Thanks.
PHP Code:
<?php
//XMLXSL Transformation class
require_once('includes/MM_XSLTransform/MM_XSLTransform.class.php');
?>
<html>
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("http://feeds.feedburner.com/usgs/eqs1day-M25");
$mm_xsl->setXSL("earthquake.xsl");
$earth = $mm_xsl->Transform();
$foo = 'bar';
?>
<?php
echo $earth;
echo $foo;
?>
<script>
var a = "<?php echo $foo;?>";
document.write(a);
</script>
</html>
XSL fragment:
<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="http://feeds.feedburner.com/usgs/eqs1day-M25" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "*">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="ItemsPerPage" select="20"/>
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<xsl:sort select="title" order="descending"/>
<xsl:if test="position() < 2">
<xsl:value-of select="title"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>