Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Context

Reply
Thread Tools

Context

 
 
Eliza Zadura
Guest
Posts: n/a
 
      09-10-2003
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">
<xslaram 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!
 
Reply With Quote
 
 
 
 
Marrow
Guest
Posts: n/a
 
      09-11-2003
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">
> <xslaram 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" <(E-Mail Removed)> wrote in message
news:3f5ef1f6$0$62080$(E-Mail Removed)...
> 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">
> <xslaram 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!



 
Reply With Quote
 
 
 
 
Eliza Zadura
Guest
Posts: n/a
 
      09-11-2003
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spring context refering to application context Jani Tiainen Java 3 08-27-2007 07:24 AM
return HttpStatusCode.ServiceUnavailable in the context.context.Response.StatusCode (Http response code 503) Flip Rayner ASP .Net 1 01-23-2007 06:35 AM
How to retrieve a session Bean in the Context in a class with the Context reference asd Java 1 11-09-2006 05:00 PM
Strange Context Error: Context 0x197ee0 is disconnected in VS 2005 =?Utf-8?B?U3VuU21pbGU=?= ASP .Net 0 01-10-2006 03:59 PM
Context.Items vs Context.Handler (passing values between pages) VS_NET_DEV ASP .Net 2 05-25-2004 01:16 PM



Advertisments