xsl-list
[Top] [All Lists]

XSL variable out of scope

2003-01-23 13:03:39
Hi All,

I have an xml and xsl like the following. When I apply
the xsl I need to get the following HTML

Home: 4089888888
Business: 40888888

But I get an error saying variable out of scope. And I
know I am using a variable declared in a different
scope. I am kinda stuck here and I dont have any more
ideas to counter this. Can someone help me find a way
to tackle this problem. 

PhoneList.xml

<?xml-stylesheet type="text/xsl"
href="C:\TestXSLT\xsl\PhoneList.xsl"?>
<PhoneList>
        <Phone>
                <PhoneUseCode>BUS</PhoneUseCode>
                <PhoneNumber>4082389033</PhoneNumber>
        </Phone>
        <Phone>
                <PhoneUseCode>HOME</PhoneUseCode>
                <PhoneNumber>4082834798</PhoneNumber>
        </Phone>
</PhoneList>


PhoneList.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<xsl:template match="/">
<xsl:for-each select="//PhoneList/Phone">
        <xsl:variable name="PhUseCode"
select="PhoneUseCode"/>
        <xsl:choose>
                <xsl:when test="$PhUseCode='HOME'">
<xsl:variable name="HomePhone" select="PhoneNumber"/>
        </xsl:when>
        <xsl:when test="$PhUseCode='BUS'">
<xsl:variable name="BusPhone" select="PhoneNumber"/>
        </xsl:when>
</xsl:choose>
</xsl:for-each>
<tr>
        <td>&#160;</td><td>&#160;</td>
        <td nowrap="nowrap"
colspan="2">&#160;&#160;&#160;Home</td>
                                <td nowrap="nowrap">"<xsl:value-of
select="$HomePhone"/></td>
                        </tr>
                        <tr>
                                <td>&#160;</td>
                                <td>&#160;</td>
                                <td nowrap="nowrap"
colspan="2">&#160;&#160;&#160;Business</td>
                                <td nowrap="nowrap"><xsl:value-of
select="$BusPhone"/></td>
                        </tr>
        </xsl:template>
</xsl:stylesheet>


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>