95 |
|
|
96 |
if (format.equalsIgnoreCase("xml")) { |
if (format.equalsIgnoreCase("xml")) { |
97 |
resp.setContentType("text/xml"); |
resp.setContentType("text/xml"); |
98 |
resp.getWriter().print( formatXml(beans, stationName) ); |
resp.getWriter().print( formatXml(beans, stationName, arrival) ); |
99 |
} else if (format.equalsIgnoreCase("html")) { |
} else if (format.equalsIgnoreCase("html")) { |
100 |
|
|
101 |
String advStr = req.getParameter("advanced"); |
String advStr = req.getParameter("advanced"); |
112 |
|
|
113 |
} |
} |
114 |
|
|
115 |
protected String formatXml(List<DepartureBean> beans, String stationName) throws ServletException{ |
protected String formatXml(List<DepartureBean> beans, String stationName, boolean arrival) throws ServletException{ |
116 |
String xml = ""; |
String xml = ""; |
117 |
try { |
try { |
118 |
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); |
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); |
122 |
Document doc = impl.createDocument(null,null,null); |
Document doc = impl.createDocument(null,null,null); |
123 |
Element root = doc.createElement("departureinfo"); |
Element root = doc.createElement("departureinfo"); |
124 |
root.setAttribute("station", stationName); |
root.setAttribute("station", stationName); |
125 |
|
root.setAttribute("arrival", Boolean.toString(arrival) ); |
126 |
for (DepartureBean departure : beans) { |
for (DepartureBean departure : beans) { |
127 |
Element train = doc.createElement("train"); |
Element train = doc.createElement("train"); |
128 |
|
|