use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Document in project muikku by otavanopisto.
the class DeusNexStructureParser method parseFCKDocument.
private Document parseFCKDocument(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
Element documentElement = (Element) DeusNexXmlUtils.findNodeByXPath(resourceElement, "document");
if (documentElement == null) {
logger.severe("Missing data/document node");
return null;
}
List<Resource> embeddedElements = new ArrayList<>();
List<Element> embeddedResourceElements = DeusNexXmlUtils.getElementsByXPath(resourceElement, "embedded/res");
for (Element embeddedResourceElement : embeddedResourceElements) {
Resource resource = parseResource(embeddedResourceElement);
if (resource != null) {
embeddedElements.add(resource);
}
}
Document document = new Document();
parseBasicResourceProperties(resourceElement, document);
document.setDocument(documentElement);
document.setResources(embeddedElements);
return document;
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Document in project muikku by otavanopisto.
the class DeusNexStructureParser method parseLink.
private Resource parseLink(Element resourceElement) throws DeusNexInternalException {
// TODO: Add support for proper link materials
Document document = new Document();
Element linkElement = resourceElement.getOwnerDocument().createElement("a");
try {
linkElement.setAttribute("href", DeusNexXmlUtils.getChildValue(resourceElement, "path"));
linkElement.setTextContent(DeusNexXmlUtils.getChildValue(resourceElement, "title"));
parseBasicResourceProperties(resourceElement, document);
Element documentElement = resourceElement.getOwnerDocument().createElement("document");
Element fckDocumentElement = resourceElement.getOwnerDocument().createElement("fckdocument");
fckDocumentElement.setAttribute("lang", "fi");
fckDocumentElement.appendChild(linkElement);
documentElement.appendChild(fckDocumentElement);
document.setDocument(documentElement);
} catch (DOMException | XPathExpressionException | DeusNexSyntaxException e) {
throw new DeusNexInternalException("Link parsing failed", e);
}
return document;
}
use of fi.otavanopisto.muikku.plugins.dnm.parser.structure.model.Document in project muikku by otavanopisto.
the class DeusNexStructureParser method parseStyleDocument.
private Document parseStyleDocument(Element resourceElement) throws DeusNexSyntaxException, XPathExpressionException, DeusNexInternalException {
Element documentElement = (Element) DeusNexXmlUtils.findNodeByXPath(resourceElement, "document/styledocument");
if (documentElement == null) {
logger.severe("Missing data/document node");
return null;
}
List<Resource> embeddedElements = new ArrayList<>();
List<Element> embeddedResourceElements = DeusNexXmlUtils.getElementsByXPath(resourceElement, "embedded/res");
for (Element embeddedResourceElement : embeddedResourceElements) {
Resource resource = parseResource(embeddedResourceElement);
if (resource != null) {
embeddedElements.add(resource);
}
}
Document document = new Document();
parseBasicResourceProperties(resourceElement, document);
document.setDocument(documentElement);
document.setResources(embeddedElements);
return document;
}
Aggregations