John,
This kind of problem really requires that you resort either to processing
in more than one pass (sort in one pass, format in the next), or use a
node-set() extension function (check the Xalan docs) to turn a Result Tree
Fragment that you get from one application of your templates, into a node
set that you can process with another.
I'm afraid I don't have time to sketch this out in detail at the moment,
but there is enough on using the extension function in the FAQ and
elsewhere on the net, that I think you can puzzle it out. (Hint: bind the
result of your sort routine to a variable. Turn the variable from an RTF
into a node set using the extension function. Then process this node-set
using another set of templates.)
XSLT 2.0 won't need this extension function since this will all happen
transparently.
Cheers,
Wendell
At 05:55 AM 7/25/2003, you wrote:
I am using Xalan-j_2_5_1. I have a set of elements (recovered by SQL),
each containing four child elements: property, prvalue, user_id and
acct_id. I can use the Muench method to obtain a nodeset containing all
elements with a particular value of "property". I can sort this into the
required order. Using a for-each loop I can display this in a table as:
+---------+--------+--------+--------+
|property1|prvalue1|user_id1|acct_id1|
+---------+--------+--------+--------+
|property1|prvalue1|user_id1|acct_id2|
+---------+--------+--------+--------+
|property1|prvalue1|user_id2|acct_id1|
+---------+--------+--------+--------+
I want to display it as:
+--------+------------------+
|property1 - prvalue1 |
+--------+------------------+
|user_id1|acct_id1, acct_id2|
+--------+------------------+
|user_id2|acct_id1 ... |
+--------+------------------+
In order to do this I need to either access the element in my nodeset
before "." or store the values of prvalue and user_id from one iteration
to access in the next iteration, to do the appropriate format control.
I can get the result I need by successively searching the source tree, but
the length of this table makes this unacceptably slow (4 1/2 hours).
I had hoped that EXSLT set:leading() would provide a solution, but I note
that the documentation shows this returns a node set in document order,
not in the order of the sorted subset I have obtained, so I have not
pursued this.
This seems such a common requirement that I am sure there is a
straightforward answer and I apologise if I have missed it.
Thank you.
John Marshall
Accurate Software
80 Peach Street, Wokingham, Berkshire, RG40 1XH, UK.
Tel: +44 (0)118 977 3889
Fax: +44 (0)118 977 1260
http://www.accuratesoftware.com
Accurate Software
info(_at_)accuratesoftware(_dot_)com
www.accuratesoftware.com
Europe . North America . Australasia . Africa
The information in this email is confidential and privileged and is
intended only for the use of the individual or entity listed above. If
you are neither the intended individual, or entity listed above, nor the
person responsible for the delivery of this email to the intended
recipients, you are hereby notified that any unauthorised distribution,
copying or use of this email is prohibited. If you have received this
email in error, please notify the Accurate system manager at
postmaster(_at_)accuratesoftware(_dot_)com or on +44 (0)118 977 3889. The views
expressed in this communication may not necessarily be the views held by
the Accurate Group.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list