0

到目前为止,当我单击嵌入在我的超链接中的 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>
4

1 回答 1

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>

So, you are actually on the right lines already. I am assuming $ListingRid is a variable that you have set that contains the value of the ListingRid element. The syntax you actually want here is this

<a href="property_resi_xslt_test.php?ListingRid={$ListingRid}">

This is known as "Attribute Value Templates". The curly braces indicate it is an expression to be evaluated, rather than something to be output literally.

Assuming your current context was a row element, you wouldn't really need a variable here, you could just do this

<a href="property_resi_xslt_test.php?ListingRid={ListingRid}">

And, if you wanted to pass back more than one value, you could can use more than one AVT in the expression

<a href="property_resi_xslt_test.php?ListingRid={ListingRid}&amp;Status={Status}&amp;ZipCode={ZipCode}">

Of course, what you then do in your PHP page is an entirely different question. This is just showing you how to pass the values to the PHP in the first place.

于 2013-05-22T07:43:44.823 回答