Search in sources :

Example 36 with IMSEntityResolver

use of org.olat.ims.resources.IMSEntityResolver in project openolat by klemens.

the class QTIExportProcessor method readItemXml.

private Element readItemXml(VFSLeaf leaf) {
    Document doc = null;
    try {
        InputStream is = leaf.getInputStream();
        XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
        doc = xmlParser.parse(is, false);
        Element item = (Element) doc.selectSingleNode("questestinterop/item");
        is.close();
        return item;
    } catch (Exception e) {
        log.error("", e);
        return null;
    }
}
Also used : InputStream(java.io.InputStream) Element(org.dom4j.Element) Document(org.dom4j.Document) XMLParser(org.olat.core.util.xml.XMLParser) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver) IOException(java.io.IOException)

Example 37 with IMSEntityResolver

use of org.olat.ims.resources.IMSEntityResolver 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 38 with IMSEntityResolver

use of org.olat.ims.resources.IMSEntityResolver 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

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