strange problem with apply-templates select="..."

Here should go questions about transforming XML with XSLT and FOP.
Fitty
Posts: 1
Joined: Fri Jan 18, 2008 3:20 am

strange problem with apply-templates select="..."

Post by Fitty »

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.
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post by Dan »

Sorry, but I could not figgure out what was the problem. The stylesheet is incomplete, and there may be multiple things that can go wrong.

You can try to debug your stylesheet. Create a transformation scenario in oXygen, then use the debugger to step into the transformation and check how the templates are applied and the output generated.

For details, see the user guide:
http://www.oxygenxml.com/doc/ug-oxygen/ ... heets.html
There is also a video presentation:
http://www.oxygenxml.com/demo/debugging ... arios.html

Regards,
Dan
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung »

Where are your jaal:bannertab1 and jaal:bannertab2 templates??
Post Reply