xsl-list
[Top] [All Lists]

Re: removing characters from a node set

2005-03-30 10:52:58
Duh.  As soon as you said "text node" I realized I'd been thinking of this
as a string and forgotten all about the text node.  Thanks bunches for the
mental slap.

I searched the FAQ again and still didn't find anything directly addressing
this, but it can be extrapolated from the text node entries
(http://www.dpawson.co.uk/xsl/sect2/textnode.html), if only I'd ended up
there.

Thanks again.

-Jonathan

-----Original Message-----
Date: Tue, 29 Mar 2005 17:19:31 +0100
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
From: David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>
Subject: Re: [xsl] removing characters from a node set
Message-Id: 
<200503291619(_dot_)RAA21919(_at_)penguin(_dot_)nag(_dot_)co(_dot_)uk>

This is (or was) a faq, I think there may even be an entry in the faq
list although I haven't checked.

If you use a string function like substring-before on a node it converts
the node to a string first. If you do that on the source node you lose
any child nodes, if you first apply-templates into a variable and then
apply the string function to teh variable you lose the generated html
nodes. 

The solution is not to apply the string function to to an element node
nbut just to its first text child:

<xsl:template match="refdata">
  <li>
  <xsl:apply-templates/>
  </li>
</xsl:template>

<xsl:template match="refdata/text()[1]">
  <xsl:value-of select="substring-after(.,'.')"/>
</xsl:template>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>