protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) { XmlOptions xo = new XmlOptions(); xo.setCharacterEncoding("UTF-8"); Map<String,String> nsMap = new HashMap<>(); nsMap.put(passwordUri.toString(),"p"); nsMap.put(certificateUri.toString(), "c"); xo.setUseDefaultNamespace(); xo.setSaveSuggestedPrefixes(nsMap); xo.setSaveNamespacesFirst(); xo.setSaveAggressiveNamespaces(); // setting standalone doesn't work with xmlbeans-2.3 & 2.6 // ed.documentProperties().setStandalone(true); xo.setSaveNoXmlDecl(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n".getBytes("UTF-8")); ed.save(bos, xo); bos.writeTo(os); } catch (IOException e) { throw new EncryptedDocumentException("error marshalling encryption info document", e); } }
public void setUseDefaultNamespace(boolean b) { if (b) super.setUseDefaultNamespace(); else remove( SAVE_USE_DEFAULT_NAMESPACE ); }
public void setUseDefaultNamespace(boolean b) { if (b) super.setUseDefaultNamespace(); else remove( SAVE_USE_DEFAULT_NAMESPACE ); }
public void setUseDefaultNamespace(boolean b) { if (b) super.setUseDefaultNamespace(); else remove( SAVE_USE_DEFAULT_NAMESPACE ); }
private XmlOptions createXmlOptions(Collection errors) { Map NAMESPACE_UPDATES = new HashMap(); NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/directory", "http://geronimo.apache.org/xml/ns/directory-1.0"); XmlOptions options = new XmlOptions(); options.setLoadLineNumbers(); options.setErrorListener(errors); options.setLoadSubstituteNamespaces(NAMESPACE_UPDATES); options.setUseDefaultNamespace(); return options; }
public String toXml() { EventMessageDocument msgDoc = this.toEventMessageDocument(); return msgDoc.xmlText((new XmlOptions()).setUseDefaultNamespace()); }
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(); }
private static POILogger logger = POILogFactory.getLogger(POIXMLDocumentPart.class); public static final XmlOptions DEFAULT_XML_OPTIONS; static { DEFAULT_XML_OPTIONS = new XmlOptions(); DEFAULT_XML_OPTIONS.setSaveOuter(); DEFAULT_XML_OPTIONS.setUseDefaultNamespace(); DEFAULT_XML_OPTIONS.setSaveAggressiveNamespaces(); }
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); }
options.setUseDefaultNamespace(); Map prefixes = new HashMap(); prefixes.put("", "http://www.imsglobal.org/xsd/ims_qtiasiv1p2");
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; }
private void validateDD(XmlObject dd) throws XmlException { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setDocumentType(DirDirectoryConfigurationDocument.type); xmlOptions.setLoadLineNumbers(); xmlOptions.setUseDefaultNamespace(); Collection errors = new ArrayList(); xmlOptions.setErrorListener(errors); if (!dd.validate(xmlOptions)) { throw new XmlException("Invalid directory descriptor: " + errors + "\nDescriptor: " + dd.toString(), null, errors); } // System.out.println("descriptor: " + dd.toString()); } }
public void toXML(OutputStream outputStream) throws IOException { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(4); options.setUseDefaultNamespace(); xmlObject.save(outputStream, options); }
protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) { XmlOptions xo = new XmlOptions(); xo.setCharacterEncoding("UTF-8"); Map<String,String> nsMap = new HashMap<>(); nsMap.put(passwordUri.toString(),"p"); nsMap.put(certificateUri.toString(), "c"); xo.setUseDefaultNamespace(); xo.setSaveSuggestedPrefixes(nsMap); xo.setSaveNamespacesFirst(); xo.setSaveAggressiveNamespaces(); // setting standalone doesn't work with xmlbeans-2.3 & 2.6 // ed.documentProperties().setStandalone(true); xo.setSaveNoXmlDecl(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n".getBytes("UTF-8")); ed.save(bos, xo); bos.writeTo(os); } catch (IOException e) { throw new EncryptedDocumentException("error marshalling encryption info document", e); } }
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; }
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; }
XmlOptions xmlSaveOptions = new XmlOptions().setUseDefaultNamespace().setSavePrettyPrint() .setSaveAggressiveNamespaces();
public static InputStream createInputStream(XmlObject xmlObject, boolean writeXMLDeclaration) throws GenericException, ValidationException { // Create an XmlOptions instance and set the error listener. XmlOptions validateOptions = new XmlOptions(); List<XmlValidationError> errorList = new ArrayList<>(); validateOptions.setErrorListener(errorList); // Validate the XML. boolean isValid = xmlObject.validate(validateOptions); if (isValid) { XmlOptions xmlSaveOptions = new XmlOptions().setUseDefaultNamespace().setSavePrettyPrint() .setSaveAggressiveNamespaces(); if (!writeXMLDeclaration) { xmlSaveOptions = xmlSaveOptions.setSaveNoXmlDecl(); } return xmlObject.newInputStream(xmlSaveOptions); } else { throw new ValidationException(xmlValidationErrorsToValidationReport(errorList)); } }