[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to select text only for element with mixed content?

Subject: RE: How to select text only for element with mixed content?
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Fri, 30 Jun 2000 10:48:17 +0200
xsl value of select text
If you want all the text nodes, you have to use xsl:for-each instead of
xsl:value-of. xsl:value-of always gets the value of the first matching node.


So use something like this: 

<xsl:template match="Tag1">
	<Test1>
		<xsl:for-each select="text()">
			<xsl:value-of select="."/>
		</xsl:for-each>
	</Test1>
</xsl:template>

Linda

> -----Original Message-----
> From: X Line [mailto:xline1@xxxxxxxxxxx]
> Sent: Thursday, June 29, 2000 7:46 PM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Re: How to select text only for element with mixed content?
> 
> 
> 
> >If you want to get the value of text that
> >isn't just whitespace, you can use a predicate to choose 
> only those bits of 
> > >text that aren't made up solely of whitespace:
> ><xsl:value-of select="text()[normalize-space(.) != '']" />
> >Jeni
> 
> Hi Jeni and others who responded to my query.
> 
> Thanks much for your help. Apprciate it. However,
> using jclark's XT, either version of text() (by
> itself or with normalization), only the
> text node before any element node is returned.
> Any text after an element node is ignored.
> 
> eg:
> 
> Using the following XML & templates,
> only the text "This is some text" is returned.
> 
> 
> <?xml version="1.0"?>
> <Tag1>
>    This is some text.
>    <Tag2>Text for Tag2 </Tag2>
>    Some additional text.
>    <Tag3>Text for Tag3 </Tag3>
>    And some ending text.
> </Tag1>
> 
> 
> 
> 
> <?xml version="1.0" ?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="/">
>    <document>
>     <xsl:apply-templates/>
>    </document>
> </xsl:template>
> 
> 
> <xsl:template match="Tag1">
>    <Test1>
>       <xsl:value-of select="text()"/>
>    </Test1>
> 
>    <Test2>
>       <xsl:value-of select="text()[normalize-space(.) != '']" />
>    </Test2>
> </xsl:template>
> 
> </xsl:stylesheet>
> ______________________________________________________________
> __________
> Get Your Private, Free E-mail from MSN Hotmail at 
http://www.hotmail.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.