Search in sources :

Example 31 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class XSSFPivotCacheRecords method commit.

@Beta
@Override
protected void commit() throws IOException {
    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    //Sets the pivotCacheDefinition tag
    xmlOptions.setSaveSyntheticDocumentElement(new QName(CTPivotCacheRecords.type.getName().getNamespaceURI(), "pivotCacheRecords"));
    ctPivotCacheRecords.save(out, xmlOptions);
    out.close();
}
Also used : QName(javax.xml.namespace.QName) OutputStream(java.io.OutputStream) XmlOptions(org.apache.xmlbeans.XmlOptions) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) Beta(org.apache.poi.util.Beta)

Example 32 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class XSSFPivotTable method readFrom.

@Beta
public void readFrom(InputStream is) throws IOException {
    try {
        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
        //Removing root element
        options.setLoadReplaceDocumentElement(null);
        pivotTableDefinition = CTPivotTableDefinition.Factory.parse(is, options);
    } catch (XmlException e) {
        throw new IOException(e.getLocalizedMessage());
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) IOException(java.io.IOException) Beta(org.apache.poi.util.Beta)

Example 33 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class XSLFSheet method commit.

protected final void commit() throws IOException {
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    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();
}
Also used : QName(javax.xml.namespace.QName) XmlOptions(org.apache.xmlbeans.XmlOptions) OutputStream(java.io.OutputStream) PackagePart(org.apache.poi.openxml4j.opc.PackagePart)

Example 34 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project knime-core by knime.

the class NodeDescription13Proxy method validate.

/**
 * Validate against the XML Schema. If violations are found they are reported via the logger as coding problems.
 *
 * @return <code>true</code> if the document is valid, <code>false</code> otherwise
 */
final boolean validate() {
    // this method has default visibility so that we can use it in testcases
    XmlOptions options = new XmlOptions(OPTIONS);
    List<XmlError> errors = new ArrayList<XmlError>();
    options.setErrorListener(errors);
    boolean valid = m_document.validate(options);
    if (!valid) {
        logger.coding("Node description of '" + m_document.getKnimeNode().getName() + "' does not conform to the Schema. Violations follow.");
        for (XmlError err : errors) {
            logger.coding(err.toString());
        }
    }
    return valid;
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) ArrayList(java.util.ArrayList) XmlError(org.apache.xmlbeans.XmlError)

Example 35 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project knime-core by knime.

the class NodeDescription28Proxy method validate.

/**
 * Validate against the XML Schema. If violations are found they are reported via the logger as coding problems.
 *
 * @return <code>true</code> if the document is valid, <code>false</code> otherwise
 */
protected final boolean validate() {
    // this method has default visibility so that we can use it in testcases
    XmlOptions options = new XmlOptions(OPTIONS);
    List<XmlError> errors = new ArrayList<XmlError>();
    options.setErrorListener(errors);
    boolean valid = m_document.validate(options);
    if (!valid) {
        logger.coding("Node description of '" + m_document.getKnimeNode().getName() + "' does not conform to the Schema. Violations follow.");
        for (XmlError err : errors) {
            logger.coding(err.toString());
        }
    }
    return valid;
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) ArrayList(java.util.ArrayList) XmlError(org.apache.xmlbeans.XmlError)

Aggregations

XmlOptions (org.apache.xmlbeans.XmlOptions)36 OutputStream (java.io.OutputStream)18 QName (javax.xml.namespace.QName)18 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)17 XmlException (org.apache.xmlbeans.XmlException)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Beta (org.apache.poi.util.Beta)7 XmlError (org.apache.xmlbeans.XmlError)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 HashMap (java.util.HashMap)2 MarshalException (javax.xml.crypto.MarshalException)2 EncryptedDocumentException (org.apache.poi.EncryptedDocumentException)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 XmlObject (org.apache.xmlbeans.XmlObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 GeneralSecurityException (java.security.GeneralSecurityException)1