[xsl] Comparing values in a 2nd XML document

Subject: [xsl] Comparing values in a 2nd XML document
From: JOHN MARSHALL <marshall.john@xxxxxxxxxx>
Date: Wed, 26 Nov 2003 13:51:58 +1100
Sorry, that really should of had a new subject line!

I'm having difficulty running a test and selecting a value from a second XML

I have one XML document, pad_output.xml which includes what on air this week.

I also have prog.xml which includes all the shows and their associated ID's.
There is a web page based on these ID.

prog.xml looks like this...


<progName>The Adventures of Sam</progName> 

<progName>The Adventures of Spot</progName> 


At the moment, I'm sucking out all the shows that are on air, and putting them
in my html page.

But I want to include links to the relevant pages from the prog.xml document.

So I'm selecting the pad_long_title_1 from a document called pad_output.xml

Now I want to compare the value of pad_long_title_1 to the value of progName in
the second XML document prog.xml

When I find a match between pad_long_title_1 and progName, I want to select the
value of progID and do something like

	<xsl:element name="a">
name="href">/rollercoaster/kidstv/shows/prog<xsl:value-of select="progID"
			<xsl:value-of select="pad_long_title_1" />

So I'll end up with
<a href="/rollercoaster/kidstv/shows/prog7.htm">The Adventures of Sam</a>
<a href="/rollercoaster/kidstv/shows/prog8.htm">The Adventures of Spot</a>

but I keep getting the same and first value of the document. Eg I'm getting
<a href="/rollercoaster/kidstv/shows/prog1.htm">The Adventures of Sam</a>
<a href="/rollercoaster/kidstv/shows/prog1.htm">The Adventures of Spot</a>

		<xsl:variable name="isProgNamePAD" select="pad_long_title_1" />	
		<xsl:variable name="isProgNamePROG" select="$pp//progName" />
		<xsl:variable name="ppID" select="$param4"/>		
		<xsl:variable name="testPassed">
				<xsl:when test="$isProgNamePROG =
					<xsl:param name="param4"
		<p>Prog ID		
		 <xsl:value-of select="$pp//progID"/> 
		<br />
		<xsl:element name="a">
name="href">/rollercoaster/kidstv/shows/prog<xsl:value-of select="$ppID"
			<xsl:value-of select="pad_long_title_1" />
I thought I could do this (pseudo code)

<xsl:value-of select="pad_long_title_1" />
set variable title = pad_long_title_1

loop element in prog.xml
	if pad_long_title_1 = prog//progName
	set variable ID = progID
<xsl:attribute name="href">/rollercoaster/kidstv/shows/prog<xsl:value-of
select="ID" />.htm</xsl:attribute>
<xsl:value-of select="pad_long_title_1" />	

John Marshall

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

Current Thread