Subject: [xsl] String comparison From: "Dineen, Geoffrey" <Geoffrey.Dineen@xxxxxxxxxx> Date: Wed, 4 Sep 2002 16:00:45 +1200 |
Hi I have the following section of XML which I am parsing using the XSL included below it. At the position marked "### conditional test here! ###" I am wanting to do a simple test where I examine the current URL from the "for-each select" statement to see if it contains the string "http://". If it does, the target of the resulting HTML HREF should be "_top" causing the page to load in the entire browser window. If the URL does not contain the "http://" string the page should be loaded in the "ESRCanvas" frame as is currently happening. I'm just starting to learn the XSLT language, but presume I need to use a "choose .... otherwise" statement to get this test to work. I am, however, not so sure on how I do the match between the current URL and the string "http://". I have experimented with the contains() and starts-with() tests but so far without much success. Perhaps I am not using the correct stylesheet version ? I do not quite know where I am going here so would greatly appreciate some help. TIA Geoff <?xml version="1.0"?> <?xml:stylesheet type="text/xsl" href="menus.xsl"?> <TOPICLIST TYPE="ESR Intranet"> <TOPICS TYPE="ESR"> <TOPIC> <TITLE>Home</TITLE> <URL>/default.asp</URL> </TOPIC> </TOPICS> <TOPICS TYPE="Databases & Services"> <TOPIC> <TITLE>Staff Directory</TITLE> <URL>http://intranet/cgi-bin/gateway.exe?displayform=update/manixsue</URL> </TOPIC> </TOPICS> </TOPICLIST> <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <!-- MENUS.XSL --> <xsl:template match="/"> <TITLE><xsl:value-of select="TOPICLIST/@TYPE" /></TITLE> <LINK REL="stylesheet" TYPE="text/css" HREF="/ESRscripts/menus.css" /> <SCRIPT LANGUAGE="JScript" SRC="/ESRscripts/menus.js"></SCRIPT> <!-- BUILD MENUBAR --> <DIV ID="divMenuBar"> <TABLE ID="tblMenuBar" BORDER="0"> <TR height="50%"> <xsl:for-each select="//TOPICS[TOPIC]"> <TD CLASS="clsMenuBarItem" VALIGN="BOTTOM"> <xsl:attribute name="ID">tdMenuBarItem<xsl:value-of select="@TYPE" /></xsl:attribute> <A CLASS="clsTopLevelLink"><xsl:attribute name="HREF"><xsl:value-of select="@TURL" /></xsl:attribute><xsl:value-of select="@TYPE" /></A> </TD> <xsl:if test="context()[not(end())]"> <TD VALIGN="BOTTOM">|</TD> </xsl:if> </xsl:for-each> </TR> </TABLE> </DIV> <!-- BUILD INDIVIDUAL MENUS --> <xsl:for-each select="//TOPICS[TOPIC]"> <DIV CLASS="clsMenu" Left="0"> <xsl:attribute name="ID">divMenu<xsl:value-of select="@TYPE" /></xsl:attribute> <DIV CLASS="clsMenuSpacer"></DIV> <xsl:for-each select="TOPIC"> <DIV> ### conditional test here! ### <A TARGET="ESRCanvas"> <xsl:attribute name="HREF"><xsl:value-of select="URL" /></xsl:attribute> <xsl:value-of select="TITLE" /> </A> </DIV> </xsl:for-each> </DIV> </xsl:for-each> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] can I give xsl:number a s, Jeff Rosler | Thread | RE: [xsl] String comparison, Michael Kay |
[xsl] can I give xsl:number a start, Jeff Rosler | Date | RE: [xsl] String comparison, Jarno . Elovirta |
Month |