Subject: RE: [xsl] Selecting text bisected by child nodes. From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Tue, 22 Apr 2003 15:57:05 -0400 |
[ Gan Uesli Starling] > To experiment, I simplified my actual template all the > way down to just this... > > <xsl:template match="op"> > <xsl:value-of select="op/text()"/> > </xsl:template> > > The select="op/text()" lost ALL of the text, but > "../op/text()" and "node()" got as much as > the 'pow(' but still lost the ')' > Easy to understand. When you have selected the "op" nodes, the expression "op/text()" asks for test nodes that are children of op nodes that are children of the context node (which is already op). There are none, so you get nothing back. "../op/text()" __seemed__ to work (partially) but is not what you want because it gets text nodes of all op nodes at that level. You only have one in this sample but you might have more sometime. select='text()' would get all the child text nodes, but you have some grandchildren too. To pick up all the nested text, the easiest thing is to use //text(), which gets them to any nesting depth. You have another problem, too. value-of only gets the string value of the first node (if ther are more than one). That is why you got partial results, even considering that you only asked for children. So finally, here is a simple template that returns all the nested text nested within an "op" node - <xsl:template match='op'> <xsl:copy-of select='//text()'/> </xsl:template> With your example, it gives pow(2.0, -3) I persume that this is what you want, is that right? Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Selecting text bisected b, David Carlisle | Thread | RE: Re: [xsl] xslt query a data, cknell |
RE: [xsl] xsl-fo header problems, G. Ken Holman | Date | Re: [xsl] preceding sibling headach, Andrew Watt |
Month |