I am trying to apply several styles to an XML file using an XSL stylesheet to present the data in several formats.
Would it be best to have a seperate XSL file for every style of presentation or use one stylesheet and call multiple templates?
If i was to use one stylesheet how would i call each template for each style?
I would have thought it would be something like
<xsl:template name="styles">
<xsl:call-template name="templatename">
<!-- This is for my first layout -->
</xsl:call-template>
<xsl:call-template name="templatename">
<!-- This is for my second layout -->
</xsl:call-template>
<xsl:call-template name="templatename">
<!-- This is for my third layout -->
</xsl:call-template>
</xsl:template>
Sorry…i couldn’t read your reply as there is something wrong with my account and it’s preventing your post from being made visible to me.
I have since worked out that i could import each stylesheet or i can have several templates each calling a set of smaller templates to present my data.
The question now is, is there a way i can have a menu at the top such as a bunch of hyperlinks and by click each one will call a different template instead of all the templates at once?
Hopefully when i get a reply i’ll be able to read it
I couldn’t see what i was trying to do in either of those links
What i want to do is have a menu and click a link and the relavent stylesheet will be called
The way i have it working at the minute does work but the document is too long becasue of the same data being displayed in different formats
<xsl:template match="folktask">
<html>
<head>
<link href="xsl2.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
font-size:0.83em;
font-family:arial;
}
</style>
</head>
<body>
<h1 id="showAllUSers">Show all users contact details</h1>
<xsl:call-template name="show_all_users" />
<h2>My festival organisers and festivals</h2>
<xsl:for-each select="member">
<xsl:if test="user/account/userlevel='3'">
<xsl:call-template name="organisers"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="position()=last()">
<div class="count"><h2>Total number of festival organisers: <xsl:value-of select="count(/folktask/member/user/account/userlevel[text()=3])"/></h2></div>
<div class="count"><h2>Total number of festivals: <xsl:value-of select="count(/folktask/member/festival)"/></h2></div>
</xsl:if>
</body>
</html>
</xsl:template>
I wouldn’t say there is a “right” way to do what you want… both ways are equally acceptable.
What I’d do is that if there are subtle differences in the presentation, I’d embed them in the same stylesheet, and if they’re too many, I’d place them in a separate stylesheet.