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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:03:08+00:00 2026-05-16T04:03:08+00:00

I have an XML file whose contents I want to sort by document order

  • 0

I have an XML file whose contents I want to sort by document order (basically in the order that the items were written out).

I currently use the following code:

<xsl:template match="/Error">
        <xsl:apply-templates>
            <xsl:sort select="position()" order="descending" />
        </xsl:apply-templates>
</xsl:template>

<xsl:template match="/Error/Warning">
<!-- etc -->
</xsl:template>

Example XML (data replaced for ease of reading):

<Error>
<Warning data="stuff" timestamp="08:26:17 2010/08/01">CODE.1</Warning>
<Clear data="stuff" timestamp="08:26:36 2010/08/01">CODE.2</Clear>
<Warning data="stuff" timestamp="08:36:00 2010/08/01">CODE.3</Warning>
<Clear data="stuff" timestamp="08:36:56 2010/08/01">CODE.4</Clear>
<Warning data="stuff" timestamp="08:40:31 2010/08/01">CODE.5</Warning>
</Error>

This, however, seems to give odd results as it seems to be in no particular order! Any ideas?

Removing the sort seems to make it work properly – will this reliably order it in write-order or is that not guaranteed?

  • 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-16T04:03:09+00:00Added an answer on May 16, 2026 at 4:03 am

    <xsl:apply-templates /> operates over the selected nodeset in document order, remove the sort element, and this will work as desired. See: Applying Template Rules

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

Sidebar

Related Questions

I have the following layout in my xml file: <RelativeLayout android:layout_width=fill_parent android:layout_height=fill_parent> <FrameLayout android:id=@+id/logoLayout
I have the following XSD file: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.wvf.com/schemas' xmlns='http://www.wvf.com/schemas' xmlns:acmewvf='http://www.wvf.com/schemas'> <xs:element name='loft'> </xs:element>
I'm trying to parse a moderately large XML file (6mb) in php using simpleXML.
We have a servlet that accepts image uploads. Sometimes when the uploads originate in
I have programmed a proxy.php script (listed below), which would fetch an image specified
I have an XMLEventReader. It has been built from an XMLInputFactory with the UTF8
I tried to make a file choose following the below link http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ However, I
I have a client for whom I am updating a website... the previous designer
I am working on a biztalk project and I need to copy (filtered) content
HI, My question has to do with a very basic understanding of Writing data

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.