473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

XSL replace value with string

I'm a newbie, and I have an XML data file with Book data. I'm trying to replace a value with a string. Specifically trying to test for "if value is less than 5.00 than replace value with the string "Free". Here is what is not working but I receive no errors.
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="value">
  2.       <xsl:if test="value &amp;lt;= 5.00">
  3.       <xsl:value-of select="Free" />"
  4.       </xsl:if>
  5.     </xsl:for-each>
  6.  
Jul 14 '08 #1
3 4438
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.       <xsl:if test=". &amp;lt;= 5.00">
  2.  
Once you do the for-each, you're already in the value node. Your current code looks for a value node inside the value node! eg like:

Expand|Select|Wrap|Line Numbers
  1. <value>
  2.   <value>5.00</value>
  3. </value>
  4.  
Jul 14 '08 #2
jkmyoung
2,057 Expert 2GB
From go4gator
--------------------------------------------------------------------------------

It still doesn't work. Maybe more code will give you more insight. I think I may need to declare the string "Free" somehow. Got any ideas? The second sort works fine.
I changed the code to:

Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="books/book">
  2. <xsl:if test="value &lt;= 5.00">
  3. <xsl:value-of select='free'/>
  4. </xsl:if>
  5. </xsl:for-each>
  6. <xsl:for-each select="books/book">
  7. <xsl:sort select="edition" order="descending" />
  8. <tr>
  9. <td><xsl:value-of select="title"/></td>
  10. <td><xsl:value-of select="rating"/></td>
  11. <td><xsl:value-of select="author"/></td>
  12. <td><xsl:value-of select="publisher"/></td>
  13. <td><xsl:value-of select="condition"/></td>
  14. <td><xsl:value-of select="binding"/></td>
  15. <td><xsl:value-of select="value"/></td>
  16. <td><xsl:value-of select="edition"/></td>
  17. </tr>
  18.  
  19. </xsl:for-each>
  20.  
Thanks again
Jul 15 '08 #3
jkmyoung
2,057 Expert 2GB
<xsl:value-of select="'free'"/>

Use single quotes inside the double quotes to declare 'free' as a string.
Jul 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
5
by: K.Simon | last post by:
Hello, it's very often neccessary to replace strings or a single character in my stylesheets. My solution looks awful and very long. Now i thought to solve this with an array like structure but...
22
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
9
by: Peter Row | last post by:
Hi, I know this has been asked before, but reading the threads it is still not entirely clear. Deciding which .Replace( ) to use when. Typically if I create a string in a loop I always use a...
4
by: Derek Martin | last post by:
I have an object with several string elements that I would like to check for invalid characters in the properties of each element. Can I use string.replace to do that or is there a better...
16
by: BBM | last post by:
This is so bizarre I hesitate to post it, but I need to get this working. My code looks like this... Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _ " WHERE Scenario =...
1
by: Random Task | last post by:
Can someone help me by providing an example of how to replace / with \ in a string in xslt2. The characters / and \ seem to cause me grief ... I am trying the below code currently ... Any...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
3
by: Hvid Hat | last post by:
Hi I want to highlight (make it bold) a word in some text I'm getting in XML format. My plan was to replace the word with a bold (or span) tag with the word within the tag. I've found the code...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.