Subject: Re: [xsl] Using XPath to combine text from multiple nodes? From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 31 Aug 2005 16:00:59 +0100 |
> Is there any way to write an XPath expression that will combine the > text within two nodes and return a text node that contains the > combined strings. No, not without using a user-supplied function as Xpath does not generate new nodes, it only returns node in the source, or atomic values. Howver an XPath function could do this (and in xslt2 you can write xpath functions using xslt rather than using an extension mechanism) But probably you don't _really_ need a text node do you? wouldn't you be happy with a returned string? > Although I don't think this would affect any solutions, the xpath > processor is the .Net Framework v1.1. Only in so far as it means that you are looking for an xpath1 solution which rather limits things here as xpath1 doesn't have "node lists" which is what you are asking for but "node sets", which have no order. > <Employee first="Mark" second="Allanson" /> > > What I would like to do in this case is to effectively return a node > that contains the text "MarkAllanson". as I say you can't return a text node but you could return the string concat(@first,@second) it depends what you want to do with it after that. > Is it possible to write an XPath to return a node list that contains > both the first attribute of the employee and the City element of the > address? yes of course, except that attribute order is implementation defined so it's best to select attribute by name rather than number as @*[1] is legal but selects an essentially arbitrary attribute. Employee/@first|Address/City returns the node set that you require. 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using XPath to combine te, Jon Gorman | Thread | Re: [xsl] Using XPath to combine te, JBryant |
Re: [xsl] Using XPath to combine te, Jon Gorman | Date | [xsl] RE: help understanding xslt , Evan Lenz |
Month |