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

  • SEARCH
  • Home
  • 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 939929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:52:19+00:00 2026-05-15T21:52:19+00:00

I have a rather specific question perhaps.. I have a user that will enter

  • 0

I have a rather specific question perhaps..

I have a user that will enter in some criteria on a form, and then it builds an XPath from their input. Let’s say their input creates the following:

//*[@color='red']/@*

Which essentially means they want to see all attributes of any element with the @color = red.

I can display exactly what the expression asks for (all attributes), but I wanted to add information that could be useful, such as the element’s name the attributes belong to.

One option would be to add to the XPath to also display the elements name: (a shorter way to create this expression without the use of | would be nice to know.. so if you have suggestions, that would be awesome!)

//*[@color='red']/@* | //*[@color='red']

Another option (that I hope is possible) is to select the element name the attribute belongs to from the template without altering the XPath expression (because I might want to use this expression in another context without the element name).

I want to have this XSLT:

<xsl:param name="built_expression" select="//*[@color='red']/@* />
<xsl:template match="/">
    <html>
        <body>
            <table>
                <tr>
                    <th>Element Name</th>
                    <th>Element Content</th>
                </tr>

                <xsl:apply-templates select="$built_expression"/>
            </table>
        </body>
    </html>
</xsl:template>

<xsl:template match="@*|node()">
    <tr>
      <td>
        <xsl:value-of select="ELEMENT name()" />
      </td>
      <td>
        <xsl:value-of select="node()" />
      </td>
    </tr>

    ... other display stuff to do with the attributes ...
</xsl:template>

This obviously doesn’t work… but I hope you get my point..

<xsl:value-of select="name()"/>

just returns the name of the attribute, but I need to select the name of the attribute’s element.

Thanks! Let me know if I need to clarify anything!

  • 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-15T21:52:20+00:00Added an answer on May 15, 2026 at 9:52 pm

    You need just this XPath:

    name(..)
    

    This works if the context node is your selected attribute node.

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

Sidebar

Related Questions

I have some rather odd behavior in my D program that I've narrowed down
I have a rather specific question about how to exclude items of one list
I have some major performance issues when asking a specific nhibernate question. I have
I have some rather mangled code that almost produces the tangible price/book from Yahoo
I have rather large project that uses ICU regex classes. Basically it might run
Have a rather simple question. Does anyone knows if i can use jparallax both
I have a rather huge query that is needed in several stored procedures, and
I've started working on some Android applications and have a question regarding how people
I know some have already asked the question but so far, the answers are
This question was asked already here , but rather than answering the specific question,

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.