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 January 20th, 2006, 04:16 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default recursive transform output different in IE and FF

I am trying to create an HTML DOM that is unnested, as the XML input. All folders should be siblings of one another in the output HTML DOM. In IE this works great with the attached XSLT logic. In FF, on the other hand, all folder nodes end up as[list]s embeded in one another resulting in folder 1 as parent of folder 2, 2 parent of 3, etc.

Intrestingly, if any folder has a child node it will display correctly in the resulting HTML DOM.

Why the diff? Even if my XSLT logic is crap, I would expect the same crappy result from both browsers, perhaps in an ideal world. Ideas?

input XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

...
<channelListNodes>
    <channel>
        <name>blah</name>
    </channel>
    <folder>
        <name>1</name>
    </folder>
    <folder>
        <name>2</name>
    </folder>
    <folder>
        <name>3</name>
    </folder>
    <folder>
        <name>4</name>
    </folder>
</channelListNodes>
...

XSL stylesheet:

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

<xsl:output
    method="html"
    encoding="UTF-8"
    omit-xml-declaration="no"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    indent="yes"
    standalone="yes"
    />

    <xsl:template match="//channelListNodes">

        <html>
        <head>
            <title>ChannelList</title>
        </head>
        <body>

            <table class="channelListTable" id="channelListTable">
                <thead>
                    <th class="leftChannelCol">#160;</th>
                    <th class="midChannelCol">#160;</th>
                    <th class="rightChannelCol">#160;</th>
                </thead>
            </table>
            <ul class="tree" id="channelListTree">

                <xsl:variable name="channels" select="./channel"/>
                <xsl:variable name="folders" select="./folder"/>

                <xsl:if test="$channels">
                    <xsl:for-each select="$channels">
                        <xsl:call-template name="processChannel">
                            <xsl:with-param name="channel" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>

                <xsl:if test="$folders">
                    <xsl:for-each select="$folders">
                        <xsl:call-template name="processFolder">
                            <xsl:with-param name="folder" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>
            </ul>
        </body>
        </html>
    </xsl:template>

    <xsl:template name="processFolder">
        <xsl:param name="folder"/>
        <xsl:variable name="name"><xsl:value-of select="$folder/name"/></xsl:variable>

        <li class="folder" id='{$name}'>
            <a href="#"><xsl:value-of select='$name'/></a>
            [list]

                <xsl:variable name="channels" select="$folder/channel"/>
                <xsl:variable name="folders" select="$folder/folder"/>

                <xsl:if test="$channels">
                    <xsl:for-each select="$channels">
                        <xsl:call-template name="processChannel">
                            <xsl:with-param name="channel" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>

                <xsl:if test="$folders">
                    <xsl:for-each select="$folders">
                        <xsl:call-template name="processFolder">
                            <xsl:with-param name="folder" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:if>
            </ul>
        </li>
    </xsl:template>

    <xsl:template name="processChannel">
        <xsl:param name="channel"/>

        <xsl:variable name="thisName"><xsl:value-of select="$channel/name"/></xsl:variable>


        <li class="channelListEntry" id='{$thisName}' xpath='{$path}' ro='{$ro}'>
            <a href="#">
                <span class="channelListEntryData" id = "channelListEntryDataName"><xsl:value-of select='$thisName'/></span>
            </a>
        </li>
    </xsl:template>



    <xsl:template match="text()" />

</xsl:stylesheet>
  #2 (permalink)  
Old January 20th, 2006, 05:22 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

As far as I can see your code is correct (except for two undeclared variables $path and $ro) and you should therefore report this as a Mozilla bug.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old January 20th, 2006, 06:01 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I attempted to remove all extraneous material from my code to post a cleaner example but overlooked those variables specified in that element. Thank you for getting back to me so quickly, I will submit the Mozilla bug report.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursive Query for Formatted Output Itech SQL Server 2005 11 June 12th, 2008 04:32 PM
transform in a loop vs recursive template ramarc XSLT 3 April 10th, 2006 04:40 PM
Disable-Output-Escaping in .NET Transform tclancy XSLT 3 March 1st, 2006 09:27 AM
Recursive Transform chuck.boyer XSLT 0 December 5th, 2005 05:51 PM
Removing Namespaces from XSL Transform output francislang XSLT 2 September 7th, 2004 07:58 AM





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