Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 567599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:06:00+00:00 2026-05-13T13:06:00+00:00

Within an XSL sheet, I have a nodeset in a variable, $context . How

  • 0

Within an XSL sheet, I have a nodeset in a variable, $context.

How do I properly query an attribute of the topmost node in $context? Obviously, if $context was the current node, I would just write "@attname", but it is not. Currently I do $context/../@attname which is doesn’t look great to me.

EDIT

Ok, the data.
Here is what I see in the VS.

In case you wonder how I got this strange thing: I UNION’ed a node with it’s subnodes and an attribute selected out from a different node:

<xsl:with-param name="context" select=". | ../@res" />.

I’m not completely aware what results from this, but I can see that it works. Highlighted is the attribute I’m interested in.

Maybe that creates an attribute attached to nothing, if that makes sence at all 😐

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:06:00+00:00Added an answer on May 13, 2026 at 1:06 pm
    $context/../@attname
    

    does not make too much sense. You can’t go “up” here, as this would bring you “outside of” $context.

    If the node-set contains something like this (a single node)

    <node attname="foo">
      <bar />
    </node>
    

    then:

    $context/@attname
    

    If it is like this (a list of nodes):

    <node attname="foo">
      <bar />
    </node>
    <node attname="foo">
      <bar />
    </node>
    

    then:

    $context[1]/@attname
    

    All of this does not work if the variable contains a result tree fragment (RTF). In this case, you need to employ an extension function called node-set(). Most XSLT processors provide this function.


    EDIT: Your variable holds a union of the current node and a naked attribute node from its parent:

    <xsl:with-param name="context" select=". | ../@res" />
    

    The result of a union will always be in document order, so even though you selected the attribute after the context node in the XPath, in the resulting node set it will come before – the parent of the context node is before the context node in document order.

    You need $context[1] to grab the attribute node, and $context[2] to grab the other node.

    I must say that this is some strange and probably unnecessary complicated use of variables. I’m sure there is a way to do this in a less painful fashion. For example you could do

     <xsl:with-param name="context" select="." />
    

    and then use $context/../@res in the called template. That would be a lot more straight-forward than what you are trying now.

    Also, if the <xsl:with-param> you show here is part of an <xsl:call-template>, you can drop that param entirely. When a template is called (instead of applied), then the context node does not change, passing it in is redundant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried this Visual Studio plugin to see if… May 14, 2026 at 12:46 am
  • Editorial Team
    Editorial Team added an answer Are you hitting the loop back issue here? http://support.microsoft.com/kb/896861 May 14, 2026 at 12:46 am
  • Editorial Team
    Editorial Team added an answer Maybe one of these ideas will help you to solve… May 14, 2026 at 12:46 am

Related Questions

I have an xslt sheet with some text similar to below: <xsl:text>I am some
I would like to either prevent or handle a StackOverflowException that I am getting
I have a document, something like this: <root> <A node=1/> <B node=2/> <A node=3/>
I'm attempting to apply an XSL transform to an XML file inside an SSIS
I am having trouble transforming particular characters from an XML feed into XHTML. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.