Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 28th, 2008, 12:58 PM
Authorized User
Join Date: Apr 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Contains Function

I am trying to do a basic e-mail address validation. I've done:

<xsl:if test="contains(mailaddress, '@') and contains(mailaddress, '.')">

which has cut out some of the rubbish.

firstly can the . and @ be contained in a single "contain"

secondly does anyone have anything else for e-mail checking (I am using version 1) - maybe checking that there must be a dot after the @ sign???? I assume doing something with substring-after(mailaddress, '@') might help, but I've not tried it yet.

thanks in advance

Old February 28th, 2008, 01:16 PM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

This is much too complicated for XSLT 1.0's limited string-handling.

It's quite hard even with regular expressions (available in 2.0). Google for "email address regular expression"

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old February 28th, 2008, 06:16 PM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

As Michael says, in XSLT 1.0 this kind of thing is extremely complicated and hard. It might (dare I say it) be a good place for an extension functon into whatever language you are running this in (e.g. java) if XSLT 2.0 is not an option.

/- Sam Judson : Wrox Technical Editor -/

Similar Threads
Thread Thread Starter Forum Replies Last Post
function keyvanjan ASP.NET 2.0 Professional 1 September 19th, 2007 10:22 AM
How to use Function akumarp2p SQL Server 2000 1 May 28th, 2007 05:04 AM
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.