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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:23:38+00:00 2026-05-22T14:23:38+00:00

the following it the input ,I want to merge and sort the elements without

  • 0

the following it the input ,I want to merge and sort the elements without using xsl:sort!!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE lists SYSTEM "number.dtd">
<numbers>
  <number>
    <num val="7"/>
    <num val="2"/>
    <num val="9"/>
    <num val="16"/>
    <num val="12"/>
    <num val="15"/>
  <number/>
  <number>
    <num val="29"/>
    <num val="18"/>
    <num val="30"/>
    <num val="32"/>
  </number>
</numbers>

the out put should be::

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE lists SYSTEM "number.dtd">
<numbers>
  <number>
    <num val="2"/>
    <num val="7"/>
    <num val="9"/>
    <num val="12"/>
    <num val="15"/>
    <num val="16"/>
    <num val="18"/>
    <num val="29"/>
    <num val="30"/>
    <num val="32"/>
  </number>
</numbers>

in the xsl ,please do not use xsl:sort… ∩_∩

  • 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-22T14:23:39+00:00Added an answer on May 22, 2026 at 2:23 pm

    Without using xsl:sort, you could do something like the following, but if your numbers are much higher, negative, non-whole, or not actually numbers, then you will either have to adjust things, or it may just not work (I tried bumping up the last value from 32 to 3200 and xsltproc not only required I give a higher –maxdepth value but also took 52x as long!):

    <?xml version="1.0" encoding="UTF-8"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
        <numbers>
          <number>
            <xsl:call-template name="iterate.over.nums">
              <xsl:with-param name="i">0</xsl:with-param>
            </xsl:call-template>
          </number>
        </numbers>
      </xsl:template>
    
      <xsl:template name="iterate.over.nums">
        <xsl:param name="i">0</xsl:param>
        <xsl:choose>
          <xsl:when test="not(numbers/number/num/@val &gt;= $i)" />
          <xsl:otherwise>
            <xsl:for-each select="numbers/number/num[@val = $i]">
              <num val="{@val}"/>
            </xsl:for-each>
            <xsl:call-template name="iterate.over.nums">
              <xsl:with-param name="i" select="$i + 1" />
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </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 have the following input: <?xml version=1.0 encoding=utf-8?> <NewTerms> <newTerm>XPath</newTerm> <newTerm>AutoValue</newTerm> <newTerm>XPath</newTerm> <newTerm>context</newTerm> <newTerm>AutoValue</newTerm>
i want the following functionality. input : this is test <b> bold text </b>
I have the following HTML: <input type=email id=email> I want to type text into
I've opened the following input and output bluetooth streams using Apple's External Accessory Framework:
I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
Consider two matrices as input parameters of the following sample_method() method, I want to
Learning sed, I want to change the drive letter of the following input lines
I have the following input element: <input type=radio> <xsl:attribute name=name> <xsl:value-of select=../../os:Row_ID /> </xsl:attribute>
I want to store the following input in a tree such that a number
I want to make following function: 1)input is a number. 2)functions are indexed, return

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.