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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:27:30+00:00 2026-06-09T02:27:30+00:00

So I have this code: <xsl:for-each select=item> <Row> <Cell Borders=#ffffff> <xsl:attribute name=Background> <xsl:choose> <xsl:when

  • 0

So I have this code:

<xsl:for-each select="item">
<Row>
    <Cell Borders="#ffffff">
      <xsl:attribute name="Background">
        <xsl:choose>
          <xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
          <xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
        </xsl:choose>
      </xsl:attribute>
      <Paddings Left="5" Right="5" Top="2" Bottom="2"/>
      <xsl:for-each select="//queries/query/selection/dataItem">
      <Text Style="TableContent">                                               
        <xsl:value-of select="@name"/>                                                                                        
      </Text>
      </xsl:for-each>   
    </Cell>
    <Cell Borders="#ffffff">
      <xsl:attribute name="Background">
        <xsl:choose>
          <xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
          <xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
        </xsl:choose>
      </xsl:attribute>
      <Paddings Left="5" Right="5" Top="2" Bottom="2"/>
      <Text Style="TableContent">
      <xsl:choose>
      <xsl:when test="qi">
        <xsl:value-of select="qi"/>
      </xsl:when>
      <xsl:otherwise>
        <Text>N/A</Text>
      </xsl:otherwise>
      </xsl:choose> 
      </Text>
    </Cell>
</Row>
</xsl:for-each>

I am trying to pull information from an XML, however the information is in two different nodes, with two different XPATH. Also I need to match the information from one node, i.e. name. to another node located under a different location, with a different XPATH. is there a way to go through each name in the node and match it to the information found in another node all in the same XML??

EDIT
Added link to original XML

Thank you very much

  • 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-06-09T02:27:31+00:00Added an answer on June 9, 2026 at 2:27 am

    It looks like you are trying to access dataItem elements where the expression element matches the name element of the current item.

    In this case, you can create a key to look up dataItem records by their expression value

    <xsl:key name="dataItems" match="dataItem" use="expression" />
    

    Then, instead of looping through all dataItem records like you are doing currently…

    <xsl:for-each select="//queries/query/selection/dataItem"> 
    

    You can replace this line to simply use the key to iterate over only those dataItems with the relevant value

     <xsl:for-each select="key('dataItems', name)">
    

    Here, name is the name element under the current item element on which you are currently positioned.

    Here is some fuller XSLT, to show the xsl:key element in context

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:key name="dataItems" match="dataItem" use="expression"/>
    
       <xsl:template match="root">
          <xsl:apply-templates select="lineage"/>
       </xsl:template>
    
       <xsl:template match="lineage">
          <xsl:for-each select="item">
             <Row>
                <Cell Borders="#ffffff">
                   <xsl:attribute name="Background">
                      <xsl:choose>
                         <xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
                         <xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
                      </xsl:choose>
                   </xsl:attribute>
                   <Paddings Left="5" Right="5" Top="2" Bottom="2"/>
                   <xsl:for-each select="key('dataItems', name)">
                      <Text Style="TableContent">
                         <xsl:value-of select="@name"/>
                      </Text>
                   </xsl:for-each>
                </Cell>
                <Cell Borders="#ffffff">
                   <xsl:attribute name="Background">
                      <xsl:choose>
                         <xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
                         <xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
                      </xsl:choose>
                   </xsl:attribute>
                   <Paddings Left="5" Right="5" Top="2" Bottom="2"/>
                   <Text Style="TableContent">
                      <xsl:choose>
                         <xsl:when test="qi">
                            <xsl:value-of select="qi"/>
                         </xsl:when>
                         <xsl:otherwise>
                            <Text>N/A</Text>
                         </xsl:otherwise>
                      </xsl:choose>
                   </Text>
                </Cell>
             </Row>
          </xsl:for-each>
       </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code: <xsl:for-each select=GroupsServed> <xsl:value-of select=./>,<br/> </xsl:for-each></font> I'm trying to add
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I have XSLT 1.0 code like this: <xsl:key name=enemyItems match=metadata[attributes/metadata_key/@value = 'enemylist'] use=attributes/metadata_refkey/@value/> <xsl:template
I have nested xsl:for loops: <xsl:for-each select=/Root/A> <xsl:for-each select=/Root/B> <!-- Code --> </xsl:for> </xsl:for>
I have <xsl:for-each select=ancestor-or-self::*> <xsl:variable name=expression select=name() ></xsl:variable> </xsl:for-each> below I have href and
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I don't really know XSL but I need to fix this code, I have
I have a menu generated in a Umbraco macro: <xsl:for-each select=$currentPage/* [@isDoc and string(umbracoNaviHide)

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.