You can't construct new elements using XPath. It looks to me as if you would be better off using XQuery, which allows you to build a structured result in this way. Alternatively, it's not clear to me why you want to combine the expressions in the first place. If you kept them as separate XPath expressions, then you would have no difficult disentangling the results.
Michael Kay

From: Erik Rens []
Sent: 27 March 2009 09:15
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Fwd: Xpath 2.0 sequences and Saxon examples problems.

Just one question left. If i have three or more expressions i want to compile in once.
XPathSelector xps = xpc.compile("/BOOKLIST/BOOKS/ITEM, sum(//BOOKLIST/BOOKS/ITEM/PAGES), avg(//BOOKLIST/BOOKS/ITEM/PAGES)").load();
How do i know which atomic value is SUM or AVG ? I mean some times i have SUM exppression but not always. I will build my xpath statement dynamically. I like to have the elements arround the expression values. Like this:
(For items I use only toString() method to print the Elements).
With debug mode i found in the xps variable an object exp with an array expression with childeren where I can find my statements. Bu i guess they are private so i cant read it.
So is there a simple way to this ?