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 September 24th, 2006, 10:56 AM
Authorized User
 
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Switching list content dynamically ...

Dear All,

I currently have an XSLT template which displays a variety of selectable lists which are used to filter the data in the main form. These work fine. Now I would like to allow the user to select the values declared in the lists to allow a wider variety of selection (e.g. rather than displaying a list of 'Plants', the list would switch to display a list of 'departments' or 'teams').

At the moment I use the following syntax (excerpts) ...

    [... code ... key declaration: ]
<xsl:key name="kplnt" match="PLANT" use="." />
    [... code ... selection form: ]
   <form name="formsel" id="formsel">
          [... code ... List of Plants: ]
    <label for="selplnt">Plant</label><br />
    <select size="5" name="selplnt" id="selplnt">
     <xsl:apply-templates select="//PLANT[generate-id()=generate-id(key('kplnt',.))]" mode="selectplnt">
     <xsl:sort order="ascending"/>
     </xsl:apply-templates>
    </select>
          [... code ... Run call to javascript: ]
    <input type="button" value="Run Select" onClick="filter(document.formsel.selplnt.value)"/>
    [... code ... End of form: ]
   </form>
    [... code ... Choose statement activated by selection of Plant $plnt: ]
<xsl:choose>
 <xsl:when test="$plnt">
    [... code ...]

[... Key declaration: ]
<xsl:template match="//PLANT[generate-id()=generate-id(key('kplnt',.))]" mode="selectplnt">
  <option value="{.}"><xsl:value-of select="."/></option>
</xsl:template>

Here I use javascript to apply filters to my display and so I am hoping that I can integrate an extra piece of code to 'flip' the contents of the List Boxes (in this example 'Plant'). Once I have got this working, then I will see if I can flip the display in the main body of the display. This would give a lot of extra flexibility and allow the users to browse a lot more data.

Anyway, I hope that somone out there has come across and has tackled similar issues and can point me in the right direction :-)

Many thanks,
Alan Searle

PS: I have done quite a lot of googling and notice that Jenny Tennison offers some examples of mixed sources of data and/or XSL. However, this seemed to be static whereas I am looking for a dynamic method that can be switched by the user.


 
Old September 24th, 2006, 11:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can sometimes achieve the flexibility you need by replacing an element name PLANT by an an expression *[name()=$param]. Unfortunately there are restrictions on where you can do this, for example XSLT 1.0 doesn't allow variables in a match pattern. For the kind of flexibility you are looking for, you may be better off using dynamically constructed or modified stylesheets - remember you can write stylesheets that transform stylesheets.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic List Content cyberddindia Classic ASP Basics 3 October 24th, 2006 10:29 AM
Adding XSLT transformed XML content dynamically jacob ASP.NET 1.x and 2.0 Application Design 2 December 1st, 2005 04:40 PM
Dynamically Changing the content of a table cell asdasd Javascript 4 February 18th, 2005 01:44 PM
How to split pages when content load dynamically bekim Classic ASP Basics 0 August 5th, 2004 02:57 AM





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