[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: order problem

Subject: RE: order problem
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 27 Jun 2003 09:51:25 +0100
xsl element order attribute
> >
> > I have this element hierarchy
> >
> > Source::
> > root
> >     body
> >         record1(*)
> >         record2(*)
> >
> > Destination::
> > root1
> >     body1
> >         record3(*)
> >         record4(*)

Actually, in the text of your message, you suggest that your source has
a quite different structure, namely:

   root
       body
           ( record1 | record2 ) *
            
This is a classic case for xsl:apply-templates.

<xsl:apply-templates select="record1 | record2"/>

<xsl:template match="record1">
...
</xsl:template>

<xsl:template match="record2">
...
</xsl:template>


> >
> > Here occurence of record1 and record2 can occur any number of 
> > times.This will be my source xml on which the transform is to be 
> > applied.Following is the xsl
> >
> > <xsl:template match="/" name="root">
> > <xsl:element name="root1">
> >  <xsl:element name="body1">
> >   <xsl:for-each select="/root/body/record1">
> >    <xsl:element name="record3"><xsl:value-of 
> > select="concat(.,'1')"/></xsl:element>
> >   </xsl:for-each>
> >   <xsl:for-each select="/root/body/record2">
> >    <xsl:element name="record4"><xsl:value-of 
> > select="concat(.,'2')"/></xsl:element>
> >   </xsl:for-each>
> >  </xsl:element>
> > </xsl:element>
> > </xsl:template>
> >
> > Only problem would be that i need the order of records to be same in
> output
> > as in input and input of records can be in random order,viz 
> > <record1><record1><record2><record1><record2><record1>.But with the 
> > two for-loops this will break the sequence.
> >
> > How can this be done.
> >
> > Any help on this would be deeply appreciated.
> >
> > Thanks,
> > Shadab
> >
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • order problem
    • Shadab - Fri, 27 Jun 2003 04:06:56 -0400 (EDT)
      • Michael Kay - Fri, 27 Jun 2003 04:51:08 -0400 (EDT) <=
      • <Possible follow-ups>
      • Jarno . Elovirta - Fri, 27 Jun 2003 04:32:03 -0400 (EDT)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.