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 October 13th, 2006, 10:29 AM
Authorized User
 
Join Date: Oct 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default *solved* applying same template to multiple nodes

i have the following in my code...

Code:
[list]
   <xsl:for-each select="/root/media/foo">
      <xsl:apply-templates select="makeli"/>
   </xsl:for-each>
</ul>[list]
   <xsl:for-each select="/root/media/bar">
      <xsl:apply-templates select="makeli"/>
   </xsl:for-each>
</ul>
and the following template...

Code:
<xsl:template name="makeli">
   <li>
      <a><xsl:value-of select="title"/></a><br />
      <xsl:value-of select="description"/>
   </li>
</xsl:template>
it's not applying the template. i don't get any errors, just no results. is thos not possible?
 
Old October 13th, 2006, 11:21 AM
Authorized User
 
Join Date: Oct 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok, figured it out! just had to change the following...

Code:
[list]
   <xsl:for-each select="/root/media/foo">
      <xsl:apply-templates select="makeli"/>
   </xsl:for-each>
</ul>[list]
   <xsl:for-each select="/root/media/bar">
      <xsl:apply-templates select="makeli"/>
   </xsl:for-each>
</ul>
to...

Code:
[list]
   <xsl:for-each select="/root/media/foo">
      <xsl:call-template name="makeli"/>
   </xsl:for-each>
</ul>[list]
   <xsl:for-each select="/root/media/bar">
      <xsl:call-template name="makeli"/>
   </xsl:for-each>
</ul>
 
Old October 13th, 2006, 11:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If your path expressions are wrong then you will receive no output. You haven't shown your source document, so I assume your path expressions are wrong.

Try:

- running using Saxon with the -T (tracing) option, or similar options on other processors

- running in an IDE with a debugger (e.g. Stylus Studio, oXygen)

- trying the path expressions in a free-standing XPath visualizer.

- using a schema-aware XSLT 2.0 processor. This will spot the errors in your path expressions at compile time by comparing them against the schema. (shameless plug, since that's what I'm selling at www.saxonica.com)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 13th, 2006, 06:56 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Michael,

Can you call the Saxon processor from with in the XML file?

Thanks,






Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing higher level nodes from a template mikeymikey XSLT 3 January 3rd, 2008 09:14 PM
Problem in Recursive applying template ismomo XSLT 3 December 29th, 2007 11:35 PM
Applying Multiple Selected Values to a Listbox rit01 ASP.NET 2.0 Professional 1 December 15th, 2006 07:12 AM
Applying a template with subreport nat246 Crystal Reports 0 December 12th, 2005 02:50 AM
Using a recursive template for various nodes spencer.clark XSLT 5 August 2nd, 2005 03:49 PM





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