Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old January 17th, 2008, 08:13 PM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default odd error with apply-templates select="..." name

I’m new to XSL and have a very strange problem.

Here is some code that works:

<jaal:city name="Gold Coast" country="Australia">
    <jaal:banner src="./myimage.jpg" alt="Banner Image"/>
    <jaal:bannertab1>
            <p>Text for bannertab1.</p>
    </jaal:bannertab1>
    <jaal:bannertab2>
            <p> Text for bannertab2.</p>
    </jaal:bannertab2>
  </jaal:city>







<xsl:template match="jaal:city">
            <xsl:apply-templates select="@name" />
            <xsl:apply-templates select="jaal:banner" />
            <div style="float: left; width: 300px; background-color: #1c98bc; margin-top: 2px;">
            <div style="margin-top: 8px; margin-left: 5px; margin-right: 5px;"><xsl:apply-templates select="jaal:bannertab1" /></div>
</div>
<div style="float: right; width: 312px; background-color: #64af46; margin-top: 2px;"><img src="./images/local_tip.gif" alt="Locals Tip" align="left" />
<div style="margin-top: 8px; margin-left: 5px; margin-right: 5px;"><xsl:apply-templates select="jaal:bannertab2" /></div>
            <div style="clear: both"></div>
</xsl:template>

I am adding to someone else’s code who can’t be contacted… I added the bannertab1 and bannertab2 bits.

There is more code which has the following and works:

<jaal:city name="Gold Coast" country="Australia">
            <jaal:banner src="./images/citybanners/1/main.jpg" alt="Welcome to Gold Coast" />
            <jaal:mytxt>write stuff</jaal:mytxt>
            <jaal:citybanners>
                        <jaal:one src="./images/citybanners/1/one.png" alt="Local Message Board" href="/xml/messageboard.xml" />
                        <jaal:two src="./images/citybanners/1/two.png" alt="Hot Specials" href="./" />
                        <jaal:three src="./images/citybanners/1/three.png" alt="Want To Work?" href="./" />
                        <jaal:four src="./images/citybanners/1/four.png" alt="Local Celebs Tell All" href="/xml/celebrityprofile.xml" />
                        <jaal:five src="./images/citybanners/1/five.png" alt="Kids Talk" href="./" />
            </jaal:citybanners>
</jaal:city>


<xsl:template match="jaal:city">
            <xsl:apply-templates select="@name" />
            <xsl:apply-templates select="jaal:banner" />
            <div style="margin-top: 5px;">
                        <div style="float: left; margin-left: 4px;">
                                    <img src="./images/localnews/heading.gif" /><br />
                        </div>
                        <div style="float: left; margin-left: 5px;">
                                    <img src="./images/community/heading.gif" /><br />
                                    <xsl:apply-templates select="jaal:mytxt" />
                        </div>
                        <div style="float: right; margin-right: 4px;">
                                    <img src="./images/services/heading.gif" /><br />
                        </div>
            </div>
</xsl:template>






<xsl:template match="jaal:citybanners">
            <div style="margin: 8px 5px 8px 5px">
                        <div>
                                    <a href="{jaal:one/@href}"><img src="{jaal:one/@src}" alt="{jaal:one/@alt}" /></a>
                                    <a href="{jaal:two/@href}"><img src="{jaal:two/@src}" alt="{jaal:two/@alt}" /></a>
                        </div>
                        <div>
                                    <a href="{jaal:three/@href}"><img src="{jaal:three/@src}" alt="{jaal:three/@alt}" /></a>
                                    <a href="{jaal:four/@href}"><img src="{jaal:four/@src}" alt="{jaal:four/@alt}" /></a>
                                    <a href="{jaal:five/@href}"><img src="{jaal:five/@src}" alt="{jaal:five/@alt}" /></a>
                        </div>
            </div>
</xsl:template>


Now with this code, only the jaal:banner is showing on the page. Also if I add another <xsl:apply-templates select=”jaal:banner” /> it appears, however if I change the name from jaal:banner to anything else (in both sets of code), it stops displaying!

I have no idea why and any help would be greatly appreciated.
 
Old January 18th, 2008, 03:45 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You have no template which matches either bannertab1 or bannertab2?

<xsl:template match="jaal:bannertab1">

If you want to use the same template for each you could do this:

<xsl:template match="jaal:bannertab1 | jaal:bannertab2">

or use <xsl:call-template> and pass in the banner as a parameter.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exclude Elements in Apply Templates mail4kaja XSLT 18 November 29th, 2008 12:09 PM
Apply-templates combined with with-param ? Smirre XSLT 6 November 11th, 2008 08:25 AM
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
xsl:apply-templates select problem harapraveen XSLT 2 October 22nd, 2007 08:05 AM
Templates Won't Apply neilac333 XSLT 5 October 26th, 2006 01:39 PM





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