Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jstl xslt listbox  RSS feed

 
Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was he solution to making a dynamic listbox with jstl and xslt with sorted options:
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David because of a bug in the forum software, each time you edit your post, the codes get unreadable and this is the case with your post too. So let me correct the codes and post it so that people including me can read and understand it and then maybe I or someone else might be able to help

I have presently the following code that works fine accept the listbox is not sorted.



This reads in an xml file.



I want to have a listbox that has the hostname attributes sorted ascending. I saw xslt exists. Not real sure how to use this.

I put in my jsp page at the top of the file before the <html> tag:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
I have the closing tags at the bottom after the </html>



This does not seem to work though. Can somebody help me understand whether what I am trying is even possible and how to do this one case?
 
Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was the final code to fix my issue:

<c:import var="xmlfile" url="http://localhost:7001/chowder/xml/mis.xml" />
<x:parse var="doc" xml="${xmlfile}" />


<label for="server">Weblogic Server</label>
<input type="hidden" name="port">
<select name="server" style='width:300px'
onchange="org.cote.js.xml.getXml('/chowder/xml/mis.xml',setPort,1);
org.cote.js.xml.getXml('/chowder/xml/listDS-'+this.value+'.xml',selOptions,1);">
<c:set var="xsl">
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="mis/machine">
<xsl:sort select="@hostname" order="ascending" />
<option value="{@hostname}">
<xsl:value-of select="@hostname" />
</option>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</c:set>
<x:transform xml="${doc}" xslt="${xsl}" />
</select>

 
Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help partners.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!