Mohit,
At 11:17 AM 9/10/2008, you wrote:
Thanks. I was thinking that sort gets applied to output if it's put
inside xsl:apply-templates, but it looks like it just works on input.
Thanks for the explanation.
You're welcome, but I should also warn you that this bit of confusion
may be indicative of a deeper problem, namely a hazy understanding of
the processing model.
As has been repeated often on this list, XSLT doesn't "change" or
even "operate" on anything. What it does is build XML. Most commonly,
it builds its output XML by following a set of rules (the stylesheet)
as applied to another XML, which is considered the "input". (In your
case it is complicated by the fact that you have more than one input
file, but the basic situation is the same.) The XSLT process doesn't
change the input at all: when the operation is complete, any input is
still there exactly as it was. If your process has run successfully,
you also now have an output.
A sort, or for that matter any XSLT instruction or specification,
doesn't work on output or on input. It simply says something about
how the output (the "result") is built.
This matters here because as long as you persist in thinking you're
sorting output or sorting input, as opposed to specifying the rules
whereby your processor builds the result, you're unlikely to be able
to set those rules up properly. XSLT has a "normal" way of operating:
by default, it will build its output in an order corresponding to the
order of the nodes in the input that it selects for examination
("processing"). What a sort does is override this behavior by telling
the processor to put the results in a different order. So you are
"sorting" the input, but what "gets sorted" is the output.
This makes no sense at all until you understand how any XSLT
transformation works, at which point it becomes obvious, as in "but
how else could it be?", and much easier to manage. The result
reflects an imposed ("sorted") order of the input data instead of its
native "document order".
Is there a way I could do this in one xslt itself?
Probably, but you haven't given us enough information to say. You
haven't even given us enough information to determine if your problem
is due to a bug in your XSLT engine, or in something you are doing or
not doing.
I suggest you try again to compose a complete problem. Show us a
minimal small example of input, the code that you are currently
using, the result it is generating, and a description of what you
want instead. Also tell us what XSLT processor you are using in case
the processor isn't doing the right thing (since we can't guess what
it will do if it doesn't do what it's supposed to).
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
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
======================================================================