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 17th, 2006, 03:55 AM
Authorized User
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lot's of 'when' clauses ...

Hallo All,

This is a bit of a design question and so I hope that someone can give me a second opinion and maybe some tips?

I have an XSL stylesheet with a range of options that the user can choose (presented in list-boxes). For each selection, a different set of processing is triggered. The parameters (for the various displays) processed by a little block javascript: Basically this just sets the new parameters and reposts the page.

There is a lot of grouping/summing so the first action is to call (one of a number of) the following ...

<xsl:when test="$plevel='plt'">
<xsl:apply-templates select="rep_base[generate-id()=generate-id(key('kteam', team)]" mode="dteam">
[? Possible match location ?]
[other when statements]

This in turn, then calls the following:

<xsl:template match="rep_base" mode="dteam">
<td><xsl:value-of select="team" />
<td ALIGN="RIGHT"><xsl:value-of select="sum(key('kteam', team)[plant_code=$pfiltfld]/GOODS_CNT)" />

All this works fine but now it is becoming extremely complicated with a whole stack of 'when' statements calling various templates presenting various views of the data.

I then thought I would try putting the 'template' inside the 'apply-templates select' clause but the syntax was not accepted.

So my question here is: How can I best tidy up all these 'when' clauses and make clear blocks of functionality which enable easier maintenance. i.e. it is very difficult to jump between the apply-template clause and the actual template display.

Or maybe I should separate things and use 'include' statements to add the other styles? But I have considered this and am not sure how I would get the selection lists, the javascript and the 'included' templates to interact (i.e. it might be more confusing).

Anyway, any tips on how to keep 'mushrooming' code under control would be a great help.


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