use of org.jdom.Document in project vcell by virtualcell.
the class DocumentCompiler method validateTOC.
private void validateTOC() throws Exception {
File tocSourceFile = new File(docSourceDir, tocFileName);
//
// read in existing TOC file and validate it's contents
//
Document doc = XmlUtil.readXML(tocSourceFile);
Element root = doc.getRootElement();
if (!root.getName().equals(VCellDocTags.toc_tag)) {
throw new RuntimeException("expecting " + VCellDocTags.toc_tag + " in file " + tocSourceFile.getPath());
}
HashSet<DocumentPage> pagesNotYetReferenced = new HashSet<DocumentPage>(Arrays.asList(documentation.getDocumentPages()));
readTOCItem(pagesNotYetReferenced, root);
if (pagesNotYetReferenced.size() > 0) {
for (DocumentPage docPage : pagesNotYetReferenced) {
if (!documentation.isReferenced(docPage)) {
System.err.println("ERROR: Document page '" + docPage.getTarget() + "' not referenced in either table of contents or from another document");
}
}
}
// copy the Table of Contents to the target directory.
FileUtils.copyFile(new File(docSourceDir, tocFileName), new File(docTargetDir, tocFileName));
// System.out.println("Calling buildHtmlIndex");
buildHtmlIndex(root);
}
use of org.jdom.Document in project vcell by virtualcell.
the class DocumentCompiler method readDefinitionFile.
private ArrayList<DocumentDefinition> readDefinitionFile(File file) throws XmlParseException {
ArrayList<DocumentDefinition> documentDefs = new ArrayList<DocumentDefinition>();
Document doc = XmlUtil.readXML(file);
Element root = doc.getRootElement();
if (!root.getName().equals(VCellDocTags.VCellDoc_tag)) {
throw new RuntimeException("expecting ...");
}
// get all definition elements
@SuppressWarnings("unchecked") List<Object> pageElements = root.getContent();
if (pageElements != null) {
for (Object pageElement : pageElements) {
if (pageElement instanceof Element && ((Element) pageElement).getName().equals(VCellDocTags.definition_tag)) {
String target = ((Element) pageElement).getAttributeValue(VCellDocTags.target_attr);
String label = ((Element) pageElement).getAttributeValue(VCellDocTags.definition_label_attr);
String text = ((Element) pageElement).getText();
DocumentDefinition documentDefinition = new DocumentDefinition(file, target, label, text);
documentDefs.add(documentDefinition);
}
}
}
return documentDefs;
}
use of org.jdom.Document in project vcell by virtualcell.
the class JDOM2Model method addJDOM.
public void addJDOM(Element element, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
Document document = new Document((Element) element.clone());
StringWriter stringWriter = new StringWriter();
new XMLOutputter().output(document, stringWriter);
StringReader stringReader = new StringReader(stringWriter.getBuffer().toString());
RDFParser rdfParser = Rio.createParser(RDFFormat.RDFXML);
rdfParser.setRDFHandler(new StatementCollector(model));
rdfParser.parse(stringReader, baseURI);
}
use of org.jdom.Document in project vcell by virtualcell.
the class VisMeshUtils method writePointDataToVtu.
public static void writePointDataToVtu(File inputMeshFile, String dataName, double[] data, File outputMeshFile) throws IOException {
Document meshDocument = XmlUtil.readXML(inputMeshFile);
addPointDataToVtuXml(meshDocument, dataName, data);
FileWriter fw = null;
try {
fw = new FileWriter(outputMeshFile);
XMLOutputter xmlOut = new XMLOutputter();
Format f = Format.getRawFormat();
f.setLineSeparator("\n");
f.setOmitEncoding(true);
f.setExpandEmptyElements(true);
xmlOut.setFormat(f);
xmlOut.output(meshDocument, fw);
} finally {
if (fw != null) {
fw.close();
}
}
}
use of org.jdom.Document in project vcell by virtualcell.
the class ExpressionMathMLPrinter method getMathML.
/**
* Insert the method's description here.
* Creation date: (2/8/2002 5:51:09 PM)
* @return java.lang.String
*/
String getMathML(boolean bOnlyMathMLFragment, MathType desiredMathType) throws ExpressionException, java.io.IOException {
org.jdom.output.XMLOutputter xmlwriter = new org.jdom.output.XMLOutputter();
Element mathElement = new Element("math", Namespace.getNamespace("http://www.w3.org/1998/Math/MathML"));
mathElement.addContent(getMathML(rootNode, desiredMathType));
if (!bOnlyMathMLFragment) {
Document mathDoc = new Document(mathElement);
return xmlwriter.outputString(mathDoc);
}
return xmlwriter.outputString(mathElement);
}
Aggregations