[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: More than one parameter for stylesheet

Subject: Re: More than one parameter for stylesheet
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 21 Jul 2005 17:29:37 +0100
Re:   More than one parameter for stylesheet
   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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.