12.07.2015 Views

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

SHOW MORE
SHOW LESS

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 CERTU9. GENERATION DE LA CARTE DU P.O.S. EN PDF AU FORMAT A39.1 LA SERVLET (SERVLETCARTEA3.JAVA)package maquettefinale;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import org.xml.sax.*;import javax.xml.transform.*;import javax.xml.transform.stream.*;import org.apache.fop.apps.Driver;public class ServletCarteA3 extends HttpServlet {private static final String CONTENT_TYPE = "application/pdf";private StreamSource svgSource, xmlSource;private Transformer xslTransformer, xslsvgTransformer, xslsvglegTransformer;private String contextPath;/**Initialiser les variables globales*/public void init() throws ServletException {contextPath = this.getServletContext().getRealPath("");try {TransformerFactory tFactory = TransformerFactory.newInstance();xslsvgTransformer = tFactory.newTransformer(new StreamSource(contextPath +"/carteA3_svg-fo.xsl"));xslsvglegTransformer = tFactory.newTransformer(new StreamSource(contextPath +"/legendeA3_svg-fo.xsl"));svgSource = new StreamSource(contextPath + "/pos.svg");xslTransformer = tFactory.newTransformer(new StreamSource(contextPath + "/carteA3-fo.xsl"));xmlSource = new StreamSource(contextPath + "/reglement.xml");} catch (Exception e) {e.printStackTrace();}}/**Traiter la requête HTTP Get*/public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {response.setContentType(CONTENT_TYPE);OutputStream out = response.getOutputStream();StringWriter bufWriter = new StringWriter();try {// Création de la carte à inclure dans le documentFile mapFile = File.createTempFile("map",".svg",new File(contextPath));FileWriter fw = new FileWriter(mapFile);xslsvgTransformer.transform(svgSource, new StreamResult(fw));fw.close();// Création de la légende à inclure dans le documentFile legFile = File.createTempFile("leg",".svg",new File(contextPath));fw = new FileWriter(legFile);SWORD - Nos réf. : <strong>IDL</strong>_<strong>CERTU1</strong>/<strong>ETU</strong>_002 / 1.0 Diffusion : contrôlée Page : 44/48

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!