1 |
package dk.thoerup.traininfoservice.banedk; |
package dk.thoerup.traininfoservice.banedk; |
2 |
|
|
3 |
import java.io.IOException; |
import java.io.IOException; |
|
import java.util.List; |
|
4 |
import java.util.logging.Level; |
import java.util.logging.Level; |
5 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
6 |
|
|
66 |
int station = Integer.parseInt( req.getParameter("station") ); |
int station = Integer.parseInt( req.getParameter("station") ); |
67 |
String format = req.getParameter("format"); |
String format = req.getParameter("format"); |
68 |
|
|
69 |
List<DepartureBean> beans; |
DepartureBean beans; |
70 |
|
|
71 |
String stationName = StationDAO.getStationName(station); |
String stationName = StationDAO.getStationName(station); |
72 |
|
|
111 |
|
|
112 |
} |
} |
113 |
|
|
114 |
protected String formatXml(List<DepartureBean> beans, String stationName, boolean arrival) throws ServletException{ |
protected String formatXml(DepartureBean beans, String stationName, boolean arrival) throws ServletException{ |
115 |
String xml = ""; |
String xml = ""; |
116 |
try { |
try { |
117 |
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); |
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); |
122 |
Element root = doc.createElement("departureinfo"); |
Element root = doc.createElement("departureinfo"); |
123 |
root.setAttribute("station", stationName); |
root.setAttribute("station", stationName); |
124 |
root.setAttribute("arrival", Boolean.toString(arrival) ); |
root.setAttribute("arrival", Boolean.toString(arrival) ); |
125 |
for (DepartureBean departure : beans) { |
|
126 |
|
for (String notif : beans.notifications) { |
127 |
|
Element notElem = doc.createElement("notification"); |
128 |
|
notElem.setTextContent(notif); |
129 |
|
root.appendChild(notElem); |
130 |
|
} |
131 |
|
|
132 |
|
for (DepartureEntry departure : beans.departureEntries) { |
133 |
Element train = doc.createElement("train"); |
Element train = doc.createElement("train"); |
134 |
|
|
135 |
Element time = doc.createElement("time"); |
Element time = doc.createElement("time"); |