xsl-list
[Top] [All Lists]

Re: Using XPath to combine text from multiple nodes?

2005-08-31 08:00:42
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
similar.

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

http://www.w3.org/TR/xpath

Jon Gorman

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