Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:45:42+00:00 2026-05-26T14:45:42+00:00

I am now doing a html to xml xslt transformation, pretty straigh-forward. But I

  • 0

I am now doing a html to xml xslt transformation, pretty straigh-forward. But I have one slight problem that is left unsolved.

For example, in my source html, a node looks like:

<p class="Arrow"><span class="char-style-override-12">4</span><span class="char-style-override-13"> </span>Sore, rash, growth, discharge, or swelling.</p>

As you can see, the first child node < span> has a value of 4, is it actually rendered as a arrow point in the browser (maybe some encoding issue, it is treated as a numeric value in my xml editor).

So my question is, I wrote a template to match the tag, then pass the text content of it to another template match :

 <xsl:template match="text()">
    <xsl:variable name="noNum">
        <xsl:value-of select="normalize-space(translate,'4',''))"/>
    </xsl:variable>
 <xsl:copy-of select="$noNum"/>    
  </xsl:template>  

As you can see, this is definitely not a good solution, it will replace all the numbers appearing in the string, not only the first character. So I wonder if there is a way to remove only the first character IF it is a number, maybe using regular expression? Or, I am actually going the wrong way, should there be a better way to think of solving this problem(e.g, changing the encoding)?

Any idea is welcomed! Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:45:42+00:00Added an answer on May 26, 2026 at 2:45 pm

    Just use this :

    <xsl:variable name="test">4y4145</xsl:variable>
    <xsl:if test= "not(string(number(substring($test,1,1)))='NaN')">
        <xsl:message terminate="no">
                  <xsl:value-of select="substring($test,2)"/>
        </xsl:message>
    </xsl:if>
    

    This is a XSLT 1.0 solution. I think regex is an overkill for this.

    Output :

    [xslt]                           y4145
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that creates a file. I am now doing integration tests
We have to compare responses (XML) of two different but they are doing the
I have an XSL that transforms an XML file into a HTML file. Works
I have some questions concering routing with Codeigniter. What I´m doing now is the
Now i am doing an android application.In that application I am using asynchtask class
Now I am doing an application.In my app I have to change textview value
I have a java program that generates an HTML file. The Java program takes
I have android application that is written regular way. layouts, java, APK. Now, depending
I have a servlet that users post a XML file to. I read that
I have had the problem a few times now while working on projects and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.