Re: [xsl] Using XPath to combine text from multiple nodes?

Subject: Re: [xsl] Using XPath to combine text from multiple nodes?
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Wed, 31 Aug 2005 10:00:42 -0500
>Maybe concat and do what I want, but I have been unable to think of a
way to use the >concat function to do what I am after. For an example:
> <Employee first="Mark" second="Allanson" />

Perhaps I'm going to bring up a stupid question and avoid a possibly
interesting discussion about XPath, but in the entire grouping of
similar emails from the past couple days I have to wonder why is it
necessary to do this in one XPath?

Why not:

<xsl:value-of select='@first'/><xsl:value-of select='@second'/>

or more generically (I'd actually put it in a template)
<xsl:for-each select="@*"><xsl:value-of select="." /></xsl:for-each>

Of course, a second glance tells me you might not even be using
XSL....but since this is a mailing list for it I think my examples
aren't too out of scope.  You should be able to apply something

I don't see why concat wouldn't work, but without any more details
there isn't much to go on...
without playing with the xpath too much something like
concat(string(@first),string(@second)) should work, if the objects
aren't automatically converted to string.  If they are,
concat(@first,@second) should work just dandy, I'd imagine.

> 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?

Ummm, you can make an Xpath that unions the two by using the Union
operator.  See the second line in the section 3.3 Node Sets in the
XPath specs

Jon Gorman

Current Thread