I need a fresh outlook on a problem I have been working on. I am very new to XSL, so I am hoping that I am just missing something obvious. I have a node containing images. Each image has a sortorder used to determine the order of the image in a slideshow. I am now working on an interface to allow a user to reorder these images. I have a function that will update the sortorder attribute of two images when passed the two valid sortorder attribute values. So for my sample xml shown, I could reorder the first and second images by passing the following values:
ReorderImages("1", "60")
I would accomplish this by passing my values in the QueryString on an ASP page like this:
page.asp?op=reorder&oldsor
torder=1&n
ewsortorde
r=60
This would simply swap the two values on the sortorder attributes. This all works fine. My problem is creating the hyperlinks on my XSL stylesheet, so that they have the correct hyperlinks based on the order of the sortorder attribute. If I do something like this:
<xsl:for-each select="images/image">
<xsl:sort data-type="number" select="@sortorder" order="ascending" />
<a>
<xsl:attribute name="href">
<xsl:text>?op=reorder</xsl
:text>
<xsl:text>&oldsortorde
r=</xsl:te
xt>
<xsl:value-of select="@sortorder" />
<xsl:text>&newsortorde
r=</xsl:te
xt>
<xsl:value-of select="'previous image sortorder'" />
</xsl:attribute>
</a>
<a>
<xsl:attribute name="href">
<xsl:text>?op=reorder</xsl
:text>
<xsl:text>&oldsortorde
r=</xsl:te
xt>
<xsl:value-of select="@sortorder" />
<xsl:text>&newsortorde
r=</xsl:te
xt>
<xsl:value-of select="'next image sortorder'" />
</xsl:attribute>
</a>
</xsl:for-each>
</xsl:stylesheet>
I end up having problems capturing the next or previous sortorder attribute. When I use something like: following-sibling, it does not look at the xsl:sort that I am applying, it simply looks at the next node as it appears in my XML file. I could write a more complex function that would do all the work behind the scenes to update the sortorder of two nodes but my objective for this project has been to learn more about XSL, so I would really like to accomplish it that way.