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 6925975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:32+00:00 2026-05-27T10:51:32+00:00

I have the following XSLT variable: <xsl:variable name=superid select=/contentdata/id/> Furthermore, I have a node

  • 0

I have the following XSLT variable:

<xsl:variable name="superid" select="/contentdata/id"/>

Furthermore, I have a node with subnodes:

<nodes>
    <node name="foo" id="bar" />
    <node name="john" id="doe" />
    <node name="jane" id="tarzan" />
</nodes>

Now, I’d like to check if a node with an id attribute that equals superid exists.

I’ve tried the following (which obviously doesn’t work):

<xsl:if test="/nodes/node[@id = $superid]">Yes, Sir!</xsl:if>
  • 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-27T10:51:33+00:00Added an answer on May 27, 2026 at 10:51 am

    Use:

    boolean(/nodes/node/@id = $superid)
    

    Here is a complete transformation, showing this in action:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:variable name="vDoe" select="'doe'"/>
     <xsl:variable name="vXyz" select="'xyz'"/>
    
     <xsl:template match="/">
         id attribute with value "doe' exists: <xsl:text/>
         <xsl:value-of select="boolean(/nodes/node/@id = $vDoe)"/>
    ==========
         id attribute with value "xyz' exists: <xsl:text/>
         <xsl:value-of select="boolean(/nodes/node/@id = $vXyz)"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the provided XML document:

    <nodes>
        <node name="foo" id="bar" />
        <node name="john" id="doe" />
        <node name="jane" id="tarzan" />
    </nodes>
    

    the wanted, correct result is produced:

         id attribute with value "doe' exists: true
    ==========
         id attribute with value "xyz' exists: false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XSLT code that almost does what I want: <xsl:variable name=scoredItems
I have the following XSLT macro (in Umbraco) <xsl:param name=currentPage/> <xsl:template match=/> <xsl:apply-templates select=$currentPage/imageList/multi-url-picker
I have the following in my xslt file: <xsl:param name=predicate select=//Event /> <xsl:apply-templates select=$predicate
I have the following XSLT Template: <xsl:template name=foo> <xsl:param name=arg1>0</xsl:param> <xsl:param name=arg2 /> <xsl:param
I have written the following XSLT template: <xsl:template match=foo:*> <xsl:processing-instruction name=php>$s = ob_get_clean(); ob_start();
Assume I have the following temp documents: <xsl:variable name=emc> <people> <person id=1> <name>Jim</name> </person>
I have the following code block in my xslt; <xsl:when test=StatusData/Status/Temperature > 27> <td
Lets say I have a xslt stylesheet like the following: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
i have the following xslt sheet: <?xml version=1.0 encoding=UTF-8 ?> <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform version=1.0> <xsl:variable
I have a following xslt: <span><xsl:text disable-output-escaping=yes><![CDATA[&nbsp;Some text]]></xsl:text></span> After transformation I get: <span>&amp;nbsp;Some text</span>

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.