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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:09:40+00:00 2026-05-27T23:09:40+00:00

I get from my xml some integer and I want to get all numbers

  • 0

I get from my xml some integer and I want to get all numbers between 1 and the gotten number .

I want to insert those numbers as a columns names .

Is it possible to do ?

Thanks .

  • 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-27T23:09:41+00:00Added an answer on May 27, 2026 at 11:09 pm

    I. XSLT 2.0 solution:

     <xsl:sequence select="1 to $N"/>
    

    II. XSLT 1.0 DVC solution

    The answer by @nd (using primitive recursion) is a good one.

    However, if a sequence of numbers is to be generated with sufficiently big length (1000 or more) primitive recursion typically ends abnormally with stack overflow due to too-deep recursion.

    The DVC (Divide and Conquer) method can be used to avoid call stack overflow for any practical case:

    <xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:output method="text"/>
    
         <xsl:template match="/">
          <xsl:call-template name="displayNumbers">
            <xsl:with-param name="pStart" select="1"/>
            <xsl:with-param name="pEnd" select="1000000"/>
          </xsl:call-template>
         </xsl:template>
    
         <xsl:template name="displayNumbers">
          <xsl:param name="pStart"/>
          <xsl:param name="pEnd"/>
    
          <xsl:if test="not($pStart > $pEnd)">
           <xsl:choose>
            <xsl:when test="$pStart = $pEnd">
              <xsl:value-of select="$pStart"/>
              <xsl:text>&#xA;</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:variable name="vMid" select=
               "floor(($pStart + $pEnd) div 2)"/>
              <xsl:call-template name="displayNumbers">
               <xsl:with-param name="pStart" select="$pStart"/>
               <xsl:with-param name="pEnd" select="$vMid"/>
              </xsl:call-template>
              <xsl:call-template name="displayNumbers">
               <xsl:with-param name="pStart" select="$vMid+1"/>
               <xsl:with-param name="pEnd" select="$pEnd"/>
              </xsl:call-template>
            </xsl:otherwise>
           </xsl:choose>
          </xsl:if>
         </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on any XML document (not used), it outputs the numbers from one to one million. The maximum dept of the call stack during this transformation is only 19 (log2(N)).


    III. Non-recursive XSLT 1.0 solution:

    In case the length of the numeric sequence to be generated is not too big (more precisely , doesn’t exceed the number of the available nodes in an XML document (such as the XSLT stylesheet itself)), then we can use a non-recursive solution, known as the Piez method:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:variable name="vDoc" select="document('')"/>
     <xsl:variable name="vNodes" select=
     "$vDoc//node() | $vDoc//@* | $vDoc//namespace::*"/>
    
     <xsl:template match="/">
         <xsl:for-each select="$vNodes[not(position() > 40)]">
          <xsl:value-of select="position()"/>
          <xsl:text>&#xA;</xsl:text>
         </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied to any XML document (not used) it produces the numbers from 1 to 40:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one problem , I want to get some data from XML file
I'd like to get all the element name from a xml file, for example
I get an XML file From a web service. Now I want to get
I am using some XML parser to get some information from API, blah blah...
I'm using HttpClient 4.0 to get some XML from the remote host. When I
I am trying to get some words from xml and put them an the
I am trying to get some data from xml file from my C# coding.
I'd like to get some rows ( z:row rows) from XML using: <rs:data> <z:row
Background: I want to take some xml from one file, put it in a
I wrote some android application that get xml from some service ( using http

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.