Let me give a really basic example of what I’m trying to do, then I’ll explain afterward.
xml.xml:
<dataparent>
<data title="one" type="number" description="this is one" />
<data title="two" type="number" description="this is number two" />
<data title="a" type="letter" description="this is the letter a" />
<data title="b" type="letter" description="this is b" />
</dataparent>
xsl.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="<A href="http://www.w3.org/1999/XSL/Transform"><xsl:template">http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<div id="left">
Links:<br/>
<form name="FormName" action="Open_Result.php" method="get">
<xsl:for-each select="//data[@type]">
<xsl:variable name="link" select="@description"/>
<input type="hidden" value="//data[@description='{$link}']" id="{$link}" name="result" />
<a href="javascript: result('{$link}');"><xsl:value-of select="@title"/></a><br/>
</xsl:for-each>
</form>
</div>
<div id="open">
<xsl:for-each select="//data[@description='this is one']">
Title: <xsl:value-of select="@title"/> <br/>
Type: <xsl:value-of select="@type"/> <br/>
Description: <xsl:value-of select="@description"/> !
</xsl:for-each>
</div>
</xsl:template></xsl:stylesheet>
index.php:
<html>
<head>
<style type="text/css">
#left {float:left}
#open {position:relative;top:0;left:200px;font-size:20px}
</style>
<script type="text/javascript">
function result(value)
{
obj = document.FormName;
obj.theValue = value;
obj.submit();
}
</script>
</head>
<body>
<?php
$xml_file = "xml.xml";
$xslt_file = "xsl.xsl";
$xp = xslt_create() or die("Could not create XSLT processor");
if($result = xslt_process($xp, $xml_file, $xslt_file))
{
echo $result;
}
else
{
echo "An error occurred: " . xslt_error($xp) . "(error code " . xslt_errno($xp) . ")";
}
xslt_free($xp);
?>
</body>
</html>
xsl_Result.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="<A href="http://www.w3.org/1999/XSL/Transform"><xsl:template">http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<div id="left">
Links:<br/>
<form name="FormName" action="Open_Result.php" method="get">
<xsl:for-each select="//data[@type]">
<xsl:variable name="link" select="@description"/>
<input type="hidden" value="//data[@description='{$link}']" id="{$link}" name="result" />
<a href="javascript: result('{$link}');"><xsl:value-of select="@title"/></a><br/>
</xsl:for-each>
</form>
</div>
<div id="open">
<!-- this is where the problem occurs -->
<xsl:for-each select="<?php echo $_REQUEST['result']; ?>">
<!-- above here-->
Title: <xsl:value-of select="@title"/> <br/>
Type: <xsl:value-of select="@type"/> <br/>
Description: <xsl:value-of select="@description"/> !
</xsl:for-each>
</div>
</xsl:template></xsl:stylesheet>
Open_Result.php:
<html>
<head>
<style type="text/css">
#left {float:left}
#open {position:relative;top:0;left:200px;font-size:20px}
</style>
<script type="text/javascript">
function result(value)
{
obj = document.FormName;
obj.theValue = value;
obj.submit();
}
</script>
</head>
<body>
<?php
$xml_file = "xml.xml";
$xslt_file = "xsl_Result.xsl";
$xp = xslt_create() or die("Could not create XSLT processor");
if($result = xslt_process($xp, $xml_file, $xslt_file))
{
echo $result;
}
else
{
echo "An error occurred: " . xslt_error($xp) . "(error code " . xslt_errno($xp) . ")";
}
xslt_free($xp);
?>
</body>
</html>
Taking account the above:
“xml.xml” is transformed by “xsl.xsl” to be displayed properly.
Both “xml.xml” and “xsl.xsl” are parse in “index.php” and that works properly.
In “xsl.xsl” the links “one, two, a, b” (which comes from the “title” attributes) and the links use their “description.” The .xsl’s Javascripts get the value of the hidden input (the value which is equal to the “description” attribute) to make the their output values be the “description” attribute and seperate each from eachother when clicked…still all works. The .xml’s form has a action to “Open_Result.php”. The values from the links in the index.php (from the xsl.xsl) should be requested in the “xsl_Result.xsl” on the line “<xsl:for-each select=’<?php echo $_REQUEST[‘result’]; ?>’>”…but the problem is when the links are clicked in index.php these errors happen: “An error occurred: XML parser error 4: not well-formed (invalid token)(error code 2)”.
I believe this is because the values of the link are actually being sent to just “Open_Result.php” and not the “xsl_Result.xsl” which is being parsed by “Open_Result.php”.
Basically, I need someway for the “Open_Result.php” to actually write the “<xsl:for-each select=”<?php echo $_REQUEST[‘result’]; ?>"> line correctly.
That’s my problem if this is solved all other questions on this thread can be answered easily with the resolution to this post.