Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2007, 07:21 PM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default extract string from value of attribute

Hi,
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 ?


 
Old August 16th, 2007, 02:44 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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"/>
</xsl:template>
This would be part of a complete XSLT with a call somewhere via <xsl:apply-templates select="event"/>

--

Joe (Microsoft MVP - XML)





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.