[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using XPath to combine text from multiple nodes?

Subject: Re: Using XPath to combine text from multiple nodes?
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Wed, 31 Aug 2005 10:00:42 -0500
xpath select multiple nodes
>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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.