xsl-list
[Top] [All Lists]

Re: Concatenating a nodeset (set of attributes)

2005-10-08 13:39:46
In XSLT 2.0 this is quite straightforward.

If you provide a really wellformed xml, somebody may try to solve your
problem in XSLT 1.0.

In the meantime, do have a look at this solution -- a generic sort
with varying/statically-unknown number of sort keys:

           http://www.biglist.com/lists/xsl-list/archives/200303/msg00007.html

--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.




On 10/8/05, Ragulf Pickaxe <ragulf(_dot_)pickaxe(_at_)gmail(_dot_)com> wrote:
Hi all,

Using XSLT 1.0

I have a table of contents that is of the following (endtags abreviated):

<TOC>
 <STRUC pos="3" title="sometitle"><STRUC pos="1" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="4" title="Another"></ </
 <STRUC pos="2" title="sometitle"><STRUC pos="1" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="2" title="Another"></ </
 <STRUC pos="2" title="sometitle"><STRUC pos="3" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="6" title="Another"></ </
</TOC>

The depth of the STRUC elements is arbitrary.

<TOC>
 <STRUC pos="2" title="sometitle"><STRUC pos="1" title="Another"></ </
 <STRUC pos="2" title="sometitle"><STRUC pos="3" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="1" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="2" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="4" title="Another"></ </
 <STRUC pos="3" title="sometitle"><STRUC pos="6" title="Another"></ </
</TOC>

When I am at the TOC element, I want to process the top STRUC
elements, sorting them in full depth.

If I can concatenate all pos attributes, I will be able to do this.
As far as I know, I cannot say:
<xsl:sort select="concat(.//STRUC/@pos)" date-type="number"/>

Is there some other way that I can achieve this? Does the following work?
<xsl:sort select=".//STRUC/@pos" data-type="number"/>

I have not tried sorting more complicated than on a single element or
attribute, so I am a little unsure of the mechanics in this.

Another problem is of course where @pos > 10. If I had full control, I
could do something like:
<xsl:sort select="translate(.//STRUC/@pos,'0','A')" data-type="text"/>

Is this workable? If not, is there someway else that I can achieve this?

I am doing a lot with the data, besides just sorting them, so it is
not so clearcut as an identity transformation sorting each element.

I hope help is possible :-)

Regards,
Ragulf Pickaxe :-)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--