public static String indent(String xmldoc) throws IOException, XmlException { StringWriter sw = new StringWriter(); XmlObject doc = XmlObject.Factory.parse(xmldoc, (new XmlOptions()).setLoadLineNumbers()); doc.save(sw, new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(DEFAULT_INDENT)); sw.close(); return sw.getBuffer().toString(); } }
doc.save(System.out, new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(indent));
/** * Returns default output options for outputting XmlObjects from XBeans. * * @return */ public static XmlOptions getDefaultXMLOptions() { XmlOptions opts= new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(INDENTION_SIZE); return opts; }
protected XmlOptions getXmlOptions() { if (xmlOptions == null) { xmlOptions = new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2); } return xmlOptions; }
XmlOptions.setSaveSuggestedPrefixes() XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveAggressiveNamespaces(); HashMap<String, String> nsMap = new HashMap<String, String>(); nsMap.put("namespace1","A"); nsMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi"); xmlOptions.setSaveSuggestedPrefixes(nsMap); // Create your XmlObject <Your XmlObject>.save(new File("test.xml"),xmlOptions);
@ApiModelProperty(hidden=true) public XmlOptions getXmlSaveOptions() { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSaveAggressiveNamespaces(); options.setSavePrettyPrintIndent(2); return options; }
public static String indent(String xmldoc) throws IOException, XmlException { StringWriter sw = new StringWriter(); XmlObject doc = XmlObject.Factory.parse(xmldoc, (new XmlOptions()).setLoadLineNumbers()); doc.save(sw, new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(DEFAULT_INDENT)); sw.close(); return sw.getBuffer().toString(); } }
public static String indent(String xmldoc) throws IOException, XmlException { StringWriter sw = new StringWriter(); XmlObject doc = XmlObject.Factory.parse(xmldoc, (new XmlOptions()).setLoadLineNumbers()); doc.save(sw, new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(DEFAULT_INDENT)); sw.close(); return sw.getBuffer().toString(); } }
public String toXML() { Assert.notNull(dd); XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); //opts.s opts.setSavePrettyPrintIndent(4); opts.setUseDefaultNamespace(); return dd.xmlText(opts); //return dd.toString(); }
public void save(File file) throws Exception { Assert.notNull(dd); XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); //opts.s opts.setSavePrettyPrintIndent(4); opts.setUseDefaultNamespace(); dd.save(file,opts); }
protected static XmlOptions makeXMLOptions() { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveOuter(); Map<String, String> prefixes = new HashMap<String, String>(); prefixes.put(PLUGINS_NS, "plugins"); xmlOptions.setSaveSuggestedPrefixes(prefixes); xmlOptions.setUseDefaultNamespace(); xmlOptions.setLoadStripWhitespace(); return xmlOptions; }
public void toXML(OutputStream outputStream) throws IOException { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(4); options.setUseDefaultNamespace(); xmlObject.save(outputStream, options); }
public void toXML(OutputStream outputStream) throws IOException { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(4); options.setUseDefaultNamespace(); xmlObject.save(outputStream, options); }
private static XmlOptions makeXMLOptions() { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadStripWhitespace(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveOuter(); xmlOptions.setUseDefaultNamespace(); xmlOptions.setCompileNoValidation(); xmlOptions.setSaveAggressiveNamespaces(); xmlOptions.setCharacterEncoding(ENCODING); Map<String, String> ns = new HashMap<String, String>(); ns.put("http://www.w3.org/1999/xlink", "xlink"); ns.put("http://purl.org/dc/terms/", "dcterms"); ns.put("http://purl.org/dc/elements/1.1/", "dc"); xmlOptions.setSaveSuggestedPrefixes(ns); return xmlOptions; }
/** * Writes a complete trace of a test suite to the output stream in form of an XML document. * * @param out stream to write to * @param suite suite with the data to be written * * @throws IOException */ public static void writeXML(OutputStream out, TestSuite suite) throws IOException { XMLTestResultDocument xmlTestResultDocument= getXMLResults(suite); XmlOptions opts= new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(4); xmlTestResultDocument.save(out, opts); }
public XmlOptions getSaveOptions( boolean prettyPrint ) { XmlOptions opts = new XmlOptions(); opts.setSaveOuter() ; // opts.setSaveImplicitNamespaces( ImplicitNamespaces ) ; opts.setSaveNamespacesFirst() ; opts.setSaveAggressiveNamespaces() ; if( prettyPrint ) { opts.setSavePrettyPrint() ; opts.setSavePrettyPrintIndent( prettyPrintIndent ) ; } return opts ; }
/** * Write the specified WSDL definition to the specified Writer. * * @param model The WSDL definitions component to be written * @param sink The Writer to write the xml to * @exception WsdlException When a problem reading the <code>model</code> * occurs. * @exception IOException When a problem writing to <code>sink</code> * occurs. */ public void writeDescription(Description model, Writer sink) throws WsdlException, IOException { DescriptionImpl defs = (DescriptionImpl) model; if (defs != null && sink != null) { XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(Constants.XML_PRETTY_PRINT_INDENT); defs.getDocBean().save(sink, opts); } return; }
/** * Write the specified WSDL definition to the specified OutputStream. * * @param model The WSDL definitions component to be written * @param sink The OutputStream to write the XML to * @exception WsdlException When a problem reading the <code>model</code> * occurs. * @exception IOException When a problem writing to <code>sink</code> * occurs. */ public void writeDescription(Description model, OutputStream sink) throws WsdlException, IOException { DescriptionImpl defs = (DescriptionImpl) model; if (defs != null && sink != null) { XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(Constants.XML_PRETTY_PRINT_INDENT); defs.getDocBean().save(sink); } return; }
public String createDeploymentPlan() throws IOException { environmentConfig.storeDependencies(); jndiRefsConfig.storeResourceRefs(getWebApp()); if (securityConfig.getSecurity() != null) { getWebApp().setSecurity(securityConfig.getSecurity()); } GerWebAppDocument webAppDocument = GerWebAppDocument.Factory.newInstance(); webAppDocument.setWebApp(getWebApp()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(4); options.setUseDefaultNamespace(); webAppDocument.save(outputStream, options); outputStream.close(); deploymentPlan = new String(outputStream.toByteArray(), "US-ASCII"); return deploymentPlan; }
/** * Returns the <code>XmlOptions</code> required to produce * a text representation of the emitted XML. * If <code>prettyPrint</code> is true, the text will be * indented according to the <code>prettyPrintIndent</code> setting. * * @param prettyPrint * @return XmlOptions */ public XmlOptions getSaveOptions( boolean prettyPrint ) { XmlOptions opts = new XmlOptions(); opts.setSaveOuter() ; // opts.setSaveImplicitNamespaces( ImplicitNamespaces ) ; opts.setSaveNamespacesFirst() ; opts.setSaveAggressiveNamespaces() ; if( prettyPrint ) { opts.setSavePrettyPrint() ; opts.setSavePrettyPrintIndent( prettyPrintIndent ) ; } return opts ; }