Search in sources :

Example 41 with XMLParser

use of org.olat.core.util.xml.XMLParser in project openolat by klemens.

the class CPManifestTreeModel method loadDocument.

private Document loadDocument(String documentStr) throws IOException {
    InputStream in = null;
    Document doc = null;
    try {
        in = new ByteArrayInputStream(documentStr.getBytes());
        XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
        doc = xmlParser.parse(in, false);
        in.close();
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException("could not read and parse from string " + documentStr, e);
    } finally {
        IOUtils.closeQuietly(in);
    }
    return doc;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Document(org.dom4j.Document) XMLParser(org.olat.core.util.xml.XMLParser) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver) AssertException(org.olat.core.logging.AssertException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 42 with XMLParser

use of org.olat.core.util.xml.XMLParser in project openolat by klemens.

the class CPManifestTreeModel method loadDocument.

private Document loadDocument(VFSLeaf documentF) throws IOException {
    InputStream in = null;
    Document doc = null;
    try {
        in = documentF.getInputStream();
        XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
        doc = xmlParser.parse(in, false);
        in.close();
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException("could not read and parse from file " + documentF, e);
    } finally {
        IOUtils.closeQuietly(in);
    }
    return doc;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Document(org.dom4j.Document) XMLParser(org.olat.core.util.xml.XMLParser) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver) AssertException(org.olat.core.logging.AssertException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

XMLParser (org.olat.core.util.xml.XMLParser)42 Document (org.dom4j.Document)40 InputStream (java.io.InputStream)32 IMSEntityResolver (org.olat.ims.resources.IMSEntityResolver)30 IOException (java.io.IOException)26 FileInputStream (java.io.FileInputStream)16 BufferedInputStream (java.io.BufferedInputStream)14 File (java.io.File)14 Element (org.dom4j.Element)10 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)10 VFSItem (org.olat.core.util.vfs.VFSItem)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)10 URL (java.net.URL)8 Node (org.dom4j.Node)8 Test (org.junit.Test)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 QuestionItem (org.olat.modules.qpool.QuestionItem)8 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6