[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Substring test

Subject: Re: Substring test
From: "Aaron Johnson" <artpunx@xxxxxxxxx>
Date: Thu, 26 Oct 2006 14:04:36 +0100
xsl substring test
Thanks Owen and David for your help.

I gave your version a try but got no further.

Taking Davids advice, here goes a simple example:

The name attribute has a value of 'Home'...

<navigation>
	<focusedTab unremovable="true" immutable="true" ID="38" name="Home"/>
</navigation>

...when I run the template below, it shows the correct respnse:
	
	<h1>Not Broken</h1>
	
	<xsl:template match="navigation/focusedTab">
			<xsl:call-template name="activeTab"/>
	</xsl:template>
	
	<xsl:template name="activeTab">
		<xsl:choose>
			<xsl:when test="//focusedTab/@name='Home'">
				<h1>Not Broken</h1>
			</xsl:when>
			<xsl:otherwise>
				<h1>Broken</h1>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	</xsl:stylesheet>

If the name attribute has a value of 'Home::foo'. When I run the
template again, because it is not  "Home" it shows the correct
respnse:

<navigation>
	<focusedTab unremovable="true" immutable="true" ID="38" name="Home::foo"/>
</navigation>

<h1>Broken</h1>

I still need the 'Home' part of the element to trigger stuff...

What I want to do is test for 'Home' and ignore the following '::foo'
part of the element, effectively breaking it up into two parts 'Home'
and '::foo'.


On 10/26/06, Owen Rees <owen.rees@xxxxxx> wrote:
--On 26 October 2006 10:29 +0100 Aaron Johnson wrote:

> I gave this a go:
>
> <xsl:when
> test="($tabName[substring-before(@name,'::')]='Home')">home</xsl:when>

If I understand what you are trying to do, the "='Home' should be inside
the predicate like this:

<xsl:when
test="($tabName[substring-before(@name,'::')='Home'])">home</xsl:when>

--
Owen Rees
Hewlett Packard Laboratories, Bristol, UK

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.