473,382 Members | 1,365 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,382 software developers and data experts.

XST String Reverse

I have a string value in a node of a xml file.
For example:a/b/c/d.
By using XSLT i need to chane the string in a reverse order.
For Example: d/c/b/a.
How to do this please help its urgent.
Oct 23 '08 #1
3 5594
8,658 Expert Mod 8TB
after a while of thinking, this came to my mind:
Expand|Select|Wrap|Line Numbers
  1. // <xsl:param name="input" select="--get-text-here--"/>
  2. <xsl:param name="result"></xsl:param>
  3. <xsl:param name="pos" select="string-length($input)"/>
  5. <xsl:template name="xyz">
  6.   <xsl:param name="result" select="concat($result, substring($input, $pos, 1))"/>
  7.   <xsl:param name="pos" select="$pos - 1"/>
  8.   <xsl:if test="$pos gt; 0">
  9.     <xsl:call-template name="xyz"/>
  10.   </xsl:if>
  11. </xsl:template>
I didn't check it (had no time), maybe you have to use <xsl:with-param>. at least this should get you started.

Oct 23 '08 #2
I have tried out the code it is not working can u check and send me the working code again please it is urgent.
Oct 24 '08 #3
2,057 Expert 2GB
Reduce the string one letter at a time. Then output from the back. As the template calls come back, the string will start outputting from the back first.
Expand|Select|Wrap|Line Numbers
  1. <xsl:call-template name="xyz">
  2.   <xsl:with-param name="input" select="."/><!-- change xpath here -->
  3. </xsl:call-template>
  6. <xsl:template name="xyz"> 
  7.   <xsl:param name="input"/>
  8.   <xsl:if test="string-length($input) &gt; 0">
  9.     <xsl:call-template name="xyz"> 
  10.       <xsl:with-param name="input" select="substring($input, 2)"/>
  11.     </xsl:call-template>
  12.     <xsl:value-of select="substring($input, 1, 1)">
  13.   </xsl:if>
  14. </xsl:template> 
Oct 24 '08 #4

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

Similar topics

by: ineedyourluvin1 | last post by:
Why does this reverse the string ? Sorry about using namespace std ; It made it easier to read :-) Thanks #include<iostream> using namespace std ; void rev_str( char* str ) {
by: google | last post by:
I'm trying to implement something that would speed up data entry. I'd like to be able to take a string, and increment ONLY the right-most numerical characters by one. The type structure of the...
by: Sathyaish | last post by:
This one question is asked modally in most Microsoft interviews. I started to contemplate various implementations for it. This was what I got. #include <stdio.h> #include <stdlib.h> #include...
by: sudharsan | last post by:
could any one please give me a code to reverse a string of more than 1MB .??? Thanks in advance
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
by: Babikie | last post by:
Write a program that performs a reverse recursion with following functions. void swop (char,int,int); void reverse (char); void rev(char,int, int); User should enter a string and all character...
by: Kelly B | last post by:
I tried to write a code which would reverse the order of words in a given string. I.e if Input String=The C Programming Language Output String=Language Programming C The Here is the code...
by: rajash | last post by:
Thanks for the additional comments. Here is a solution to an exercise I had problems with. I still don't think it's really what's wanted as it uses a "state variable" n - but I can't see how to...
by: ssecorp | last post by:
char* reverse(char* str) { int length = strlen(str); char* acc; int i; for (i=0; i<=length-1; i++){ acc = str; } return acc; }
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.