Re: [xsl] xml as parameter from servlet

Subject: Re: [xsl] xml as parameter from servlet
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Sun, 07 Apr 2002 09:46:06 -0800
Hi again,

Maybe I am going about this the wrong way. Perhaps there is a simpler XSLT/java way?

I have a multi select list box that lists the contents of a folder on a web site. This list is the labels (with the value being the corresponding ID) that would appear in a nav.

The user moves folder items up and down to change the order in which they are displayed in the nav.

On submit i get a comma delimted String of IDs that I split on the server to make the nodeset I am passing to the transformation.

The transformation loops on the nodeset passed in and reorders the folder, like so:

<xsl:param name="nav_order"/>

<xsl:template match="folder">

<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:choose>
<xsl:when test="@id=$nav_order/order/@id">
<xsl:variable name="current_nodeset" select="."/>
<xsl:for-each select="$nav_order/order/item">
<xsl:variable name="id" select="@id"/>
<xsl:apply-templates select="$current_nodeset/*[@id=$id]" mode="sorted"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>


<xsl:template match="folder | page | col" mode="sorted">

<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match="node()|@*">

<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


Is there a better way to do this?

best,
-Rob



J.Pietschmann wrote:

Robert Koberg wrote:

It works. I found a spelling error in my XSLT (groan...). I am not sending a string to be magically processed. I am transforming it into a nodeset before setting the parameter for the transformation.


Sorry, didn't read past println("xml_para_string...)

but it is pretty slow for such a small amount of data...

Your data is already structured, so it seems to be a bad idea to bild something less structured (string) and then parse it to regain the original structure. Furthermore, DOM trees produce even more overhead.

I will look into your third suggestion it sounds like what i want to do.

Well, glad to be of *some* help.


J.Pietschmann


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list






XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread