Altova Mailing List Archives


RE: [xsl] order problem

From: "Michael Kay" <mhk@--------->
To:
Date: 6/27/2003 12:51:00 AM
> >
> > 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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.