RE: [xsl] Passing parameters using <xsl:apply-templates>

Subject: RE: [xsl] Passing parameters using <xsl:apply-templates>
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 16 Feb 2008 19:31:02 -0000
You haven't really shown what you're doing in enough detail for me to see
what you're doing wrong. In particular, I don't see any xsl:apply-templates
and I don't see any parameters. But why don't you try:

<xsl:for-each select="//@filename">
  <xsl:variable name="filename" select="."/>
  <xsl:variable name="doc" select="document($filename)"/>
   ...

</xsl:for-each> 

> -----Original Message-----
> From: Mark [mailto:charltonrainbird@xxxxxxxxxxxxxx] 
> Sent: 16 February 2008 19:11
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Passing parameters using <xsl:apply-templates>
> 
> I'm still bashing my head against this problem. Maybe I'm 
> making this more complicated than necessary and don't need to 
> use parameters, which I still can't get to work. I think this 
> is because I have to use <xsl:apply-templates to set the 
> value of my parameter and I can't get this to work when I 
> need to use the document function. I'm not sure whether this 
> is fundamentally wrong or just because I can't get it to work.
> 
> Essentially, I'm processing an xml file which is a list of 
> xml files using the document function:
> 
> <xsl:for-each select="document(//@filename)">
> 
>  .. processing instructions to use <xsl:for-each> and 
> <xsl:result-document> along with <xsl:apply-templates> to 
> produce split output files from each of the xml files listed 
> in that initial file
> 
> What I need is the document-uri(.) (which was what I was trying to do
> originally) or, alternatively, as Eliot suggested, the value 
> of @filename to use as the prefix for my output file names.
> 
> Problem is that I just keep ending up with the value of the 
> input file name, not the value of the nodes attribute 
> @filename that it processes. Alternatively, I end up with nothing.
> 
> Any further pointers?
> 
> Thanks for your patience.
> 
> Mark
> 
> 
> On Sat, Feb 16, 2008 at 2:16 PM, Michael Kay 
> <mike@xxxxxxxxxxxx> wrote:
> > > Another tip: a very easy-to-make and hard-to-diagnose mistake
> >  > is forgetting to specify tunnel="yes" on the param statements
> >
> >  You can reduce the risk by getting into the habit of specifying  
> > required="yes" on all parameters unless you really want 
> them to be optional.
> >
> >  Michael Kay
> >  http://www.saxonica.com/

Current Thread