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

Getting unique nodes filtering by several attributes a

Subject: Getting unique nodes filtering by several attributes and mixing files
From: Iván Montoro Ten <ivanm@xxxxxxxxxxx>
Date: Tue, 25 Nov 2003 03:56:56 +0100
xsl unique nodes
Hi,

First of all please excuse my poor english... :)

I'm trying to combine two XML files, mixing the values I realy need from
both and
keeping the result in a third XML file (later I'll convert it to HTML).

One of the XML files (week_schedule.xml) is the list of programs to be on
air for
two different TV channels. This list contains an "onAir" node for each
advertisment
(commercials) block. It's the only way to know which programs will be on air
next
week, yes :(

Now, I'll want to:
* Get unique nodes from weekSchedule, based on progName, channel _and_
weekDay
  (same program can be on air at different times based on week day or
channel,
  for example we repeat the 'Friends' episode of Sunday morning each
Monday).
  I've successfuly got a unique list of progNames, but 'Friends' on Sunday
  dissapear.

* With that unique list of progName/weekDay/channel, resolve the start/end
times
  (calling document() with a local variable). That output should be in XML,
  althought I've got something out in HTML should be little difference,
isn't it?

I'm quite new to XSLT. I've been using it for some time, but basicaly the
database
was giving me the data in format I like, only a few value-of and maybe a
for-each
and HTML is out. I've been read the comments on the list about uniqueness
and
grouping, but as english is not my natural language I'm realy lost, mostly
on the
key() function that seems to make what I want to do.

Thanks!

Ivan

<!-- timetable.xml -->
<!-- I control this file -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<programs>
  <program progName='Friends' weekDay='Mon' channel='1' start='10:00'
end='10:45'/>
  <program progName='X-Files' weekDay='Sat' channel='2' start='14:00'
end='15:30'/>
  <program progName='Friends' weekDay='Sun' channel='1' start='09:00'
end='09:45'/>
</programs>

<!-- week_schedule.xml -->
<!-- This file comes from an external database I don't control -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<weekSchedule>
  <onAir progName='Friends' channel='1' weekDay='Mon' date='17/11/2003'
adsAt='10:15'/>
  <onAir progName='Friends' channel='1' weekDay='Mon' date='17/11/2003'
adsAt='10:30'/>
  <onAir progName='X-Files' channel='2' weekDay='Sat' date='22/11/2003'
adsAt='14:15'/>
  <onAir progName='X-Files' channel='2' weekDay='Sat' date='22/11/2003'
adsAt='14:30'/>
  <onAir progName='X-Files' channel='2' weekDay='Sat' date='22/11/2003'
adsAt='14:45'/>
  <onAir progName='X-Files' channel='2' weekDay='Sat' date='22/11/2003'
adsAt='15:25'/>
  <onAir progName='Friends' channel='1' weekDay='Sun' date='23/11/2003'
adsAt='09:15'/>
  <onAir progName='Friends' channel='1' weekDay='Sun' date='23/11/2003'
adsAt='09:30'/>
</weekSchedule>

<!-- my_result.xml -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<tv>
  <program progName='Friends' channel='1' weekDay='Mon' start='10:00'
end='10:45'/>
  <program progName='Friends' channel='1' weekDay='Sun' start='09:00'
end='09:45'/>
  <program progName='X-Files' channel='2' weekDay='Sat' start='14:00'
end='15:30'/>
</tv>

<!-- my_would_be_even_better_result.xml -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<tv>
  <program progName='Friends' date='17/11/2003'
	channel='1' weekDay='Mon' start='10:00' end='10:45' ads='10:15,10:30'/>
  <program progName='Friends' date='23/11/2003'
	channel='1' weekDay='Sun' start='09:00' end='09:45' ads='14:15,14:30,...'/>
  <program progName='X-Files' date='22/11/2003'
	channel='2' weekDay='Sat' start='14:00' end='15:30' ads='09:15,09:30'/>
</tv>


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


Current Thread

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.