List of usage examples for org.dom4j.io XMLWriter setEscapeText
public void setEscapeText(boolean escapeText)
From source file:org.apache.commons.jelly.XMLOutput.java
License:Apache License
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying Writer. * * @param writer is the writer to output to * @param escapeText is whether or not text output will be escaped. This must be true * if the underlying output is XML or could be false if the underlying output is textual. *//*from w ww . j a v a2 s. c o m*/ public static XMLOutput createXMLOutput(Writer writer, boolean escapeText) { XMLWriter xmlWriter = new XMLWriter(writer); xmlWriter.setEscapeText(escapeText); return createXMLOutput(xmlWriter); }
From source file:org.apache.commons.jelly.XMLOutput.java
License:Apache License
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying OutputStream. * * @param out is the output stream to write * @param escapeText is whether or not text output will be escaped. This must be true * if the underlying output is XML or could be false if the underlying output is textual. *///ww w . j a v a 2 s. c o m public static XMLOutput createXMLOutput(OutputStream out, boolean escapeText) throws UnsupportedEncodingException { XMLWriter xmlWriter = new XMLWriter(out); xmlWriter.setEscapeText(escapeText); return createXMLOutput(xmlWriter); }
From source file:org.dentaku.gentaku.tools.cgen.visitor.JellyTemplateGeneratingVisitor.java
License:Apache License
public void handleElement(Element element) throws VisitorException { if (element.getParent().getName().equals("schema")) { QName rootName = DocumentFactory.getInstance().createQName("jelly", "j", "jelly:core"); Branch parent = DocumentHelper.createDocument().addElement(rootName).addNamespace("x", "jelly:xml"); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(getEncoding()); format.setSuppressDeclaration(false); format.setExpandEmptyElements(false); pushParent(parent.addElement(element.getName())); for (Iterator it = element.elementIterator(); it.hasNext();) { visit((Element) it.next()); }// w ww .j a va 2s.c o m popParent(); try { String filename = element.getName() + ".jelly"; Writer out = new FileWriter(new File(getRootDir(), filename)); final XMLWriter xmlWriter = new XMLWriter(out, format); xmlWriter.setEscapeText(false); xmlWriter.write(parent); xmlWriter.flush(); xmlWriter.close(); } catch (Exception e) { throw new VisitorException("Exception occurred when running Jelly", e); } topLevelElements.put(element.getName(), element); } else { String refName = element.attributeValue("ref"); if (refName != null) { Branch parent = getCurrentParent(); // create an include QName qName = DocumentFactory.getInstance().createQName("import", "j", "jelly:core"); parent.addElement(qName).addAttribute("uri", refName + ".jelly").addAttribute("inherit", "true"); } } }
From source file:org.dentaku.gentaku.tools.cgen.xmi.XMIGenTask.java
License:Apache License
private void writeFile(Branch document, File file) throws IOException { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(System.getProperty("file.encoding")); format.setSuppressDeclaration(false); format.setExpandEmptyElements(false); Writer out = new FileWriter(file); final XMLWriter xmlWriter = new XMLWriter(out, format); xmlWriter.setEscapeText(false); xmlWriter.write(document);/*from w w w.j a v a2s . c om*/ xmlWriter.flush(); xmlWriter.close(); }
From source file:org.foxbpm.engine.test.AbstractFoxBpmTestCase.java
License:Apache License
@Before public void annotationDeploymentSetUp() throws Exception { Method method = null;// www . j av a2s . co m try { method = this.getClass().getDeclaredMethod(name.getMethodName(), (Class<?>[]) null); } catch (Exception e) { throw new FoxBPMException("?!", e); } if (method.isAnnotationPresent(Clear.class)) { Clear clearAnnotation = method.getAnnotation(Clear.class); String[] tableNames = clearAnnotation.tables(); for (String tableName : tableNames) { jdbcTemplate.execute("delete from " + tableName); } } Deployment deploymentAnnotation = method.getAnnotation(Deployment.class); if (deploymentAnnotation != null) { String[] resources = deploymentAnnotation.resources(); if (resources.length == 0) { return; } DeploymentBuilder deploymentBuilder = null;// processEngine.getModelService().createDeployment().name("??"); // ????? BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter(); BpmnModel bpmnModel = null; SAXReader reader = new SAXReader(); ByteArrayOutputStream out = null; OutputFormat format = null; for (String resource : resources) { bpmnModel = bpmnXMLConverter .convertToBpmnModel(reader.read(ReflectUtil.getResourceAsStream(resource))); deploymentBuilder = processEngine.getModelService().createDeployment().name("??"); // deploymentBuilder.addClasspathResource(resource); try { out = new ByteArrayOutputStream(); // ? format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8"); XMLWriter xmlWriter = new XMLWriter(out, format); xmlWriter.setEscapeText(false); xmlWriter.write(bpmnXMLConverter.convertToXML(bpmnModel)); xmlWriter.close(); System.out.println(resource + "---------------" + out.toString()); deploymentBuilder.addInputStream(resource, new ByteArrayInputStream(out.toByteArray())); deploymentBuilder.deploy(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:org.foxbpm.rest.service.api.config.ConnectorGenerator.java
License:Apache License
private void generatorConnector(String prefix, InputStream stream, ZipOutputStream out) throws Exception { SAXReader reader = null;/*from w w w . jav a2 s . c om*/ reader = new SAXReader(); Document doc = reader.read(stream); ZipEntry zipEntry = new ZipEntry(prefix + "/ConnectorMenu.xml"); zipEntry.setMethod(ZipEntry.DEFLATED);// ?? out.putNextEntry(zipEntry); XMLWriter xmlWriter = new XMLWriter(out); xmlWriter.setEscapeText(false); xmlWriter.write(doc); out.closeEntry(); Element flowConnectorElement = doc.getRootElement().element("flowConnector"); if (flowConnectorElement != null) { parseNode(flowConnectorElement, out, "flowConnector", prefix + "/flowConnector"); } Element actorConnectorElement = doc.getRootElement().element("actorConnector"); if (actorConnectorElement != null) { parseNode(actorConnectorElement, out, "actorConnector", prefix + "/actorConnector"); } }
From source file:org.opencms.util.ant.CmsXmlUtils.java
License:Open Source License
/** * Marshals (writes) an XML document into an output stream using XML pretty-print formatting.<p> * /*from w w w . j av a2 s. c o m*/ * @param document the XML document to marshal * @param out the output stream to write to * @param encoding the encoding to use * @return the output stream with the xml content * @throws Exception if something goes wrong */ public static OutputStream marshal(Document document, OutputStream out, String encoding) throws Exception { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.setEscapeText(false); writer.write(document); writer.close(); return out; }
From source file:org.opencms.util.ant.CmsXmlUtils.java
License:Open Source License
/** * Marshals (writes) an XML node into an output stream using XML pretty-print formatting.<p> * //from www.j a va 2 s . co m * @param node the XML node to marshal * @param encoding the encoding to use * * @return the string with the xml content * * @throws Exception if something goes wrong */ public static String marshal(Node node, String encoding) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); format.setSuppressDeclaration(true); XMLWriter writer = new XMLWriter(out, format); writer.setEscapeText(false); writer.write(node); writer.close(); return new String(out.toByteArray()); }
From source file:org.opencms.xml.CmsXmlUtils.java
License:Open Source License
/** * Marshals (writes) an XML document into an output stream using XML pretty-print formatting.<p> * //from ww w . jav a 2 s.c o m * @param document the XML document to marshal * @param out the output stream to write to * @param encoding the encoding to use * @return the output stream with the xml content * @throws CmsXmlException if something goes wrong */ public static OutputStream marshal(Document document, OutputStream out, String encoding) throws CmsXmlException { try { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.setEscapeText(false); writer.write(document); writer.close(); } catch (Exception e) { throw new CmsXmlException(Messages.get().container(Messages.ERR_MARSHALLING_XML_DOC_0), e); } return out; }
From source file:org.opencms.xml.CmsXmlUtils.java
License:Open Source License
/** * Marshals (writes) an XML node into an output stream using XML pretty-print formatting.<p> * //www . j a v a 2 s . c o m * @param node the XML node to marshal * @param encoding the encoding to use * * @return the string with the xml content * * @throws CmsXmlException if something goes wrong */ public static String marshal(Node node, String encoding) throws CmsXmlException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); format.setSuppressDeclaration(true); XMLWriter writer = new XMLWriter(out, format); writer.setEscapeText(false); writer.write(node); writer.close(); } catch (Exception e) { throw new CmsXmlException(Messages.get().container(Messages.ERR_MARSHALLING_XML_DOC_0), e); } return new String(out.toByteArray()); }