Avatar of Molko
Molko

asked on 

XSLT- Trying to negate a String() function

I have attached some XSLT code, the code is fairly repetitive in that a a template i have replaced with the comment   <!--DO STUFF1() --> is called in two places.

I think I could improve the code by using a negating my NOT condition, but I cant seem to make it work properly.

I want to try and say <xsl:when test="
string(substring-after(substring-after($path, '\'), '\')) ">  OR'ed with <xsl:when test="string(substring-after($path, '\')) ">


And help would be greatly received.

Even if its a complete restructure of the code.

Thanks



<xsl:choose>
		<xsl:when test="starts-with($path,'\')"> <!-- Starts with \ - e.g \abc\def\ghi -->
			<xsl:choose>
				<xsl:when test="not (string(substring-after(substring-after($path, '\'), '\'))) ">
					<!--DO STUFF1() -->
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="xxx">
						<xsl:with-param name="$path" select="substring-after(substring-after($path, '\'), '\')"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
		<xsl:otherwise> <!-- Doesn't start with \ - e.g abc\def\ghi-->
			<xsl:choose>
				<xsl:when test="not (string(substring-after($path, '\'))) ">
					<!--DO STUFF1() -->
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="xxx">
						<xsl:with-param name="$path" select="substring-after($path, '\')"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>

Open in new window

Web Languages and StandardsXML

Avatar of undefined
Last Comment
Gertone (Geert Bormans)
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Molko
Molko

ASKER

I'll take a look at that. The 'path' can be like :

c:\window\temp or

\server\temp

hence the conditional processing
I realized that would be the case,
I saw that once you are sure that the possible leading "\" is gone, the processing is exactly the same
you process the bit after the first "\" if it is there, not counting the leading one
so you could first drop that
Avatar of Molko
Molko

ASKER

Yes that quite correct, I also call that function recursively, so that i can iterate over the whole path. So i guess that means i will be assigning a value to $path2 every time - I suppose i can move the variable outside the function call ?

yes, move it outside the function call
Avatar of Molko
Molko

ASKER

Thanks
welcome
Web Languages and Standards
Web Languages and Standards

Web development can range from developing the simplest static single page of plain text to the most complex web-based internet applications, electronic businesses, and social network services using a wide variety of languages and standards, including the familiar HTML, JavaScript and jQuery, ASP and ASP.NET, PHP, ColdFusion, CSS, PHP, Flex and Flash, but also the implementation of a broad list of standards including XML, WSDL, SSDL, VoiceXML and many more.

40K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo