RE: [xsl] changing the order of xml elements when doing XSLT

Subject: RE: [xsl] changing the order of xml elements when doing XSLT
From: "Xuegen Jin" <xjin_imi@xxxxxxxxx>
Date: Wed, 18 Apr 2001 23:44:55 -0400
When you call <xsl:apply-templates/> in your <xsl:template match="record">
template, the child elements for "record" are processed in the document
order, irrespective of the order of those matching template declarations. To
have the order you want, you should simple do:

<xsl:template match="record">
      <xsl:apply-templates select="c"/>
	<xsl:apply-templates select="b"/>
	<xsl:apply-templates select="a"/>


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

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Charlie Wu
Sent: Wednesday, April 18, 2001 8:41 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] changing the order of xml elements when doing XSLT

hi all..

i have a need to accomplish the following.. i.e. when doing an XSLT over an
XML file.. have the output xml be in a specific order that is NOT the same
as the order in the original XML. i guess it can only be done in the xsl
file somehow.. if at all possible.. but i couldn't figure it out.

to clarify what i mean.. here's an example:


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="mapper.xsl"?>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
        <xsl:template match="/">
        <xsl:template match="record">
	<xsl:template match="c">
			<xsl:value-of select="."/>
	<xsl:template match="a">
		<AA><xsl:value-of select="."/></AA>
	<xsl:template match="b">
			<xsl:value-of select="."/>

current output:


desired output:


any ideas would be highly appreciated..



 XSL-List info and archive:

Do You Yahoo!?
Get your free address at

 XSL-List info and archive:

Current Thread