This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: String comparison


You are using Microsoft's old proprietary WD-xsl language, so you won't
be able to use XSLT constructs like starts-with() and contains() until
you upgrade to XSLT 1.0.

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com 

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com 
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of 
> Dineen, Geoffrey
> Sent: 04 September 2002 05:01
> To: 'XSL-List@lists.mulberrytech.com'
> Subject: [xsl] String comparison
> 
> 
> 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 &amp; Services">
>       <TOPIC>
>          <TITLE>Staff Directory</TITLE>
>  
> <URL>http://intranet/cgi-bin/gateway.exe?displayform=update/ma
> nixsue</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
> 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]