Subject: Re: How to select text only for element with mixed content? From: "X Line" <xline1@xxxxxxxxxxx> Date: Thu, 29 Jun 2000 17:45:39 GMT |
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
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.
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>
<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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: How to select text only for ele, Jeni Tennison | Thread | RE: How to select text only for ele, Linda van den Brink |
Multiple output types and embedded , Warren Hedley | Date | [no subject], Hakan Pettersson |
Month |