Etude exploratoire XML / SVG IDL_CERTU1/ETU_001 / 1.1 - Lara
Etude exploratoire XML / SVG IDL_CERTU1/ETU_001 / 1.1 - Lara
Etude exploratoire XML / SVG IDL_CERTU1/ETU_001 / 1.1 - Lara
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Edité le 11 juin 2002 Annexes de l'étude CERTU6. GENERATION DE LA LEGENDE DE LA CARTE6.1 LA SERVLET (SERVLETLEGENDE.JAVA)package maquettefinale;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import javax.xml.transform.*;import javax.xml.transform.stream.*;public class ServletLegende extends HttpServlet {private static final String CONTENT_TYPE = "image/svg-xml";private StreamSource xmlSource;private Transformer xslTransformer;private String contextPath;/**Initialiser les variables globales*/public void init() throws ServletException {contextPath = this.getServletContext().getRealPath("");try {TransformerFactory tFactory = TransformerFactory.newInstance();xslTransformer = tFactory.newTransformer(new StreamSource(contextPath +"/legende.xsl"));xmlSource = new StreamSource(contextPath + "/pos.svg");} catch (Exception e) {e.printStackTrace();}}/**Traiter la requête HTTP Get*/public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {// Effectue la transformation et renvoie la réponseresponse.setContentType(CONTENT_TYPE);PrintWriter out = response.getWriter();}try {xslTransformer.transform(xmlSource, new StreamResult(out));} catch (Exception e) {e.printStackTrace();}}/**Nettoyer les ressources*/public void destroy() {}6.2 LA TRANSFORMATION XSLT (LEGENDE.XSL)SWORD - Nos réf. : <strong>IDL</strong>_<strong>CERTU1</strong>/<strong>ETU</strong>_002 / 1.0 Diffusion : contrôlée Page : 28/48