472,954 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

need help understanding PARAMs

I eventually want to pass a variable to my XSLT file, but, for now, I'm just
trying to be able to declare it globally in the XSLT file itself.

So, I added this to the top of the page:

<xsl:param name="currentPage">5</xsl:param>

BTW, this is a menu I'm creating and, as such, need to know what node it the
'current page' the site/menu is on.

So, elsewhere in my XSLT file, where I want to see if the link I'm
generating matches the current page so I can give it a different class, I
use this:

<xsl:when test="contentID=$currentPage">

This works.

However, I'm trying to establish the current node from the get go using the
match attribut of the xml:template:

<xsl:template match="*[contentID=5]">

This finds the item with the contentID=5

If I try to bring in the parameter like this:

<xsl:template match="*[contentID=$currentPage]">

I get a "Variables may not be used within this expression.
*[contentID=-->$currentPage<--]" error.

Is this just a syntax error on my part, or can I not do what I'm trying to
do?

-Darrel
Nov 12 '05 #1
2 1340

"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I eventually want to pass a variable to my XSLT file, but, for now, I'm just trying to be able to declare it globally in the XSLT file itself.

So, I added this to the top of the page:

<xsl:param name="currentPage">5</xsl:param>

BTW, this is a menu I'm creating and, as such, need to know what node it the 'current page' the site/menu is on.

So, elsewhere in my XSLT file, where I want to see if the link I'm
generating matches the current page so I can give it a different class, I
use this:

<xsl:when test="contentID=$currentPage">

This works.

However, I'm trying to establish the current node from the get go using the match attribut of the xml:template:

<xsl:template match="*[contentID=5]">

This finds the item with the contentID=5

If I try to bring in the parameter like this:

<xsl:template match="*[contentID=$currentPage]">

I get a "Variables may not be used within this expression.
*[contentID=-->$currentPage<--]" error.

Is this just a syntax error on my part, or can I not do what I'm trying to
do?
In XSLT 1.0 it is illegal to have an xsl:variable reference within a match
pattern, because this may lead to a circular definition.

One workaround is the following:

<xsl:template match="*[contentID]">
<xsl:if test="contentID = $currentPage">

<!-- Put all processing here -->
</xsl:if>
</xsl:template>
BTW, it is more straightforward to write:
<xsl:param name="currentPage" select="5">

than
<xsl:param name="currentPage">5</xsl:param>

Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Nov 12 '05 #2
> One workaround is the following:
<xsl:template match="*[contentID]">
<xsl:if test="contentID = $currentPage">
<!-- Put all processing here -->
</xsl:if>
</xsl:template>


Hmm...that doesn't work for me (thought that could be due to other problems
with my logic).

I want the initial template to match a very specific node, so I can then
navigate up and down relatively from that particular node.

The if doesn't quite seem to do the same thing as a template match (in my
head, at least).

So, I suppose the problem is with my match and i need to rethink how to do
this with the if.

If it helps, here's what I have now (It's MESSY, though and not fully
thought out)

================================================== =============

<xsl:param name="currentPage">5</xsl:param>

<xsl:template match="*[contentID=5]">
<!-- this is the CURRENT PAGE node: -->
<xsl:if test="../../page">
PARENT(S):
<ul>
<xsl:for-each select="../../page">
<li><a href="{linkURL}"><xsl:value-of select="linkTitle"/></a></li>
</xsl:for-each>
</ul>
</xsl:if>
<!-- this is the SIBLING node(s): -->
<xsl:if test="../page">

SIBLING(S):
<ul>
<xsl:for-each select="../page">
<xsl:choose>
<xsl:when test="contentID=$currentPage">
<li>CURRENT PAGE <xsl:value-of select="linkTitle" /><br />

<!-- does node have children? to find out check for page element -->
<xsl:if test="page">
CHILDREN:
<ul>
<xsl:for-each select="page">
<li><xsl:value-of select="linkURL"/><xsl:value-of
select="linkTitle"/></li>
</xsl:for-each>
</ul>
</xsl:if>

</li>
</xsl:when>
<xsl:otherwise>
<li>SIBLING PAGE <xsl:value-of select="linkTitle" /><br /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>

</xsl:if>

</xsl:template>

================================================== ==============

-Darrel
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mihaly | last post by:
Hello, i'm using a VC++ com+ object, it's reference in vs .net, this com object have a function that have to params, the interop com object recive Object Params and the original com object say...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
3
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
8
by: David Duerrenmatt | last post by:
Hi there For some reasons, I've to use Python 1.5.2 and am looking for a workaround: In newer Python versions, I can call a function this way: func = some_function func(*params) Then,...
3
by: paapa21 | last post by:
I have two datalist in two panel (viewdatalistpanel and updateDatalist). One datalist bring all student details from the database and the other update the student details in the database. On page...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
6
by: daveyand | last post by:
Hey Guys, I've stumped. I created a function that does various things to select boxes. Namely Get All selected indexes, populate array with these values
2
by: FFMG | last post by:
Hi, I was looking at http://www.php.net/manual/en/function.call-user-func-array.php and I was wondering... Given, // -- function foo( &$params) {
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.