Re: [xsl] More than one parameter for stylesheet

Subject: Re: [xsl] More than one parameter for stylesheet
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 21 Jul 2005 17:29:37 +0100
   The stylesheet is here:
   
   <?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   
     <xsl:template match="/">
       <bookshelf>
         <xsl:apply-templates select="//category[@categoryid='CAT1']"/> 
       </bookshelf>
     </xsl:template>        
   
     <xsl:template match="category[@categoryid='FTUKSDIV3']">
       <xsl:copy-of select="../../*"/>                
     </xsl:template>    
   </xsl:stylesheet>
   

Is that really your stylesheet (with different  categoryid)? assuming
you don't have nested categories, It seems very strange as it is
written as the second template woul dbever be applied.

If you had      <xsl:template match="category[@categoryid='CAT1']">
It would be applied but there is no need to go all teh way down and then
come back up. 

Assuming that you did intend to have the same cataegory, apparently want
to copy all the children of the grandparent of this category, so you
don't want to apply templates at all, just:


<xsl:param name="cat" select="'CAT1'"/>

  <xsl:template match="/">
       <bookshelf>
         <xsl:copy-of select="//*[*/category[@categoryid=$cat]/*"/> 
       </bookshelf>
     </xsl:template>        

although if you know how deep you need to go replacing //* by /a/b/c is
likely to be a big improvement.

Having the parameter in a select rather than a match is good (because
it's illegal to have parameters in a match, although i understand xalan
doesn't enforce that) then you can set the param cat to any string on
the command line (the -PARAM flag for xalan)

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread