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
 
Old February 26th, 2004, 08:27 AM
Authorized User
 
Join Date: Jun 2003
Location: Gent, , Belgium.
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default import / call / template match

is there a better/shorter way to do what i do below?

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


<xsl:import href="facturen/deliverednotinvoiced.xsl"/>


<xsl:template match="/">
<html>
<body>
    <xsl:apply-templates select="//BODY"/>
</body>
</html>
</xsl:template>

<xsl:template match="BODY[@id = 'deliverednotinvoiced']">
    <xsl:call-template name="deliverednotinvoiced"/>
</xsl:template>

</xsl:stylesheet>
 
Old February 26th, 2004, 09:10 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Difficult to say as we don't know what you want but you might want to just call the template and pass body as a param:
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:import href="facturen/deliverednotinvoiced.xsl"/>


<xsl:template match="/">
<html>
<body>
    <xsl:call-template name="deliverednotinvoiced">
      <xsl:with-param name="bodyElement" select="//BODY"/>
    </xsl:call-template>
</body>
</html>
</xsl:template>

<xsl:template name="deliverednotinvoiced>
  <xsl:param name="bodyElement"/>
</xsl:stylesheet>
--

Joe
 
Old February 26th, 2004, 09:37 AM
Authorized User
 
Join Date: Jun 2003
Location: Gent, , Belgium.
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default

i'm just looking for an easier/shorter way to select the right xsl template (from the imports), depending on the //BODY/@id.

the code i posted shows at the top 1 import and at the bottom 1 'xsl:template-match'

But in future there'll be more of course. For each import a 'xsl:template match' at the end.

Depending on the //BODY/@id the right 'xsl:template match' will be used.

now, i was just wondering if it is possible to do this in a shorter way, in place of having to import them all, and to define at the bottom a 'xsl:template match' for each import.

each imported xsl at the top represents a different value for BODY/@id
 
Old February 26th, 2004, 11:31 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well your match only has to state 'BODY', when you select a node set to match this will be called on the relevant node, you don't have to make it a specific match for each id.
Templates are only called when apply-templates is invoked, either specifically or due to a default rule being applied.

--

Joe




Similar Threads
Thread Thread Starter Forum Replies Last Post
Param in template match=" " iceandrews XSLT 2 May 7th, 2008 07:37 AM
value-of inside template match RoeZ XSLT 5 April 17th, 2008 12:09 PM
template match doesnt match the required node Tomi XSLT 2 March 12th, 2007 06:24 AM
call template from diff file? (import vs. include) mister_mister XSLT 5 January 31st, 2007 07:12 PM
help with xsl template match enT XSLT 9 September 24th, 2003 06:21 AM





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