Sort nodes

A

aerotops

Hi,
I am trying to sort some elements. But my key is a node fragment. How
can I sort this? Or how can I convert a node fragment to a node set?
Thanks,
Harsh.
 
M

Martin Honnen

aerotops wrote:

I am trying to sort some elements. But my key is a node fragment. How
can I sort this? Or how can I convert a node fragment to a node set?

It would help if you mention what language or API you are using. For
instance DOM has document fragment nodes. As you mention node set you
might also be using XSLT but XSLT does not know node fragments but only
result tree fragements. Why do we have to guess?
If you are using XSLT 1.0 and you want to convert a result tree fragment
into a node set then you need to use an XSLT processor that provides an
extension function for that. Many by now have one, but not all, and
while there is this attempt to standardize the name and namespace of
such an extension function
<http://www.exslt.org/exsl/functions/node-set/index.html>
some processors use a different name and/or namespace. So check your
XSLT processor's documentation.

If you want to solve the problem without an extension function then you
need to two pass transformation with two stylesheets which you chain so
that the second stylesheet processes the result of the first stylesheet.
 
H

Harsh Chaudhary

Hi,
I am sorry about the non-specific posting. I should have spelt things
out more clearly. Sorry that you had to guess.

But you guessed right. I am using XSLT 1.0. My processor is dom4j. But I
don't want to use that as I want to keep it pure XSLT. So, no extension
functions. I am aware of the EXSLT function that you mentioned, but I
don't want to use it. I don't want to double pass as it would increase
my cost of the transformation by I think a factor of 2. What I am
looking for is like a hack or something to acheive this. Its a
complicated problem with us being limited to only 4 variable types and
none of them suitable for getting this done. And the fact that variable
values can't be changed.

But if you know how to implement a name-value pair in XSLT, this would
be solved.
Thanks,
Harsh.
 
D

Dimitre Novatchev

Until you haven't shown a concrete example of the xml and the desired result
you're simply wasting (not only) your time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top