%--Script by: Allan Stilwell--%>
<%--This script loads an xml document
in a predetermined format that goes like this:
root level tag can be named anything
this tag is the name of the program
missio_name needs to be replaced with mission name
This script will take an xml document like this and create a drop down list for each program with the mission name as the option.
--%>
<%--First Load the Classes --%>
<%@page import="java.io.FileInputStream,javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder,org.w3c.dom.*" %>
<%--insert html--%>
<%@include file="browseheader.html"%>
 |
 |
Browse the JSC Digital Image Collection |
<%--First parse the document using the DocumentBuilderFactory--%>
<%
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new FileInputStream("/usr/local/jakarta-tomcat-4.0.4/webapps/luceneweb/programs-missions.xml"));
%>
<%--this is the part thats a little hairy--%>
<%
int formcounter = 0;
Element root = doc.getDocumentElement();
String prg=root.getTagName();
NodeList children = root.getChildNodes();
int childrenlength = children.getLength();
int tablerowcheck=1;
int firstrun=0;
for (int i = 0; i < childrenlength; i++)
{
Node node = children.item(i);
String rootstring=node.getNodeName();
NodeList missionNl=node.getChildNodes();
int type=node.getNodeType();
switch (type)
{
case node.ATTRIBUTE_NODE:
out.println("This Should Never print. check the xml code if it does");
break;
case Node.ELEMENT_NODE:
if(tablerowcheck==4)
{
if (firstrun==1)
{
out.println("
");
firstrun=0;
}
out.println("");
}
out.println("| ");
out.println(" | ");
if(tablerowcheck == 2)
{
out.println("
");
tablerowcheck=0;
}
tablerowcheck++;
formcounter++;
break;
}
}
%>
|
 |
<%@include file="./footer.jsp"%>