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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:44:29+00:00 2026-06-16T19:44:29+00:00

I am trying to understand how to deduce a solution using a code I

  • 0

I am trying to understand how to deduce a solution using a code I already wrote.

In order to simplify I will explain first what I want to do and what I got so far.

Suppose I have an XML variable in XSLT containing few nodes with the same title attribute.

Using @Dimitre Novatchev solution I have managed to combine them into one node.

So If I had :

<t>
    <GroupData ID="xxx" Key="4" Temp="yyy">
        <ItemData ID="zzz" Value="3"/>
    </GroupData>
    <GroupData ID="yyy" Key="4" Temp="yyy">
        <ItemData ID="abc" Value="3"/>
    </GroupData>
    <GroupData ID="zzz" Temp="yyy">
        <ItemData ID="pqr" Value="1982"/>
    </GroupData>
    <GroupData ID="xxx" Key="4" Temp="yyy">
        <ItemData ID="www" Value="1982"/>
    </GroupData>
    <GroupData ID="yyy" Key="4" Temp="yyy">
        <ItemData ID="def" Value="1982"/>
    </GroupData>
    <GroupData ID="zzz" Temp="yyy">
        <ItemData ID="tuv" Value="1982"/>
    </GroupData>
</t>

After using the following key

<xsl:key name="kGDByIdKey" match="GroupData" use="concat(@ID, '+', @Key)"/>

I would get :

<t>
   <GroupData ID="xxx" Key="4" Temp="yyy">
      <ItemData ID="zzz" Value="3"/>
      <ItemData ID="www" Value="1982"/>
   </GroupData>
   <GroupData ID="yyy" Key="4" Temp="yyy">
      <ItemData ID="abc" Value="3"/>
      <ItemData ID="def" Value="1982"/>
   </GroupData>
   <GroupData ID="zzz" Temp="yyy">
      <ItemData ID="pqr" Value="1982"/>
      <ItemData ID="tuv" Value="1982"/>
   </GroupData>
</t>

Now I would like to modify this one a little bit, I would like to be able to merge/combine titles by my decision. In that in mind, in the example above I would like to define xxx and zzz to be in the same group although they are using a different title (Extreme cases – in my workspace I defined them to be identical – I might have more cases like this).

I would appreciate if you can tell me what should be the direction to do it generally ( I suppose I need to modify my key or using alternative method – generate-id or something).

I find myself implementing only bad solutions requiring a lot of unnecessary effort.

  • 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-16T19:44:29+00:00Added an answer on June 16, 2026 at 7:44 pm

    I would guess this is XSLT1 which is a shame as it would look nicer in XSLT2 but anyway you basically need to ensure that nodes that you want to group together end up with the same key

    <xsl:key name="kGDByIdKey" match="GroupData" use="concat(@ID, '+', @Key)"/>
    

    things only get the same use attribute if they have the same @ID and @key

    If you change that to

    <xsl:key name="kGDByIdKey" match="GroupData[not(@ID='xxx')]" use="concat(@ID, '+', @Key)"/>
    <xsl:key name="kGDByIdKey" match="GroupData[@ID='xxx'] use="concat('zzz', '+', @Key)"/>
    

    Then nodes with ID xxx will be indexed (and therefore grouped) with zzz (or course you need to make a similar change when you construct the lookup value from the node)

    If you were using xslt 2you could use a simpler functional style that is perhaps less unweildy when extended to multiple such changes

    <xsl:key name="kGDByIdKey" match="GroupData" use="concat(replace(@ID,'^xxx$','zzz'), '+', @Key)"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand the math of this code snippet. A token is provided which
Trying to understand isolation levels better - using entity framework and sql server What
Trying to understand why i don't have to convert null to DBNull when using
Trying to understand, how to redirect program output to a file... Code : import
Trying to understand what is going on, maybe someone can explain. Upon :HOVER I
Trying to understand how the code below always brings up a number between 0-6
Trying to understand free-identifier=? and bound-identifier=?. Can anyone give me equivalent code examples where
After trying to understand why client code is not rendered in a page (injected
Trying to understand why you can't use sql_variant for the value type when using

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.