finding the string before a special character

Suppose i have an xml file.
i have to write an xsl file so that it should allow characters from
a-z and A-Z and numbers and '_' and '/'.
if the string is having any other character then it should display the string before the special character.
if the string is not having any other special characters then it should display normally.

my xml file is:

<?xml version="1.0"?>

in this case the output should be :
pease give a solution to this.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you could use the substring-before function

Here's a stylesheet that does what you want.  It uses the translate function to create a variable containing only the special charaters.  it then uses the first of these in the subbstring-before to output the beginning

<xsl:stylesheet version="1.0" xmlns:xsl="">

<xsl:template match="name">
      <!-- translate out the non-special characters, leaving the special characters -->
      <xsl:variable name="specialChars" select="translate(.,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_/','')"/>
            <!-- If there are no special characters, output the whole name -->
            <xsl:when test="string-length($specialChars) = 0">
                  <xsl:value-of select="."/>
            <!-- Otherwise output the string before the first special character -->
                  <xsl:variable name="firstSpecialChar" select="substring($specialChars,1,1)"/>
                  <xsl:value-of select="substring-before(.,$firstSpecialChar)"/>



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.