@SuppressWarnings("nls") private void writePluginJpf(IProgressMonitor monitor, IProject project) throws CoreException { Document doc = new Document(); doc.setDocType(new DocType("plugin", "-//JPF//Java Plug-in Manifest 1.0", "http://jpf.sourceforge.net/plugin_1_0.dtd")); Element rootElem = new Element("plugin"); doc.setRootElement(rootElem); rootElem.setAttribute("id", project.getName()); rootElem.setAttribute("version", "1"); Element requires = new Element("requires"); rootElem.addContent(requires); Element runtime = new Element("runtime"); Element srcLib = new Element("library"); srcLib.setAttribute("type", "code"); srcLib.setAttribute("path", "classes/"); srcLib.setAttribute("id", "classes"); Element export = new Element("export"); export.setAttribute("prefix", "*"); srcLib.addContent(export); runtime.addContent(srcLib); rootElem.addContent(runtime); fFirstPage.customizeManifest(rootElem, project, monitor); if( requires.getContentSize() == 0 ) { rootElem.removeContent(requires); } IFile manifest = JPFProject.getManifest(project); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { xmlOut.output(doc, baos); } catch( IOException e ) { throw new RuntimeException(e); } manifest.create(new ByteArrayInputStream(baos.toByteArray()), true, monitor); }
/** * From AbstractOutput - finished up the SVG output. * @param width The output width (in pixels) of the barcode * @param height The output height (in pixels) of the barcode. */ public void endDraw(int width, int height) throws OutputException { root.setNamespace(Namespace.getNamespace("svg", "http://www.w3.org/2000/svg")); root.setAttribute("width", getScaledDimension(width)); root.setAttribute("height", getScaledDimension(height)); doc.setDocType(new DocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd")); try { BufferedWriter bw = new BufferedWriter(writer); XMLOutputter outputter = new XMLOutputter(); outputter.output(doc, bw); bw.flush(); bw.close(); } catch (IOException e) { throw new OutputException(e.getMessage(), e); } }
protected Document createDocument(Element root) { Document doc = new Document(root); DocType docType = new DocType(RSS091NetscapeParser.ELEMENT_NAME, RSS091NetscapeParser.PUBLIC_ID, RSS091NetscapeParser.SYSTEM_ID); doc.setDocType(docType); return doc; }
/** * addEntityRef * * @param inputLasDoc Document * @param entityReference EntityRef */ public static void addEntityRef(Document inputLasDoc, String entityName, String ofile, EntityRef entityReference) { DocType docType = inputLasDoc.getDocType(); String entityString = docType.getInternalSubset(); // Get rid of the file:/// references to the existing entities String shortEntityString = ""; StringTokenizer tokenizer = new StringTokenizer(entityString, "\n"); while (tokenizer.hasMoreTokens()) { String entity = tokenizer.nextToken(); if (entity.indexOf("file:/") >= 0) { entity = entity.substring(0, entity.indexOf("file")) + entity.substring(entity.lastIndexOf("/") + 1, entity.length()); shortEntityString += entity + "\n"; } else { shortEntityString += entity + "\n"; } } entityString = shortEntityString + " <!ENTITY " + entityName + " SYSTEM \"" + ofile + "\">\n"; docType.setInternalSubset(entityString); Element lasdata = inputLasDoc.getRootElement(); lasdata.addContent(entityReference); lasdata.addContent("\n"); }
private void generate_application_xml_config(){ Element root = new Element("beans"); Document doc = new Document(root); DocType dt = new DocType("beans","-//SPRING//DTD BEAN//EN","http://www.springframework.org/dtd/spring-beans.dtd"); doc.setDocType(dt); Element bns = new Element("bean"); bns.setAttribute("id","remoteService"); String className = "Remote"+CodeGenUtils.getPartialName(applicationService)+"Impl"; bns.setAttribute("class",basePackage+"application.server."+className); root.addContent(bns); this.outputDocumentToFile(doc,sourceFolder+"/"+"applicationContext.xml"); }
private void generate_http_invoker_xml_config(){ Element root = new Element("beans"); Document doc = new Document(root); DocType dt = new DocType("beans","-//SPRING//DTD BEAN//EN","http://www.springframework.org/dtd/spring-beans.dtd"); doc.setDocType(dt); Element bean = new Element("bean"); bean.setAttribute("id","defaultHandlerMapping"); bean.setAttribute("class","org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"); root.addContent(bean); Element rBean = new Element("bean"); rBean.setAttribute("name","/remoteService"); rBean.setAttribute("class","org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"); Element prop = new Element("property"); prop.setAttribute("name","service"); Element ref = new Element("ref"); ref.setAttribute("bean","remoteService"); prop.addContent(ref); rBean.addContent(prop); Element prop2 = new Element("property"); prop2.setAttribute("name","serviceInterface"); Element val = new Element("value"); String className = "Remote"+CodeGenUtils.getPartialName(applicationService); val.setText(basePackage+"application.common."+className); prop2.addContent(val); rBean.addContent(prop2); root.addContent(rBean); this.outputDocumentToFile(doc,sourceFolder+"/"+"httpinvoker-servlet.xml"); }
public void generate_applicationService_xml_config(){ Element root = new Element("beans"); Document doc = new Document(root); DocType dt = new DocType("beans","-//SPRING//DTD BEAN//EN","http://www.springframework.org/dtd/spring-beans.dtd"); doc.setDocType(dt); Element bns = new Element("bean"); bns.setAttribute("id","applicationService"); String className = CodeGenUtils.getPartialName(applicationService)+"Impl"; bns.setAttribute("class",applicationServiceImplentationClassName); root.addContent(bns); File f = CodeGenUtils.createAndGetSourceFileFolder(sourceFolder,"classes"); String classesFolder = f.getAbsolutePath(); this.outputDocumentToFile(doc,classesFolder+"/"+"applicationService.xml"); }
public void generate_client_config_file(){ Element root = new Element("beans"); Document doc = new Document(root); DocType dt = new DocType("beans","-//SPRING//DTD BEAN//EN","http://www.springframework.org/dtd/spring-beans.dtd"); doc.setDocType(dt); Element bean = new Element("bean"); bean.setAttribute("id","remoteService"); bean.setAttribute("class","org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"); root.addContent(bean); Element prop = new Element("property"); prop.setAttribute("name","serviceUrl"); Element val = new Element("value"); //val.setText("http://localhost:8080/SpringHttp12/http/remoteService"); val.setText("{Host}"+ "/"+webContextRoot+"/http/remoteService"); prop.addContent(val); bean.addContent(prop); Element prop2 = new Element("property"); prop2.setAttribute("name","serviceInterface"); Element val2 = new Element("value"); //val2.setText("com.prototype.application.remote.RemoteService"); val2.setText(basePackage+"application.common.Remote"+CodeGenUtils.getPartialName(applicationService)); prop2.addContent(val2); bean.addContent(prop2); this.outputDocumentToFile(doc,clientFolder+"/"+"remoteService.xml"); }
private String getNamespace(FileWrapper file) throws JDOMException, IOException { Element root = JDOMUtil.loadDocument(file.getStream()).getRootElement(); String namespace = root.getNamespaceURI(); if(StringUtil.isEmpty(namespace)) { DocType type = root.getDocument().getDocType(); namespace = (type != null) ? type.getSystemID() : ""; } return namespace; }
private void generate_web_xml_config(){ Element root = new Element("web-app"); Document webDoc = new Document(root); DocType dt = new DocType("web-app","-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN","http://java.sun.com/dtd/web-app_2_3.dtd"); webDoc.setDocType(dt); Element context_param = new Element("context-param"); Element param_name = new Element("param-name"); param_name.setText("contextConfigLocation"); context_param.addContent(param_name); Element param_value = new Element("param-value"); param_value.setText("/WEB-INF/applicationContext.xml"); context_param.addContent(param_value); root.addContent(context_param); Element s1 = new Element("servlet"); Element s1_name = new Element("servlet-name"); s1_name.setText("context"); Element s1_class = new Element("servlet-class"); s1_class.setText("org.springframework.web.context.ContextLoaderServlet"); Element l_stp1 = new Element("load-on-startup"); l_stp1.setText("1"); s1.addContent(s1_name); s1.addContent(s1_class); s1.addContent(l_stp1); root.addContent(s1); Element s2 = new Element("servlet"); Element s2_name = new Element("servlet-name"); s2_name.setText("httpinvoker"); Element s2_class = new Element("servlet-class"); s2_class.setText("org.springframework.web.servlet.DispatcherServlet"); Element l_stp2 = new Element("load-on-startup"); l_stp2.setText("3"); s2.addContent(s2_name); s2.addContent(s2_class); s2.addContent(l_stp2); root.addContent(s2); Element sMap = new Element("servlet-mapping"); Element s_name = new Element("servlet-name"); s_name.setText("httpinvoker"); Element url_pat = new Element("url-pattern"); url_pat.setText("/http/*"); sMap.addContent(s_name); sMap.addContent(url_pat); root.addContent(sMap); this.outputDocumentToFile(webDoc,sourceFolder+"/"+"web.xml"); }
/** * Creates an XML string from a query * * @param query * @return an XML string */ public static String queryToXML(Query query) { Document document = new Document(QueryXMLHandler.queryToElement(query, Namespace.NO_NAMESPACE), new DocType("Query")); return new XMLOutputter().outputString(document); }