Hi Begue,
You can't just create a ScriptingEnvironment. One is created
as part of the build of the document (if appropriate). Unfortunately
we currently don't provide real access to the Window Object from
Java. Fortunately you can fairly easily implement all the window
object functions yourself in Java - if in no other way than by
copying the implementation that Batik provides in the
BaseScriptingEvironment.Window inner class (although often you
can do a better job by just using the JDK classes).
BEGUE Pierre wrote:
i try to use parseXML and postURL the error message it's :
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
cause mère
java.lang.NullPointerException
org.apache.batik.bridge.BaseScriptingEnvironment.<init>(Unknown Source)
org.apache.batik.bridge.ScriptingEnvironment.<init>(Unknown Source)
org.apache.jsp.savesvg_jsp._jspService(savesvg_jsp.java:153)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
and this my code. I don't why he do this :
/*creation du document en utilisant DOMImplementation, Le Document créé
supporte du XML générique et du SVG,
Le Document sera casté en (SVGDocument) */
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
try{
String svgURI = new
File("C:/stage(iftechnologie)/Lege/Lege/LegeParc.svg").toURL().toString();
FileInputStream instream = new
FileInputStream("C:/stage(iftechnologie)/Lege/Lege/LegeParc.svg");
InputStreamReader istream = new InputStreamReader(instream);
TranscoderInput input = new TranscoderInput(istream);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
Document doc = f.createDocument(svgURI);
/*Construit le contenu SVG */
// récupère l'élément « root »
Element svgRoot = doc.getElementById("map");
// définie la taille de l'éléemnt « root » pour l'affichage
svgRoot.setAttributeNS(null, "width", "399");
svgRoot.setAttributeNS(null, "height", "450");
SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
FileOutputStream outStream = new
FileOutputStream("C:/stage(iftechnologie)/Lege/Lege/sortieFlux.svg");
Writer outf = new OutputStreamWriter(outStream, "UTF-8");
DOMUtilities.writeDocument(doc,outf);
svgGenerator.stream(outf, true);
outf.flush();
/*******/
/* il va me balancer un string du genre "bati.svg;PLU.svg"
* en fonction des fichiers svg contenue en fonction du plan
(LegePlan1..2..)
* donc je compte le nombre de ";" qui correspond au nombre de truc
coché
* ensuite je lis jusqu'a atteindre un ";" et je concatene le tout et
je fais
* le appendchild
* sur chaque fichier lu faut que rajoute le numero en fonction du plan
*/
String niveau = (String) request.getParameter("niveau");
String couche = (String) request.getParameter("couche");
String rep1 = "C:/stage(iftechnologie)/Lege/Lege/LegePlan";
niveau = "1";
couche = "LegePlu1.svg";
rep1 = rep1 + niveau;
rep1 = rep1 + "/";
String[] couche1 = couche.split(";");
UserAgent ua = new UserAgentAdapter();
BridgeContext bc = new BridgeContext(ua);
ScriptingEnvironment se = new ScriptingEnvironment(bc);
Window window = se.createWindow(null,"moi");
//lecture des niveau couches
for (int i=0;i<couche1.length;i++)
{
String res = " ";
window.postURL(rep1+couche1[i],res,null);
//recuperer l'element *.svg
Node node = window.parseXML(res,doc);
//ici je replace les differents niveaux dans le nouveau svg
document géré
Element svgRoot1= doc.getElementById("map");
svgRoot1.appendChild(node);
}
}
catch (IOException e){}
thanks very much.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]