到目前为止,当我点击嵌入在我的超链接中的XSLT时,我得到了我想要的页面。但是,它也是我需要帮助的地方!我需要我的style_sheet将整个row.node结果作为参数或数组onclick传递,以便我可以通过html嵌入和操作它以进行结果页面调用。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="property_resi.xsl"?>
<rows>
<row>
<ListingPrice>124000.00</ListingPrice>
<ListingRid>59999991</ListingRid>
<Status>Active</Status>
<StatusComments></StatusComments>
<StatusDate>2007-07-24T00:00:00</StatusDate>
<Stories>1.00</Stories>
<StreetDirection>East</StreetDirection>
<StreetName>San Sircettia</StreetName>
<StreetNumber>410</StreetNumber>
<StreetNumberModifier></StreetNumberModifier>
<StreetPostDirection></StreetPostDirection>
<StreetSuffix>St</StreetSuffix>
<YearBuilt>1999</YearBuilt>
<ZipCode>99999</ZipCode>
</row>
<row>
<ListingPrice>98000.00</ListingPrice>
<ListingRid>59999992</ListingRid>
<Status>Active</Status>
<StatusComments></StatusComments>
<StatusDate>2007-07-24T00:00:00</StatusDate>
<Stories>1.00</Stories>
<StreetDirection>South</StreetDirection>
<StreetName>Tuscany</StreetName>
<StreetNumber>560</StreetNumber>
<StreetNumberModifier></StreetNumberModifier>
<StreetPostDirection></StreetPostDirection>
<StreetSuffix>Circle</StreetSuffix>
<YearBuilt>2000</YearBuilt>
<ZipCode>99999</ZipCode>
</row>
<row>
<ListingPrice>805000.00</ListingPrice>
<ListingRid>59999993</ListingRid>
<Status>Active</Status>
<StatusComments></StatusComments>
<StatusDate>2007-07-24T00:00:00</StatusDate>
<Stories>1.00</Stories>
<StreetDirection>West</StreetDirection>
<StreetName>Hill View Park</StreetName>
<StreetNumber>2205</StreetNumber>
<StreetNumberModifier></StreetNumberModifier>
<StreetPostDirection></StreetPostDirection>
<StreetSuffix>Drive</StreetSuffix>
<YearBuilt>1978</YearBuilt>
<ZipCode>99999</ZipCode>
</row>
</rows>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
<xsl:template match="/">
<html>
<body>
<h2>Current Listings</h2>
<table border="1">
<tr bgcolor="#9acd32"> </tr>
<xsl:for-each select="rows/row">
<xsl:sort select="City"/>
<xsl:sort select="ZipCode"/>
<tr> <td><a href="property_resi_xslt.html">
<xsl:value-of-select=
"concat(StreetNumber, ' ',
StreetDirection, ' ',
StreetName, ' ',
StreetSuffix, ' - ', City,
',', ZipCode, ' - ', '$',
ListingPrice)"/>
</a>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" `"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Lang" content="en" />
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<meta name="author" content="" />
<meta http-equiv="Reply-to" content="@.com" />
<meta name="generator" content="PhpED 8.0" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="creation-date" content="06/09/2012" />
<meta name="revisit-after" content="15 days" />
<title>Results page</title>
</head>
<body>
Insert & Manipulate`code here` My XML RESULTS HERE!!!!
</body>
</html>
答案 0 :(得分:0)
您正在使用XML和XSLT在浏览器中生成HTML,但是当浏览器运行并显示HTML时,它将不再引用原始XML文档。所以,它并没有真正传递“row.node结果作为参数”。您必须确保行集中的数据以某种方式放置在HTML文档中,然后可以将其传递到PHP页面。
您在评论中提供此示例
<a href="property_resi_xslt_test.php?ListingRid=$ListingRid;"><xsl:value-of select="concat(StreetNumber,' ', StreetDirection, ' ',StreetName, ' ', StreetSuffix, ' - ', City, ',', ZipCode, ' - ','$', ListingPrice)"/></a>
所以,你实际上已经是正确的了。我假设 $ ListingRid 是您设置的包含 ListingRid 元素值的变量。你真正想要的语法是这个
<a href="property_resi_xslt_test.php?ListingRid={$ListingRid}">
这称为“属性值模板”。花括号表示它是一个要评估的表达式,而不是字面输出的东西。
假设您当前的上下文是行元素,那么您在此处不需要变量,您可以这样做
<a href="property_resi_xslt_test.php?ListingRid={ListingRid}">
而且,如果你想传回多个值,你可以在表达式中使用多个AVT
<a href="property_resi_xslt_test.php?ListingRid={ListingRid}&Status={Status}&ZipCode={ZipCode}">
当然,你在PHP页面中所做的是一个完全不同的问题。这只是向您展示如何将值传递给PHP。