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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:59+00:00 2026-05-27T05:43:59+00:00

what i want to do is a typical grouping that can usualy be done

  • 0

what i want to do is a typical grouping that can usualy be done using xsl:key, but it become more complicated as data to groups are in 2 differents files. How process ?
Here is an example of what i want to do, can i request your help ? must be xslt-1.0 compliant.

bookreference.xml :

<t>  
    <book isbn="1">  
        <category>SF</category>  
    </book>  
    <book isbn="2">  
        <category>SF</category>  
    </book>  
    <book isbn="3">  
        <category>SF</category>  
    </book>  
    <book isbn="4">  
        <category>Comedy</category>  
    </book>  
    <book isbn="5">  
        <category>Comedy</category>  
    </book>
</t>  

mylibrary.xml :

<t>  
   <book isbn="1">
       <price>10</price>
   </book>
   <book isbn="2">
      <price>10</price>
   </book>       
   <book isbn="3">
      <price>20</price>
   </book>
   <book isbn="4">
      <price>5</price>
   </book>
</t>  

output wanted:

SF : 3 book(s) - Total : 40$
Comedy : 2 book(s) - Total : 5$
  • 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-27T05:44:00+00:00Added an answer on May 27, 2026 at 5:44 am

    As already suggested in my comment, you can first merge two documents into a result tree fragment, then use exsl:node-set to get a node-set on which you can then apply Muenchian grouping:

    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:exsl="http://exslt.org/common"
      exclude-result-prefixes="exsl"
      version="1.0">
    
      <xsl:param name="price-url" select="'test2011113002.xml'"/>
      <xsl:variable name="doc2" select="document($price-url)"/>
    
      <xsl:output method="text"/>
    
      <xsl:variable name="rtf">
        <xsl:apply-templates select="//book" mode="merge"/>
      </xsl:variable>
    
      <xsl:template match="book" mode="merge">
        <xsl:copy>
          <xsl:variable name="isbn" select="@isbn"/>
          <xsl:copy-of select="@* | node()"/>
          <xsl:for-each select="$doc2">
            <xsl:copy-of select="key('k1', $isbn)/price"/>
          </xsl:for-each>
        </xsl:copy>
      </xsl:template>
    
      <xsl:key name="k1" match="book" use="@isbn"/>
      <xsl:key name="k2" match="book" use="category"/>
    
      <xsl:template match="/">
        <xsl:apply-templates select="exsl:node-set($rtf)/book[generate-id() = generate-id(key('k2', category)[1])]"/>
      </xsl:template>
    
      <xsl:template match="book">
        <xsl:variable name="current-group" select="key('k2', category)"/>
        <xsl:value-of select="concat($current-group/category, ': ', count($current-group), ' - Total : ', sum($current-group/price), '&#10;')"/>
      </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 want to build a program that can recognize typical playing cards. is there
I want to pass some data around threads but want to refrain from using
I want to create a PDF that will bring up a typical OK/Cancel alert
I've checked out some typical open source project which is using auto-tools. I want
I am trying to parse through a typical form using jquery. I want to
The typical way of selecting data is: select * from my_table But what if
I want to use the typical java notation. I need a Timer but I
I want to dynamically construct a TreeView using Node which represents a typical tree
So I have typical 1:M relationship: Car can have many Models I want to
I want to generate an hierarchical data representation, more like a family tree rather

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.