473,405 Members | 2,310 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,405 software developers and data experts.

Help - Conditionally Appending to Value using XSL?

I have XML that looks like the following:

<top>
<heart>
<user>bob</user>
<user>tim-o</user>
<user>joe-i</user>
<user>harvey</user>
</heart>
</top>

and I need to have it look like the following:

<top>
<heart>
<user>bob</user>
<user>tim-out</user>
<user>joe-in</user>
<user>harvey</user>
</heart>
</top>

In other words, I need to conditionally append text based on the data
value (append 'n' if it ends in '-i', append 'ut' if it ends in '-o,
otherwise do nothing). So far, I haven't come across an approach to
accomplish this, but I am pretty much an XSLT newbie. Does anyone have
suggestions on how to accomplish this?

Thanks in advance

Sep 20 '05 #1
1 1511
Hi,

Tempore 19:40:48, die Tuesday 20 September 2005 AD, hinc in foro {comp.text.xml} scripsit jjouett <jj*****@necam.com>:
I need to conditionally append text based on the data
value (append 'n' if it ends in '-i', append 'ut' if it ends in '-o,
otherwise do nothing). So far, I haven't come across an approach to
accomplish this, but I am pretty much an XSLT newbie. Does anyone have
suggestions on how to accomplish this?


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>

<xsl:template match="text()[substring(.,string-length(.)-1,2)='-i']">
<xsl:value-of select="."/>n<xsl:text/>
</xsl:template>

<xsl:template match="text()[substring(.,string-length(.)-1,2)='-o']">
<xsl:value-of select="."/>ut<xsl:text/>
</xsl:template>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Don't send spam. I don't like it and it is illegal.
Sep 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dan | last post by:
Hi, just ran into my first instance of a backend Access97 database not compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on compact. I've narrowed it down to the largest...
4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
4
by: John A Grandy | last post by:
could someone explain the following to me : Appending the literal type character I to a literal forces it to the Integer data type. Appending the identifier type character % to any identifier...
2
by: Jens Weiermann | last post by:
Hi, I need to conditionally disable a html (not web forms) button control. The condition is to be evaluated server-side. What is the smartest way to do this? I'm now using a literal server-side...
5
by: nuffnough | last post by:
This is python 2.4.3 on WinXP under PythonWin. I have a config file with many blank lines and many other lines that I don't need. read the file in, splitlines to make a list, then run a loop...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: kaens | last post by:
So, I have a class that has to retrieve some data from either xml or an sql database. This isn't a problem, but I was thinking "hey, it would be cool if I could just not define the functions for...
4
by: mthread | last post by:
Hi, I am using a string variable in which I do lot of appending. The only difficulty I am facing as of now is appending a integer/float value to this variable. Although I can accomplish this task...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.