Fun with contains

In my previous post I was demonstrating how you can include the output of an XPath query in your posts. What also turned up is how you have to be careful with the contains query. If you notice in the first table Annie Lennox shows up more often then you'd expect, this is the result of the contains query matching on the table element included in the post for the second query. Since it matches on the contents of the XPath and XSL-T is good at recursive processing it happily evaluates the query and includes the output. I'm not sure if that's such a bad thing.

A slight modification to the query will get the expected results.

<xpath-query>/item//table[tr[contains(.,'Annie Lennox')]]</xpath-query>

ArtistSongAlbumPlay Count
MetallicaFranticSt. Anger12
Massive AttackAntistar100th Window11
Massive AttackButterfly Caught100th Window11
Massive AttackEverywhen100th Window11
Massive AttackFuture Proof100th Window11
Massive AttackName Taken100th Window11
Massive AttackHymn Of The Big Wheel (OriginHymn Of The Big Wheel11
MetallicaDirty WindowSt. Anger11
MetallicaMy WorldSt. Anger11
Annie LennoxA Thousand Beautiful ThingsBare10
Annie LennoxBitter PillBare10
Annie LennoxErasedBare10
EvanescenceBring Me To Life (Feat. PaulFallen10
Massive AttackPrayer For England100th Window10
Massive AttackSmall Time Shot Away100th Window10
Massive AttackSpecial Cases100th Window10
Massive AttackWhat Your Soul Sings100th Window10
Massive AttackAny Love (Larry Heard Mix)Hymn Of The Big Wheel10
Massive AttackHome Of The WhaleHymn Of The Big Wheel10
Massive AttackHymn Of The Big Wheel (NelleeHymn Of The Big Wheel10
Annie LennoxHonestlyBare9
Annie LennoxLonelinessBare9
Annie LennoxOh God (Prayer)Bare9
EvanescenceEverybody`s FoolFallen9
EvanescenceGoing UnderFallen9

Posted by Kimbro Staken

Wednesday Sep 17, 2003 at 4:12 AM
Recommended Sites