473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XSLT programming!!! need help from gurus!

Hi there xslt gurus,
i am kinda new to xslt and having difficulty to implement my some iterations. i need to recreate an xml file by using xslt. here is the sample xml file(input for xslt)

[html]<Flights>
<Flight>
<FlightLeg >
<BookingClassCodeList>
<BookingCode Value="C" />
<BookingCode Value="Y" />
</BookingClassCodeList>
</FlightLeg>
</Flight>
<Flight>
<FlightLeg >
<BookingClassCodeList>
<BookingCode Value="C" />
</BookingClassCodeList>
</FlightLeg>
<FlightLeg >
<BookingClassCodeList>
<BookingCode Value="A" />
<BookingCode Value="B" />
</BookingClassCodeList>
</FlightLeg>
</Flight>
<Flights>[/html]
AS you can see, there can be 1 or more flightlegs per flight. I need to do sth by xslt so that:
- instead of first flight node there will be 2 new flight nodes with bookingclasscode values are assigned as attribute to flightleg
[html] <Flight>
<FlightLeg booking="C" />
</Flight>
<Flight>
<FlightLeg booking="Y" />
</Flight>[/html]
-- and instead of second flight node there will be 2 new flight nodes(combination of booking classes of flightlegs) with related attributes assigned
[html] <Flight>
<FlightLeg booking="C" />
<FlightLeg booking="A" />
</Flight>
<Flight>
<FlightLeg booking="C" />
<FlightLeg booking="B" />
</Flight>[/html]

I feel like this can be implemented by xslt since it is recursive based programming, but i couldn't figure it out. If you can help me i really appreciate it. thanks in advance!

Please add always code or html tags to code snippets. Thanks, moderator.
Mar 20 '07 #1
1 1391
dorinbogdan
839 Expert 512MB
The solution you need is not pretty simple.
I could not get enough time to complete the algorithm, however I wrote the first part of the XSL.
It may help you to build the second part too.

[html]<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Flight">
<xsl:if test="position()=1">

<xsl:for-each select="./FlightLeg/BookingClassCodeList/BookingCode">
&lt;Flight&gt;
&lt;FlightLeg booking="<xsl:value-of select="@Value" />" /&gt;
&lt;/Flight&gt;
</xsl:for-each>
</xsl:if>
<xsl:if test="position()=2">
...
</xsl:if>

</xsl:template>
</xsl:stylesheet>
[/html]

I hope this helps.
Mar 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Benjamin Hillsley | last post by:
Hi, I have a xml file that catalogs my cd and dvd collection, and I am currently writing a web page to access this catalog. I would like to include a selection box that lists the CD's by...
3
by: Matthias Marx | last post by:
Hi, May some one could help me. I want to transform data, coming from SQL Server and loaded to a dataset wiuth xslt. After that, I want convert it by a xslt style sheet, and store it...
2
by: Chumma Dede | last post by:
Hi, I need to code a DLL in .NET which logs the response times for our asp.net multi-tier application. The problem is we need to log the timestamps at multiple stages in a process lifecycle...
2
by: c++ newbie | last post by:
I am new to c++ programming I have Borland Turbo c++ ver 3.0 I copied the installed Tcc files from my friends hdd in a cd and pasted it directly into my hdd at d:\lang\tcc\ when i open tc++ it...
4
by: Mario Vázquez | last post by:
Hi, I'm trying to put the links (href attribute of the <a> element) out of my XSLT files, in a XML file, and read it from the stylesheet. I suppose that I have to use the document() function to...
0
by: rajeshwarrao.g | last post by:
Hi All, I am in need of help of "Programming IIS from C#". I want to set the session timeout of IIS and back up the properties of a virtual directory and set the properties to a new virtual...
9
by: gregmcmullinjr | last post by:
Hello, I am new to the concept of XSL and am looking for some assistance. Take the following XML document: <binder> <author>Greg</author> <notes> <time>11:45</time>
1
by: dewey | last post by:
Hi, This, I'm sure, is a very simple problem. I'm trying to use the xslt document() function to add a piece of information from a second xml file. The main xml has a list of football teams,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.