View Single Post
 
Old May 5th, 2006, 12:13 PM
underdog underdog is offline
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT & PHP -undefined variable- is . a culprit?

Update - I can get this to work if I replace the . with %2E, but then i get <a> elements later on that start to fail. WHAT THE HELL???

This has been a bang-my-head nightmare for three days now. Half of this application works (the 'user' side), but the admin side is DOA.

I am using php5's XSLTProcessor class to handle an application that I "inherited" - and am not happy about. Here is the error that I get:

Quote:
quote:Warning: compilation error: file /home/...(supressed).../neighborhoods.xsl line 57 element form in /home/...(supressed).../admin_xslt.php on line 24

Warning: Attribute template action: failed to compile $neighborhoodId in /home/...(supressed).../admin_xslt.php on line 24
Here's what some differential diagnosing has shown me:
Using <xsl:variable name="neighborhoodId" select="@id"/>, the script handles this okay:

Code:
<form action="admin.php?neighborhoods=1&amp;modNeighborhood=1&amp;neighborhoodId={$neighborhoodId}" method="post">
but then fails to compile essentially the same thing a few lines later:

Code:
<form action="admin.php?neighborhoods=1&amp;deleteNeighborhood=1&amp;neighborhoodId={$neighborhoodId}" method="post">
Now what is really odd is that if I change the above line by emptying out everything in the 'action' attribute except the variable reference, it compiles! (Here's what that looks like):

Code:
<form action="{$neighborhoodId}" method="post">


Here is the xsl:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="neighborhoods">

    <h2>Neighborhoods</h2>
    <div class="backPanel">
        <br/>
        <form action="admin.php?neighborhoods=1&amp;addNeighborhood=1" method="post">
        <input type="submit" value="Add Neighborhood"/>
    </form>
        <table class="list">
            <xsl:for-each select="neighborhood">
                <xsl:variable name="neighborhoodId" select="@id"/>
                <tr>
                    <td>
                        <a href="admin.php?neighborhoods=1&amp;viewNeighborhood=1&amp;neighborhoodId={$neighborhoodId}">
                            <xsl:value-of select="@name"/>
                        </a>

                    </td>
                </tr>
            </xsl:for-each>
        </table>
        <br/>
    </div>
</xsl:template>

<xsl:template match="neighborhood">
    <xsl:variable name="neighborhoodId" select="@id"/>
    <h2><xsl:value-of select="@name"/></h2>
    <div class="backPanel">
        <br/>
        <table class="detail">
            <tr><th>Neighborhood:</th><td><xsl:value-of select="@name"/></td></tr>
            <tr><th>Mapquest URL:</th><td><a href="{@mapquestUrl}">mapquest link</a></td></tr>
            <tr><th>Community Info:</th><td><xsl:value-of select="@communityInfo"/></td></tr>
            <tr><th>Other Communities:</th><td><xsl:value-of select="@otherCommunities"/></td></tr>
            <tr><th>Bottom Text:</th><td><xsl:value-of select="@bottomText"/></td></tr>
            <tr><th>Top Banner:</th><td><xsl:value-of select="@topBanner"/></td></tr>
            <tr><th>Bottom Banner:</th><td><xsl:value-of select="@bottomBanner"/></td></tr>
        </table>
        <br/>
        <table border="0">
            <tr>
                <td>
                    <form action="admin.php?neighborhoods=1&amp;modNeighborhood=1&amp;neighborhoodId={$neighborhoodId}" method="post">
                        <input type="submit" value="modify neighborhood"/>
                    </form>                    
                  </td>
                <td>
                    <form action="admin.php?neighborhoods=1&amp;deleteNeighborhood=1&amp;neighborhoodId={$neighborhoodId}" method="post">
                        <input type="submit" value="delete neighborhood" onclick="return confirmDelete()"/>
                    </form>
                </td>
            </tr>
        </table>
    </div>
</xsl:template>
</xsl:stylesheet>