[xsl] Concatenating a nodeset (set of attributes)

Subject: [xsl] Concatenating a nodeset (set of attributes)
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Sat, 8 Oct 2005 15:29:57 +0200
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 :-)

Current Thread