Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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>
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:18 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.