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

The Archive Base Latest Questions

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

I was wondering how this predicate([1]), is hardcoded as 1 always in the muenchian

  • 0

I was wondering how this predicate([1]), is hardcoded as 1 always in the muenchian grouping. The concept was not clear for me, after a lot of search. It is explained as the current node, is compared with the 1st group returned by the key.
Why does it always compare with the first one that a key is matched?
Also why are we giving contact[count(. | key('contacts-by-surname', surname)[1]) = 1], the =1 part? again 1 is hardcoded. I referred the below link

http://www.jenitennison.com/xslt/grouping/muenchian.html

  • 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-27T03:28:52+00:00Added an answer on May 27, 2026 at 3:28 am

    I was wondering how this predicate([1]), is hardcoded as 1 always in
    the muenchian grouping.

    This is simple:

    The key() function produces all nodes for a given group, and we want to take just one node from any group.

    It isn’t guaranteed that all groups will have two or more nodes in them — some might have just one node.

    This is why it is safe and convenient to take the first (and possibly the only) node from each group.

    We could equally well do the grouping taking the last node from each group (but this will be less efficient):

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:key name="kNumByMod3" match="num"
      use=". mod 3"/>
    
     <xsl:template match=
      "num[generate-id()
          =
           generate-id(key('kNumByMod3', . mod 3)[last()])
          ]
      ">
    
    
      3k + <xsl:value-of select=". mod 3"/>:
    <xsl:text/>
      <xsl:copy-of select="key('kNumByMod3', . mod 3)"/>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on this XML document:

    <nums>
      <num>01</num>
      <num>02</num>
      <num>03</num>
      <num>04</num>
      <num>05</num>
      <num>06</num>
      <num>07</num>
      <num>08</num>
      <num>09</num>
      <num>10</num>
    </nums>
    

    produces the wanted, correctly grouped result:

      3k + 2:
    <num>02</num>
    <num>05</num>
    <num>08</num>
    
    
      3k + 0:
    <num>03</num>
    <num>06</num>
    <num>09</num>
    
    
      3k + 1:
    <num>01</num>
    <num>04</num>
    <num>07</num>
    <num>10</num>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was always wondering about this seemingly utopic world of open source. Assuming the
Tried a little googling and everyone seemed to be wondering this for a lot
I've been wondering this for some time now. I'm by far not a hardcore
I've been wondering this for a while but since it hasn't come up much
I've been wondering this for some time. As the title say, which is faster,
I've been wondering this for a while, and Google hasn't provided me with the
Wondering if this is possible. We have an 3rd Party library that contains identification
Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() {
Just wondering about this code below... when I turn off my internet connection and
I'm wondering if this is a good design. I have a number of tables

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.