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 8147345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:19:19+00:00 2026-06-06T14:19:19+00:00

This is similar to an earlier problem I was having which you guys solved

  • 0

This is similar to an earlier problem I was having which you guys solved in less than a day.

I am working with XML files that are generated by a digital video camera. The camera allows the user to save all of the camera’s settngs to an SD card so that the settings can be recalled or loaded into another camera. The XSL stylesheet I am writing will allow users to view the camera’s settings, as saved to the SD card in a web browser.

While most of the values in the XML file — as formatted by my stylesheet — make sense to humans, some do not. What I would like to do is have the stylesheet display text that is based on the value in the XML file but more easily understood by humans.

A typical value that can be written to the XML file is “_23_970” which represents the camera’s frame rate. This would be better displayed as 23.970 (or 023.970). The first underscore is a sort of place holder to make a space for values over 099.999. The second underscore, obviously represents the decimal.

My previous (similar) question involved replacing predictable text, and the solution was matching templates. In this case, however, the camera can be set at any one of 119,999 frame rates (I think I did that math correctly).

The approach, I would guess, is to pass a value to the displayed webpage that keeps the numeric values (each digit), replaces the second underscore with a decimal, and replaces the first underscore with either an nbsp or a zero (whichever is easier). If the first character in the string is a “1” (the camera can run at frame rates up to 120.000) then the one should be passed on to the page displayed by the stylesheet.

I have read other posts here regarding wildcards, but couldn’t find one that answered this question.

EDIT: Sorry for leaving out important info. I fared better on my first try at asking a question! I guess I got complacent. Anyhow . . .

I should have shown you the code that displays the text in the XSL file as is:

<tr>
  <xsl:for-each select="Settings/Groups/Recording">
    <tr><td class="title_column">Frame Rate</td><td><xsl:value-of select="RecOutLinkSpeed"/></td></tr>
   </xsl:for-each>
</tr>

I should also have given you the URL for the sample file I have been working with: http://josephthomas.info/Alexa/Setup_120511_140322.xml

  • 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-06-06T14:19:20+00:00Added an answer on June 6, 2026 at 2:19 pm

    Use:

    concat(translate(substring(.,1,1), '_', '&#xA0;'),
           translate(substring(.,2), '_', '.')
          )
    

    Here is a complete transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
         <xsl:copy>
           <xsl:apply-templates select="node()|@*"/>
         </xsl:copy>
     </xsl:template>
     <xsl:template match=
      "td[preceding-sibling::*[1][self::td and . = 'Frame Rate']]/text()">
      <xsl:value-of select=
       "concat(translate(substring(.,1,1), '_', '&#xA0;'),
               translate(substring(.,2), '_', '.')
              )
       "/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on a simple XML document that contains one actual tr element (and one added to test the second case) from the actual XML document as pointed to by the provided link:

    <t>
        <tr>
            <td class="title_column">Frame Rate</td>
            <td>_23_976</td>
        </tr>
        <tr>
            <td class="title_column">Frame Rate</td>
            <td>118_235</td>
        </tr>
    </t>
    

    the wanted, correct result is produced:

    <t>
       <tr>
          <td class="title_column">Frame Rate</td>
          <td> 23.976</td>
       </tr>
       <tr>
          <td class="title_column">Frame Rate</td>
          <td>118.235</td>
       </tr>
    </t>
    

    Explanation:

    The expression:

    concat(translate(substring(.,1,1), '_', '&#xA0;'),
           translate(substring(.,2), '_', '.')
          )
    

    is evaluated in the following way:

    1. The two arguments of the concat() function are evaluated separately (independently from each other).

    2. concat() does what it name implies — concatenates its two string arguments into a single string.

    3. The translate() function is referenced twice in this expression — it is used to produce each of the arguments of `concat().

    4. The first call of translate() is: translate(substring(.,1,1), '_', '&#xA0;') . The first argument that is passed to the function in this case is the leading character of the string value of the current node (in XPath the current (or context) node is denoted by .). This leading character is produced by the function call: substring(.,1,1) which takes a substring starting at offset 1 and having length of 1. The second argument to this call to translate() is a string containing all the characters that we want to replace or delete — in this case just the single "_" character. The third argument to translate() is a string of “replacement characters” that should substitute the corresponding (by position) characters in the second argument. In this casethe third argument contains the single character '&#xA0;' (nbsp), this means that the call to the translate() function will replace the first character of the string value of the current node with nbsp if it happens to be an underscore.

    5. The second call of translate() is similar to the first call: translate(substring(.,2), '_', '.') . However it is applied to the remainder of the current node’s string value (starting from position 2) and replaces any underscore in this remainder with the dot character.

    Update:

    As the OP has difficulties in understanding how to adjust this solution to his own code. here is my guess (as his source XML doccument isn’t the one pointed by the provided link and I cannot guess what the real XML document is):

    <tr>
        <xsl:for-each select="Settings/Groups/Recording">
            <tr>
                <td class="title_column">Frame Rate</td>
                <td>
              <xsl:value-of select=
               "concat(translate(substring(RecOutLinkSpeed,1,1), '_', '&#xA0;'),
                       translate(substring(RecOutLinkSpeed,2), '_', '.')
                      )
               "/>
                </td>
            </tr>
        </xsl:for-each>
    </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered and solved this problem earlier this day and now I run into
This might be a similar problem to my earlier two questions - see here
Guys I asked a similar question like this earlier since I was unable to
Earlier today I asked similar problem to find the maximum element which is common
This question is very similar to an earlier question I asked ( This Question
This is similar to a question that has already been asked. However, I am
I'm sorry if this is similar to an earlier question but this is something
I posted a question similar to this earlier, however, after thinking about it and
I had similar problem few days earlier but now is more complicated. I am
I have a problem using fadeIn() on div that contains elements which positions are

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.