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); } }
namespaceMap.put(entry.getValue(), entry.getKey()); xo.setSaveSuggestedPrefixes(namespaceMap); xo.setUseDefaultNamespace();
private XmlOptions commit(XWPFHeaderFooter wrapper) { XmlOptions xmlOptions = new XmlOptions(wrapper.DEFAULT_XML_OPTIONS); Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("urn:schemas-microsoft-com:vml", "v"); map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); map.put("urn:schemas-microsoft-com:office:word", "w10"); map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne"); map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp"); xmlOptions.setSaveSuggestedPrefixes(map); return xmlOptions; }
@Override protected void write(OutputStream out) throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); chartsheet.save(out, 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);
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); _presentation.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); Map<String,String> map = new HashMap<String,String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctFootnotes.save(out, xmlOptions); out.close(); }
protected final void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a"); xmlOptions.setSaveSuggestedPrefixes(map); xmlOptions.setSaveSyntheticDocumentElement( new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "theme")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); getXmlObject().save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { if (ctSettings == null) { throw new IllegalStateException("Unable to write out settings that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings")); Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctSettings.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { if (ctStyles == null) { throw new IllegalStateException("Unable to write out styles that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles")); Map<String,String> map = new HashMap<String,String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctStyles.save(out, xmlOptions); out.close(); }
protected void init(Map<SystemValue, Object> values) throws XMLBindingException{ // Set up xml defaults xopt = new XmlOptions(); HashMap<String, String> uriToPrefixMap = new HashMap<String, String>(); uriToPrefixMap.put(SCHEMA_XSI, "xsi"); uriToPrefixMap.put(SCHEMA_OPENEHR_ORG_V1, "v1"); xopt.setSaveSuggestedPrefixes(uriToPrefixMap); xopt.setSaveAggressiveNamespaces(); xopt.setSavePrettyPrint(); xopt.setCharacterEncoding("UTF-8"); try { builder = new RMObjectBuilder(values); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("failed to start XMLBinding..."); } }
private String toString(XSSFSheet sheet) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet")); Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); try { sheet.getCTWorksheet().save(bout, xmlOptions); } catch (IOException e) { throw new ReportException(e); } return new String(bout.toByteArray(), StandardCharsets.UTF_8); }
protected void init(Map<SystemValue, Object> values) throws XMLBindingException{ // Set up xml defaults xopt = new XmlOptions(); HashMap<String, String> uriToPrefixMap = new HashMap<String, String>(); uriToPrefixMap.put(SCHEMA_XSI, "xsi"); uriToPrefixMap.put(SCHEMA_OPENEHR_ORG_V1, "v1"); xopt.setSaveSuggestedPrefixes(uriToPrefixMap); xopt.setSaveAggressiveNamespaces(); xopt.setSavePrettyPrint(); xopt.setCharacterEncoding("UTF-8"); try { builder = new RMObjectBuilder(values); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("failed to start XMLBinding..."); } }
protected final void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a"); map.put("http://schemas.openxmlformats.org/presentationml/2006/main", "p"); xmlOptions.setSaveSuggestedPrefixes(map); String docName = getRootElementName(); if(docName != null) { xmlOptions.setSaveSyntheticDocumentElement( new QName("http://schemas.openxmlformats.org/presentationml/2006/main", docName)); } PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); getXmlObject().save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { saveNamedRanges(); saveCalculationChain(); XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook")); Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); workbook.save(out, xmlOptions); out.close(); }
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; }
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); } }
/** * @return the default XmlOptions used in responses */ public static XmlOptions getXmlOptions() { return new XmlOptions() .setSaveNamespacesFirst() .setSaveSuggestedPrefixes(PREFIXES) .setSaveAggressiveNamespaces() .setSavePrettyPrint(); }
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; }
protected XmlOptions getDefaultXMLOptions() { XmlOptions bindingXmlOptions = new XmlOptions(XmlOptionsHelper.getInstance().getXmlOptions()); @SuppressWarnings("unchecked") Map<String,String> prefixes = (Map<String,String>) bindingXmlOptions.get(XmlOptions.SAVE_SUGGESTED_PREFIXES); prefixes.put(bindingConstants.getEncodingNamespace(), bindingConstants.getEncodingPrefix()); bindingXmlOptions.setSaveSuggestedPrefixes(prefixes); bindingXmlOptions.setSaveImplicitNamespaces(prefixes); return bindingXmlOptions; }