473,385 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Context

The following question is about XPath and context, as I am not sure I'm
grasping the concept entirely and this is causing me some problems while
working on my XSL transformation.

I have checked the XPath specification and am somewhat familiar with the
different addressing mechanisms. What confuses me is the context when
using templates and various (nested) <xsl:for-each>, <xsl:if> and
<xsl:when> expressions.

For example, say I have a named template where test-param is the value
of a certain node.

<xsl:template name="test_temp">
<xsl:param name="test_param"/>
...
...
<xsl:for-each select="[some other node]">

<!--here, I assume the context is that of [some other node], and not the
node represented by test_param?-->

<xsl:if test="[yet another node]">

<!--What about the context here, is it that of [yet another node]?-->

</xsl:if>
</xsl:for-each>

<!--And here, am I back to the original context, the one defined by the
test_param?-->

</xsl:template>

And so on, and so forth...
To put it briefly: Does every expression that evaluates a set of nodes
change the context to that particular set, thus enabling me to use ./
while referring to attributes or other subnodes of that node?

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
2 2342
Hi Eliza,
For example, say I have a named template where test-param is the value
of a certain node.

<xsl:template name="test_temp">
<xsl:param name="test_param"/>
^^^^^ the context here will be whatever the context node was at the point of
the <xsl:call-template>. Parameters have no effect on the context. ..
..
<xsl:for-each select="[some other node]">

<!--here, I assume the context is that of [some other node], and not the
node represented by test_param?-->
^^^^^ yes, the context node will be the [some other node]
<xsl:if test="[yet another node]">

<!--What about the context here, is it that of [yet another node]?-->

</xsl:if>
</xsl:for-each>

<!--And here, am I back to the original context, the one defined by the
test_param?-->
^^^^^ No, because the context was never the node(s) in the $test_param - the
context will revert to the context node at the point of the
<xsl:call-template>
</xsl:template>

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Eliza Zadura" <el**********@sync.se> wrote in message
news:3f***********************@news.frii.net... The following question is about XPath and context, as I am not sure I'm
grasping the concept entirely and this is causing me some problems while
working on my XSL transformation.

I have checked the XPath specification and am somewhat familiar with the
different addressing mechanisms. What confuses me is the context when
using templates and various (nested) <xsl:for-each>, <xsl:if> and
<xsl:when> expressions.

For example, say I have a named template where test-param is the value
of a certain node.

<xsl:template name="test_temp">
<xsl:param name="test_param"/>
..
..
<xsl:for-each select="[some other node]">

<!--here, I assume the context is that of [some other node], and not the
node represented by test_param?-->

<xsl:if test="[yet another node]">

<!--What about the context here, is it that of [yet another node]?-->

</xsl:if>
</xsl:for-each>

<!--And here, am I back to the original context, the one defined by the
test_param?-->

</xsl:template>

And so on, and so forth...
To put it briefly: Does every expression that evaluates a set of nodes
change the context to that particular set, thus enabling me to use ./
while referring to attributes or other subnodes of that node?

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2
Thank you for your reply. That is what I thought, but I wanted it
confirmed.

What about if I have nested for loops? Will the context of the inner
loop be that of the inner select?

I'm having to do quite horrible loops and conditions to accomplish what
I need, and find all this a bit confusing...

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

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

Similar topics

1
by: SPG | last post by:
Hi, I am relatively new to TOMCAT, and am trying to deploy a web app using it. I have a domain name that I want to use to access my web app directly. By default, I deploy my WAR, and it deploys...
4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
5
by: Nadav | last post by:
Hi, I am using FileStream's Async API: BeginRead/EndRead, upon completion callback execution I use the read data and call EndRead, Taking that in mind, I Wonder... does calling EndRead will cause...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
2
by: dave | last post by:
This little problem is driving me nuts!! On my webform page I create 2 variables.. Protected p_dml As String = "I" Public Const mwv_id As Integer = 0 ' originally had mwv_id as Protected
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
4
by: Andrus | last post by:
For winforms application with multiple related forms it is reasonable to create Linq database context object in start of application. Context object is released only when application exits. So...
4
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.