}
try {
cleanProjectXml(sourceProjectRoot);
} catch (UnsupportedEncodingException e) {
throw new SimalRepositoryException(
"Unable to encode URIs for blank nodes", e);
}
String uri = sourceProjectRoot.getAttributeNS(RDFUtils.RDF_NS, "about");
IProject project = findOrCreateProject(sourceProjectRoot, uri);
generateRelatedEntities(sourceProjectRoot, project);
/**
* record any new seeAlsos against the project
*/
NodeList seeAlsos = sourceProjectRoot.getElementsByTagNameNS(
RDFUtils.RDFS_NS, RDFS.seeAlso.getLocalName());
for (int i = 0; i < seeAlsos.getLength(); i = i + 1) {
Element seeAlso = (Element) seeAlsos.item(i);
if (seeAlso.getParentNode().equals(sourceProjectRoot)) {
String seeAlsoUri = seeAlso.getAttributeNS(RDFUtils.RDF_NS, "resource")
.trim();
try {
project.addSeeAlso(new URI(seeAlsoUri));
} catch (URISyntaxException e) {
throw new SimalRepositoryException(
"Unable to add see also to simal:Project", e);
}
}
}
// add the source RDF
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new SimalRepositoryException("Unable to create document builder", e);
}
Document sourceDoc = db.newDocument();
Node root = sourceDoc.createElementNS(RDFUtils.RDF_NS, "RDF");
root.appendChild(sourceDoc.importNode(sourceProjectRoot, true));
sourceDoc.appendChild(root);