homepage Welcome to WebmasterWorld Guest from 54.226.191.80
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Removing XML duplicates with XSL?
ptolbert




msg:3978043
 12:24 am on Aug 25, 2009 (gmt 0)

I have the following XML and need to remove duplicate entries via XSL and am having a hard time.

Essentially, I dont want the game Belton V. Waco to appear twice.

Any ideas on preventing this?

<game>
<sport_name>5A</sport_name>
<date>Friday</date>
<time>7:30</time>
<away_team_name/>
<away_team_school>Belton</away_team_school>
<away_team_score>0</away_team_score>
<home_team_name/>
<home_team_school>Waco</home_team_school>
<home_team_score>0</home_team_score>
</game>
<scoreboard>
<game>
<sport_name>4A</sport_name>
<date>Friday</date>
<time>7:30</time>
<away_team_name/>
<away_team_school>Belton</away_team_school>
<away_team_score>0</away_team_score>
<home_team_name/>
<home_team_school>Waco</home_team_school>
<home_team_score>0</home_team_score>
</game>
<scoreboard>

 

httpwebwitch




msg:3978370
 5:00 pm on Aug 25, 2009 (gmt 0)

Hi ptolbert, welcome to WebmasterWorld!

I suggest that XSLT is not the right tool for this task. XSLT will do a good job of marking up XML that is already well constructed, it's really not very good at processing data.

There are many XSLT hacks that let you find groupings and rearrange pieces and sort parts and loop with conditions in interesting ways... but it's (almost) always easier to parse the XML with some kind of server-side script, clean up dupes and rearrange the data, then throw the result of that into your XSLT. What will take 1000 lines of infuriating and confusing XSLT acrobatics can be done in 20 lines of PHP or C#.

mrVano




msg:3978444
 7:02 pm on Aug 25, 2009 (gmt 0)

Agreed.

Your XML is malformed and the task specifications leave for quite a bit of assumptions...

What you have here is not duplicated nodes, but rather a collection of duplicated data within multiple nodesets. Matching data against each other accross multiple nodes is gonna be pretty much impossible to implement. There is a slim chance that this can be done, but unless you provide a well-formed XML and elaborate on the specifications, it will be a wasted effort.

httpwebwitch




msg:3978455
 7:31 pm on Aug 25, 2009 (gmt 0)

the malformedness is just missing end tags for <scoreboard>

the important data unit here is the <game> element and its children

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved