Subject: RE: "xsl:if" - Comparing two elements From: "Pete Beazley" <pete@xxxxxxxxxxxxxxxxx> Date: Wed, 2 Jun 1999 16:32:21 -0400 |
Mark - Try changing ../bestReturn to //bestReturn in your test in order to match bestReturn regardless of where it is located in your document - that seemed to do the trick on my system using IE5. P.S. You might want to send future messages in plain text. Yours came through as RTF attachments. I've included your message in plain text for those not able to open the RTF attachments. -------- Pete Beazley - mailto:pete@xxxxxxxxxxxxxxxxx ClearlyOnline, Inc. XML-based Web Sites & XML services http://www.clearlyonline.com 1-724-942-1912 1-724-941-3698 fax > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of > markbender@xxxxxxxxxxxxxxxxxxxxxx > Sent: Wednesday, June 02, 1999 3:51 PM > To: XSL-List@xxxxxxxxxxxxxxxx > Subject: "xsl:if" - Comparing two elements > > >Greetings, I'm having an extremely frustrating time trying to compare two xml elements using the following command: <xsl:if test="ThisThing[. = ThisOtherThing]">do this</xsl:if> Heck, it won't even work if I try ThisThing[. = ThisThing]. The only way I can get this to work is if I acutally compare "ThisThing" to a string ThisThing[. = '12345'] ). Here's an example: *********** EXAMPLE XML ******************** <?xml version="1.0"?> <portfolio xmlns:dt="urn:schemas-microsoft-com:datatypes"> <bestReturn>ZCXM</bestReturn> <stock exchange="nyse"> <name>zacx corp</name> <symbol>ZCXM</symbol> <price dt:dt="number">28.875</price> </stock> <stock exchange="nasdaq"> <name>zaffymat inc</name> <symbol>ZFFX</symbol> <price dt:dt="number">92.250</price> </stock> <stock exchange="nasdaq"> <name>zysmergy inc</name> <symbol>ZYSZ</symbol> <price dt:dt="number">20.313</price> </stock> </portfolio> *********** EXAMPLE XSL ******************** <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" result-ns="http://www.w3.org/TR/REC-html"> <xsl:template match="/"> <HTML> <BODY> <B>Best Historical Return: </B><xsl:value-of select="portfolio/bestReturn"/> <BR/><BR/> <B><I>My Portfolio</I></B><BR/> <TABLE BORDER="2"> <TR> <TD><B>Symbol</B></TD> <TD><B>Name</B></TD> <TD><B>Price</B></TD> <TD><B>Best Return</B></TD> </TR> <xsl:for-each select="portfolio/stock"> <TR> <TD><xsl:value-of select="symbol"/></TD> <TD><xsl:value-of select="name"/></TD> <TD><xsl:value-of select="price"/></TD> <TD> <!-- HERE'S MY PROBLEM --> <xsl:if test="symbol[. = ../bestReturn]">Yes</xsl:if> <!-- THE EXAMPLE BELOW WORKS, BUT IT'S COMPARING TO A STRING RATHER THAN ANOTHER ELEMENT--> <xsl:if test="symbol[not(. = 'ZCXM')]">No</xsl:if> </TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet> ****************************************** What am I doing wrong? Please help me, for sanity's sake. --Mark XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
"xsl:if" - Comparing two elements, markbender | Thread | MSXSL - Implied Table Loops, David RR Webber |
Re: A would-be user's first XSL exp, jmbolles | Date | MSXSL - Implied Table Loops, David RR Webber |
Month |