Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 15th, 2007, 07:21 PM
Registered User
Join Date: Aug 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default extract string from value of attribute

You will notice that I am not a programmer, but I am working with some XML files (social research interviews) that I want to display for other researchers to read. Of course, I want to display them in a more firendly way. I wonder if it is possible to do something like this with an XSL stylesheet or XSLT:

I use this kind of elements:

<event desc="laugh" who="all"/>

So, for example, is it possible to output, for every appearance of the <event> element, only the strings that are the value of its attributes?
So, instead of having <event desc="laugh" who="all"/> in the middle of the text, to have only this: LAUGH ALL ?

Reply With Quote
  #2 (permalink)  
Old August 16th, 2007, 02:44 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Yes. You would have a template that matches event and select the nodes you need:
<xsl:template match="event">
<xsl:value-of select="@desc"/><xsl:text> </xsl:text><xsl:value-of select="@who"/>
This would be part of a complete XSLT with a call somewhere via <xsl:apply-templates select="event"/>


Joe (Microsoft MVP - XML)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
extract attribute value xPath chetrity XML 2 April 4th, 2011 07:09 PM
Extract part of String carrie09 Access 6 August 24th, 2007 10:04 AM
Extract first numeric string blkskullwork Javascript 1 November 6th, 2006 02:37 AM
how to extract from a string fraijo SQL Server 2000 3 October 25th, 2006 09:55 PM
How to extract a substring from a string.... muralish MySQL 2 May 18th, 2005 06:58 AM

All times are GMT -4. The time now is 09:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.