XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
David CorleySubject: Regex + XSLT 2.0
Author: David Corley
Date: 11 Dec 2006 04:36 PM
Hey all,
I have a series of strings matching the following format:
"xxxxxxx\xxxxxxxx\xxxxxxxx\xxxxxxx\abcd.java"

I need to remove everything but "abcd".
Can anyone tell me how to do that within the constraints of the xslt-limited regex?

Postnext
Ivan PedruzziSubject: Regex + XSLT 2.0
Author: Ivan Pedruzzi
Date: 12 Dec 2006 11:18 AM
Originally Posted: 12 Dec 2006 11:19 AM
Hi David,

If the you are just looking for the file name you could do a reverse find on the separator and take the last token.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


<xsl:template name="findlasttoken">
<xsl:param name="string"/>
<xsl:param name="sep" select="'\'"/>
<xsl:variable name="next" select="substring-after($string, $sep)"/>
<xsl:choose>
<xsl:when test="$next">
<xsl:call-template name="findlasttoken">
<xsl:with-param name="string" select="$next"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Posttop
Ivan PedruzziSubject: Regex + XSLT 2.0
Author: Ivan Pedruzzi
Date: 12 Dec 2006 11:21 AM

Forgot to remove the file extension

<xsl:template name="findlasttoken">
<xsl:param name="string"/>
<xsl:param name="sep" select="'\'"/>
<xsl:variable name="next" select="substring-after($string, $sep)"/>
<xsl:choose>
<xsl:when test="$next">
<xsl:call-template name="findlasttoken">
<xsl:with-param name="string" select="$next"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before($string, '.')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.