public Importable translate(Node resourceNode, Document descriptor, String contextPath, String archiveBasePath) { String content = XPathHelper.getNodeValue("/CONTENT/BODY/TEXT", descriptor); String title = XPathHelper.getNodeValue("/CONTENT/TITLE/@value", descriptor).replaceAll("/", "_"); int priority = Integer.parseInt(((Element)resourceNode).getAttribute("priority")); // HTML docs in the archive have the < character replaced with the equivalent HTML entity // Without this, the TEXT node contents would be treated as sub-nodes. content.replaceAll("<", "<"); contextPath = contextPath + title; //Validator.escapeResourceName(title); HtmlDocument html = new HtmlDocument(); html.setContent(content); html.setTitle(title); html.setContextPath(contextPath); html.setSequenceNum(priority); return html; }
public Importable translate(Node resourceNode, Document descriptor, String contextPath, String archiveBasePath) { if (resourceNode.hasChildNodes() && (resourceNode.getChildNodes().getLength() > 1)) { // this is a compound document, and it's already being handled by the Blackboard55FileParser return null; } if (XPathHelper.selectNodes("//STARTASSESSMENT", descriptor).size() > 0) { // this signifies a document that serves as a link to an assessment // these links aren't meaningful in the Sakai context return null; } String content = XPathHelper.getNodeValue("//TEXT", descriptor); String title = XPathHelper.getNodeValue("/CONTENT/TITLE", descriptor); int priority = Integer.parseInt(((Element)resourceNode).getAttribute("priority")); // HTML docs in the archive have the < character replaced with the equivalent HTML entity // Without this, the TEXT node contents would be treated as sub-nodes. content.replaceAll("<", "<"); contextPath = contextPath + title.replaceAll("/", "_"); //Validator.escapeResourceName(title); HtmlDocument html = new HtmlDocument(); html.setContent(content); html.setTitle(title); html.setContextPath(contextPath); html.setSequenceNum(priority); return html; }
rv.setContent(page.toString().replaceAll("<", "<")); rv.setTitle(title); rv.setContextPath(contextPath); rv.setSequenceNum(priority); return rv;
protected Importable getCompanionForCompoundDocument(Document resourceDescriptor, Folder folder) { HtmlDocument html = new HtmlDocument(); StringBuffer content = new StringBuffer(); List<Node> fileNodes = XPathHelper.selectNodes("/CONTENT/FILES/FILE", resourceDescriptor); content.append("<html>\n"); content.append(" <head><title>" + folder.getTitle() + "</title></head>\n"); content.append(" <body>\n"); content.append(" <p>" + XPathHelper.getNodeValue("/CONTENT/BODY/TEXT", resourceDescriptor) + "</p>\n"); content.append(" <table border=\"1\">\n"); for (Node fileNode : fileNodes) { String fileName = XPathHelper.getNodeValue("./NAME", fileNode); content.append(" <tr><td><a href=\""+ folder.getTitle() + "/" + fileName + "\">" + fileName + "</a></td></tr>\n"); } content.append(" </table>\n"); content.append(" </body>\n"); content.append("</html>"); html.setContent(content.toString()); html.setTitle(folder.getTitle()); html.setContextPath(folder.getPath() + folder.getTitle() + "_manifest"); html.setLegacyGroup(folder.getLegacyGroup()); // we want the html document to come before the folder in sequence html.setSequenceNum(folder.getSequenceNum() - 1); return html; }
html.setContent(content.toString()); html.setTitle(folder.getTitle()); html.setContextPath(folder.getPath() + folder.getTitle() + "_manifest"); html.setLegacyGroup(folder.getLegacyGroup());