[xsl] Parameters in the XPath for apply templates.

Subject: [xsl] Parameters in the XPath for apply templates.
From: <bjchamb@xxxxxxxxxxxxx>
Date: Fri, 7 May 2004 11:12:10 -0400
First, the problem I'm having. I have the following template:

<xsl:template name="process">
<xsl:param name="type"/>
<xsl:param name="doc"/>
<xsl:apply-templates select="document($doc)//$type"/>
</xsl:template>

The problem is that the $type isn't allowed here. I have confirmed that if I
do select="document($doc)//itemA" it works.

I'll explain more about what I'm doing in hopes that it will help.

My xml file is something like this:
<file src="a"/>
<file src="b"/>
...
<file src="z"/>

Each of these, correspond to xml files that I want to process. The structure
of these have several different things that I'm trying to draw out, for
example, if a.xml contained the following:

<contents>
<para>
<itemA name="blah"/>
<itemA name="what"/>
<itemB name="foo"/>
</para>
</contents>

And I want to generate output similar to the following:

<H1>A</H1>
blah
what
<H1>B</H1>
fooI want to go over all the files in the index.xml (the one that the xslt
is called on) and for all the files in create a grouped list of all items of A
and all items of B. In order to handle the grouping I'm planning on adapting
the algorithm for grouping that I found on Jeni's page, but first I need to get
through this problem of processing the documents. What I currently do is
iterate over all files and call this function with type equal to itemA and doc
equal to the appropriate file name. After processing all files using this, i
then call this template with type equal to itemB and doc equal to the
appropriate file name again. I know it is innefficient to process the files
twice, but I can't really think of any other way of processing this without
using multiple levels of grouping or something like that, and I'm really not up
to the task of figuring out how to do that...

All I really need is help getting the $type working, but any help that can be
offered will be greatly appreciated.

Current Thread