xsl-list
[Top] [All Lists]

Re: More than one parameter for stylesheet

2005-07-21 10:01:54
Hello,

sorry the mismatching category name was my mistake. I wanted to simplify it
but only changed the upper part.

I think you helped me a lot in simplifying the stylesheet. As I said I am
not an expert and I kept that stylesheet because it worked. When I look at
your stylesheet, however, I have another question:

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

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

What does the first line exactly mean? As I mentioned before, I want to
insert the parameter via command line. So, why should I set it in the first
line to CAT1 (assuming that I want to insert CAT1 - CAT39 in the command
line)? I assume I would need something that assigs the parameter from the
commandline to the variable. How wouild this look like?

How would the command line look like since I would have two -IN parameters
(see my original posting)?

Many thanks for your help,
Karl

--- Ursprüngliche Nachricht ---
Von: David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] More than one parameter for stylesheet
Datum: 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[(_at_)categoryid='CAT1']"/> 
       </bookshelf>
     </xsl:template>        
   
     <xsl:template match="category[(_at_)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[(_at_)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[(_at_)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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse f�r Mail, Message, More +++

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>