Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 5th, 2006, 12:13 PM
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>
  #2 (permalink)  
Old May 7th, 2006, 11:10 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Spent HOURS putting in CDATA sections and changing variable calls to xsl:value-of.

Would be interested to find out the cause of this error.
  #3 (permalink)  
Old May 7th, 2006, 12:12 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your original stylesheet compiles fine under Saxon: it seems to be correct XSLT code. So I don't know why you're hitting problems. I didn't respond to your original question because I know nothing about PHP, and I don't know where PHP comes into it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #4 (permalink)  
Old May 8th, 2006, 10:04 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...and I guess YOU would be the one to know ;)!

I think the prob may be with PHP's XSLTProcessor class.

Thanks!


Similar Threads
Thread Thread Starter Forum Replies Last Post
php question, undefined variable benappease Beginning PHP 0 December 6th, 2007 02:35 PM
Undefined Variable aspire Beginning PHP 4 July 12th, 2006 07:00 AM
How to know a variable is undefined? Edward King Javascript How-To 3 June 14th, 2005 10:14 AM
Chapter 7 check_image.php, undefined variable Ron_Bingham BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 June 3rd, 2005 10:31 PM
Undefined Variable Some Help! knight Beginning PHP 7 February 19th, 2004 07:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.