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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:42:11+00:00 2026-05-25T23:42:11+00:00

I’m trying to find a solution to the following problem. I’m developing XSLT transformation

  • 0

I’m trying to find a solution to the following problem.

I’m developing XSLT transformation (which is now about 40KB big) that is transforming quite complex XMLs into a quite simple structure which would like this:

<Records>
<Record key="XX">
</Record> 
<Record key="XX1">
</Record>
<Record key="XX2">
</Record>
<Record key="XX3">
</Record>
</Records>

I would like to have this output XML sorted according to Records/Record/@key values.
The problem is that my XSLT produces this output unsorted and due to its complexity I am unable to sort it there.
Is it possible to apply xsl:sort on the output XML? I know that I can prepare another XSLT transform, but in my case that’s not the solution, as I’m limited to only one XSLT.. Please, help!…

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

    Is it possible to apply xsl:sort on the output XML?

    Yes, multipass processing is possible, and especially in XSLT 2.0 you don’t even need to apply an xxx:node-set() extension on the result, because the infamous RTF type does no longer exist:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <xsl:variable name="vPass1">
       <!--
            Put/Invoke your cirrent code here   
            to generate the following           
    -->
        <Records>
          <Record key="XX3">
          </Record>
          <Record key="XX2">
          </Record>
          <Record key="XX4">
          </Record>
          <Record key="XX1">
          </Record>
        </Records>
      </xsl:variable>
    
      <xsl:apply-templates select="$vPass1/*"/>
     </xsl:template>
    
     <xsl:template match="Records">
      <Records>
       <xsl:perform-sort select="*">
        <xsl:sort select="@key"/>
       </xsl:perform-sort>
      </Records>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is performed on any XML document (not used/ignored), the wanted, correct, sorted result is produced:

    <Records>
       <Record key="XX1"/>
       <Record key="XX2"/>
       <Record key="XX3"/>
       <Record key="XX4"/>
    </Records>
    

    In XSLT 1.0 it is almost the same with the additional conversion of the result from RTF type to a normal tree:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     exclude-result-prefixes="ext">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <xsl:variable name="vrtfPass1">
       <!--
            Put/Invoke your cirrent code here   
            to generate the following           
    -->
        <Records>
          <Record key="XX3">
          </Record>
          <Record key="XX2">
          </Record>
          <Record key="XX4">
          </Record>
          <Record key="XX1">
          </Record>
        </Records>
      </xsl:variable>
    
      <xsl:variable name="vPass1"
                    select="ext:node-set($vrtfPass1)"/>
    
      <xsl:apply-templates select="$vPass1/*"/>
     </xsl:template>
    
     <xsl:template match="Records">
      <Records>
       <xsl:for-each select="*">
        <xsl:sort select="@key"/>
    
        <xsl:copy-of select="."/>
       </xsl:for-each>
      </Records>
     </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 am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.