Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Tue, 1 Jul 2008 14:38:03 -0700,    group: microsoft.public.xsl        back       


XSL output of complete element   
Please can someone give me a sample xsl to output a complete element in a 
for-each loop?
For example I'd like to sort the output on <level> by the <sort> value, but 
as you can see, the elements underneath the <level> node may vary :
<root>
  <level>
    <sort>2</sort>
    <x></x>
    <y></y>
  </level>
  <level>
    <sort>1</sort>
    <x></x>
    <a></a>
  </level>
  <level>
    <sort>3</sort>
    <c></c>
    <d></d>
    <e></e>
  </level>
</root>

Expected output:
<root>
  <level>
    <sort>1</sort>
    <x></x>
    <a></a>
  </level>
  <level>
    <sort>2</sort>
    <x></x>
    <y></y>
  </level>
  <level>
    <sort>3</sort>
    <c></c>
    <d></d>
    <e></e>
  </level>
</root>

Thanks - I'm sure it's a doddle for someone here.
date: Tue, 1 Jul 2008 14:38:03 -0700   author:   sbparsons

Re: XSL output of complete element   
On Jul 2, 2:38 am, sbparsons 
wrote:
> Please can someone give me a sample xsl to output a complete element in a
> for-each loop?
> For example I'd like to sort the output on <level> by the <sort> value, but
> as you can see, the elements underneath the <level> node may vary :
> <root>
>   <level>
>     <sort>2</sort>
>     <x></x>
>     <y></y>
>   </level>
>   <level>
>     <sort>1</sort>
>     <x></x>
>     <a></a>
>   </level>
>   <level>
>     <sort>3</sort>
>     <c></c>
>     <d></d>
>     <e></e>
>   </level>
> </root>
>
> Expected output:
> <root>
>   <level>
>     <sort>1</sort>
>     <x></x>
>     <a></a>
>   </level>
>   <level>
>     <sort>2</sort>
>     <x></x>
>     <y></y>
>   </level>
>   <level>
>     <sort>3</sort>
>     <c></c>
>     <d></d>
>     <e></e>
>   </level>
> </root>
>
> Thanks - I'm sure it's a doddle for someone here.

Hi,

 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="root">
<xsl:copy>
<xsl:for-each select="level">
<xsl:sort select="sort" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Regards,
Balaji. M
sql-ebooks.blogspot.com
date: Wed, 2 Jul 2008 01:58:13 -0700 (PDT)   author:   msbalaji

Re: XSL output of complete element   
Thanks for that. The time differences are to blame for the delay in 
responding to you!

Regards.

"msbalaji" wrote:

> On Jul 2, 2:38 am, sbparsons 
> wrote:
> > Please can someone give me a sample xsl to output a complete element in a
> > for-each loop?
> > For example I'd like to sort the output on <level> by the <sort> value, but
> > as you can see, the elements underneath the <level> node may vary :
> > <root>
> >   <level>
> >     <sort>2</sort>
> >     <x></x>
> >     <y></y>
> >   </level>
> >   <level>
> >     <sort>1</sort>
> >     <x></x>
> >     <a></a>
> >   </level>
> >   <level>
> >     <sort>3</sort>
> >     <c></c>
> >     <d></d>
> >     <e></e>
> >   </level>
> > </root>
> >
> > Expected output:
> > <root>
> >   <level>
> >     <sort>1</sort>
> >     <x></x>
> >     <a></a>
> >   </level>
> >   <level>
> >     <sort>2</sort>
> >     <x></x>
> >     <y></y>
> >   </level>
> >   <level>
> >     <sort>3</sort>
> >     <c></c>
> >     <d></d>
> >     <e></e>
> >   </level>
> > </root>
> >
> > Thanks - I'm sure it's a doddle for someone here.
> 
> Hi,
> 
>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
> Transform">
> <xsl:template match="root">
> <xsl:copy>
> <xsl:for-each select="level">
> <xsl:sort select="sort" data-type="number"/>
> <xsl:copy-of select="."/>
> </xsl:for-each>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
> 
> Regards,
> Balaji. M
> sql-ebooks.blogspot.com
> 
>
date: Wed, 2 Jul 2008 10:22:00 -0700   author:   sbparsons

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us