variables in expressions

Sorry about all the questions. Ah, the joys of being new to xslt :stuck_out_tongue:

What I am trying to accomplish this time is output dependent upon presence of an attribute matching a variable. Here is roughly what I am trying to accomplish. Obvously, it doesn’t work, so this hinges on being able to understand theoretical, rather than actual, xslt.

<xsl:template>
  <xsl:variable name="page" select="1" />
  . . .
  <xsl:apply-templates select="question[@page='$pg']" />
</xsl:template>
</pre><BR><BR>and in the xml<BR><BR><pre class="ip-ubbcode-code-pre">
<question page="1"> ... </question>
<question page="2"> ... </question>
...



Of course, it works when I replace @page=‘$pg’ with @page=‘1’ , or if I change the value in the xml to , the idea being that it will only display s with the correct page specified.

Ultimately, I’d really like to replace the variable with a param, because it is going to be set from outside the xslt (ASP.net), so the same xml file can be used and, based on the page param set from ASP.net, display elements corresponding to the current page.

What do I need to do to make it work with the variable, assuming the variable matches? What to make a param work?

Thanks in advance, sorry if it’s a lot of trouble for a simple answer. We all gotta start somewhere.

-Term

Nevermind.

I dont know why it all-of-a-sudden decided to work, but I must have made some small change I don’t notice to make it work. It works now for params (local and global) as well as variables.

Sorry for the useless post.

-Term

Hi

omitting the quotes, i.e. using
select=“question[@page=$pg]”
instead of
select=“question[@page=‘$pg’]”
should work

Uli

Yeah, I think that’s what the problem was. When I fixed it, i didn’t realize what I’d done, but now that I’ve repeated it, I’m sure thats what it was. Thanks.

-Term