use of org.apache.xmlbeans.XmlOptions in project poi by apache.
the class AgileEncryptor method marshallEncryptionDocument.
protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) {
XmlOptions xo = new XmlOptions();
xo.setCharacterEncoding("UTF-8");
Map<String, String> nsMap = new HashMap<String, String>();
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);
}
}
use of org.apache.xmlbeans.XmlOptions in project poi by apache.
the class XWPFSettings method commit.
@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"));
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
ctSettings.save(out, xmlOptions);
out.close();
}
use of org.apache.xmlbeans.XmlOptions in project poi by apache.
the class XWPFFootnotes method commit.
@Override
protected void commit() throws IOException {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes"));
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
ctFootnotes.save(out, xmlOptions);
out.close();
}
use of org.apache.xmlbeans.XmlOptions in project poi by apache.
the class XSSFChart method commit.
@Override
protected void commit() throws IOException {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
/*
Saved chart space must have the following namespaces set:
<c:chartSpace
xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
*/
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
chartSpace.save(out, xmlOptions);
out.close();
}
use of org.apache.xmlbeans.XmlOptions in project poi by apache.
the class SharedStringsTable method writeTo.
/**
* Write this table out as XML.
*
* @param out The stream to write to.
* @throws IOException if an error occurs while writing.
*/
public void writeTo(OutputStream out) throws IOException {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
// the following two lines turn off writing CDATA
// see Bugzilla 48936
xmlOptions.setSaveCDataLengthThreshold(1000000);
xmlOptions.setSaveCDataEntityCountThreshold(-1);
//re-create the sst table every time saving a workbook
CTSst sst = _sstDoc.getSst();
sst.setCount(count);
sst.setUniqueCount(uniqueCount);
_sstDoc.save(out, xmlOptions);
}
Aggregations