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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:36:45+00:00 2026-05-28T02:36:45+00:00

I’m trying to do a modulus 11 check in XSLT 1.0 for a 17

  • 0

I’m trying to do a modulus 11 check in XSLT 1.0 for a 17 digit number. However, it always seems to give the wrong output.

The only information I’ve been able to find about this, was in this post, however, no solution was found.

I have in the past used an XSLT template for a Luhn checker, I realise that this works differently to a modulus check but I was wondering if anyone was aware of an XSLT template which can calculate moduluses of large numbers?

  • 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-28T02:36:46+00:00Added an answer on May 28, 2026 at 2:36 am

    There is a pure XSLT 1.0 solution which calculates $n mod 11 for integer $n of any size:

    <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:template match="/*">
         <xsl:call-template name="mod11"/>
     </xsl:template>
    
     <xsl:template name="mod11">
      <xsl:param name="pN" select="."/>
    
      <xsl:choose>
       <xsl:when test="not($pN > 9999999999999999)">
         <xsl:value-of select="$pN mod 11"/>
       </xsl:when>
       <xsl:otherwise>
          <xsl:variable name="vLen" select="string-length($pN)"/>
    
          <xsl:variable name="vLen1" select="$vLen -1"/>
    
          <xsl:variable name="vPart1" select=
              "substring($pN, 1, $vLen1)"/>
    
          <xsl:variable name="vPart2" select=
              "substring($pN, $vLen1 +1)"/>
    
          <xsl:variable name="vMod1">
           <xsl:call-template name="mod11">
             <xsl:with-param name="pN" select="$vPart1"/>
           </xsl:call-template>
          </xsl:variable>
    
          <xsl:variable name="vMod2" select="$vPart2 mod 11"/>
    
          <xsl:value-of select="(10*$vMod1 + $vMod2) mod 11"/>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the following XML document:

    <t>12345678901234567</t>
    

    the wanted correct result (12345678901234567 mod 11) is produced:

    9
    

    Do note:

    1. This solution can easily be generalized to calculate $n mod $m for any integer $m — just pass $m as a second parameter.

    2. Another generalization is to pass as parameter the limit above which $n mod $m cannot be calculated directly using the mod operator. This can be useful when using XSLT 2.0 and having $n as either xs:integer or xs:decimal.

    3. Another alternative is to use the Saxon.NET XSLT 2.0 processor or any other XSLT 2.0 processor that implements Big Integer arithmetics. Then the solution is just to use the mod operator:

    ….

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/*">
         <xsl:value-of select="xs:integer(.) mod 11"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied with Saxon 9.1.07 on the same XML document (above), the same correct result is produced:

    9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.