iteration with xsl:for-each: newbie question?

This is a discussion on "iteration with xsl:for-each: newbie question?" within the Other Programming Languages section. This forum, and the thread "iteration with xsl:for-each: newbie question? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Other Programming Languages

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 7th, 2006, 14:00
New Member
Join Date: Jul 2006
Location: Switzerland
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
iteration with xsl:for-each: newbie question?

Hello,



I have a xml file with this structure



<root>
<rooms>
<roomsA price="56"/>
<date>26/02/2006</date>
<roomsA>
<roomA price="65"/>
<date>26/03/2006</date>
</roomsA>

<roomB price="59">
<date>26/02/2006</date>
</roomB>
<roomB price="75">
<date>26/03/2006</date>
</roomB>
<roomC price="45">
<date>26/02/2006</date>
</roomC>
<roomC price="75">
<date>26/03/2006</date>
</roomC>
</rooms>
</root>

and I would like to obtain something like this
<Room>
<roomsAprice>56</roomsAprice>
<roomsBprice>59</roomsBprice>
<roomsCprice>45</roomsCprice>
<date>26/02/2006</date>
</Room>
<Room>
<roomsAprice>65</roomsAprice>
<roomsBprice>75</roomsBprice>
<roomsCprice>75</roomsCprice>
<Date>26/03/2006</Date>
</Room>



I tried to do xsl:each-for and doesn't work very well.

<?xml version='1.0' ?>
<
xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Root>
<xsl:for-each select="root/rooms/roomA/@date">
<rooms>
<xsl:for-each select="..">
<roomsAprice>
<xsl:value-of select="."/>
</roomsAprice>
<xsl:for-each select="../roomB/@date">
<roomsBprice>
<xsl:value-of select=".."/>
</roomsBprice>
</xsl:for-each>
<roomsCprice>
<xsl:value-of select="../../roomC"/>
</roomsCprice>
<Date>
<xsl:value-of select="."/>
</Date>
</xsl:for-each>
</rooms>
</xsl:for-each>
</Root>
</xsl:template>
<
/xsl:stylesheet>


Can someone help me on that?

Ina
Reply With Quote

Reply

Tags
iteration, xslforeach, newbie, question

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
latest iteration of the .NET framework welshstew ASP.NET Forum 1 Dec 7th, 2007 20:56
Newbie Question DRWEB Starting Out 7 Jun 20th, 2007 19:09
XSL Newbie Question mr4thjuly Other Programming Languages 0 Oct 19th, 2006 17:37
Newbie with a question wishmastersjewelry Web Page Design 11 Aug 21st, 2006 21:20
PHP question (newbie) btfans PHP Forum 7 Dec 6th, 2005 02:53


All times are GMT. The time now is 08:07.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43