use of org.jdom.Namespace in project vcell by virtualcell.
the class XMLUtils method getElementNamespaces.
/**
* Finds all namespaces, and returns a hashmap where keys are namespaces,
* and values are the elements where the namespace first appears in the
* document
*
* @param doc
* @return poss empty but non-null hash.q
*/
public Map<Namespace, Element> getElementNamespaces(Document doc) {
Iterator it = doc.getDescendants(new ElementFilter());
Map<Namespace, Element> nss = new HashMap<Namespace, Element>();
while (it.hasNext()) {
Element el = (Element) it.next();
Namespace ns = el.getNamespace();
if (ns != null && nss.get(ns) == null) {
nss.put(ns, el);
}
}
return nss;
}
use of org.jdom.Namespace in project vcell by virtualcell.
the class SimSpec method fromSBML.
public static SimSpec fromSBML(String sbmlText) throws IOException, SbmlException {
Element rootSBML = SBMLUtils.readXML(new StringReader(sbmlText));
Namespace sbmlNamespace = rootSBML.getNamespace();
// Namespace sbmlNamespace = Namespace.getNamespace("http://www.sbml.org/sbml/level2");
Element sbmlModelElement = rootSBML.getChild("model", sbmlNamespace);
//
// collect names of Species to compare
//
Vector<String> varNames = new Vector<String>();
Element listOfSpeciesElement = sbmlModelElement.getChild("listOfSpecies", sbmlNamespace);
if (listOfSpeciesElement != null) {
@SuppressWarnings("unchecked") List<Element> speciesElementList = listOfSpeciesElement.getChildren("species", sbmlNamespace);
for (Element speciesElement : speciesElementList) {
varNames.add(speciesElement.getAttributeValue("id"));
}
} else {
System.out.println("NO species in SBML model (parameters only) ... must be rate-rules only");
}
//
// Specify simulation task.
//
String[] varsToTest = varNames.toArray(new String[varNames.size()]);
float duration = 10f;
int numTimeSteps = 100;
SimSpec simSpec = new SimSpec(varsToTest, duration, numTimeSteps);
return simSpec;
}
use of org.jdom.Namespace in project vcell by virtualcell.
the class PathwayReaderBiopax3 method addObjectXref.
private Xref addObjectXref(Element element) {
Namespace bp = Namespace.getNamespace("bp", "http://www.biopax.org/release/biopax-level3.owl#");
if (element.getChild("UnificationXref", bp) != null) {
UnificationXref xref = addObjectUnificationXref(element.getChild("UnificationXref", bp));
return xref;
}
if (element.getChild("RelationshipXref", bp) != null) {
RelationshipXref xref = addObjectRelationshipXref(element.getChild("RelationshipXref", bp));
return xref;
}
if (element.getChild("PublicationXref", bp) != null) {
PublicationXref xref = addObjectPublicationXref(element.getChild("PublicationXref", bp));
return xref;
}
if (element.getChildren().size() == 0) {
XrefProxy xref = new XrefProxy();
addAttributes(xref, element);
pathwayModel.add(xref);
return xref;
} else {
for (Object child : element.getChildren()) {
if (child instanceof Element) {
Element childElement = (Element) child;
showUnexpected(childElement);
}
}
Xref xref = new Xref();
pathwayModel.add(xref);
System.out.println("should never happen");
return xref;
}
}
use of org.jdom.Namespace in project vcell by virtualcell.
the class Xmlproducer method getXML.
private Element getXML(PathwayModel pathwayModel, RDFXMLContext context) {
Element pathwayElement = new Element(XMLTags.PathwayModelTag);
String biopaxVersion = "3.0";
// create root element of rdf for BioPAX level 3
Namespace rdf = Namespace.getNamespace("rdf", DefaultNameSpaces.RDF.uri);
Element rootElement = new Element("RDF", rdf);
rootElement.setAttribute("version", biopaxVersion);
// get element from producer and add it to root element
PathwayProducerBiopax3 xmlProducer = new PathwayProducerBiopax3(context);
// here is work done
xmlProducer.getXML(pathwayModel, rootElement);
pathwayElement.addContent(rootElement);
return pathwayElement;
}
use of org.jdom.Namespace in project vcell by virtualcell.
the class XmlHelper method XMLToSim.
public static Simulation XMLToSim(String xmlString) throws XmlParseException {
Simulation sim = null;
Namespace ns = Namespace.getNamespace(XMLTags.VCML_NS);
try {
if (xmlString == null || xmlString.length() == 0) {
throw new XmlParseException("Invalid xml for Simulation: " + xmlString);
}
// default parser and no validation
Element root = (XmlUtil.stringToXML(xmlString, null)).getRootElement();
Element simElement = root.getChild(XMLTags.SimulationTag, ns);
Element mdElement = root.getChild(XMLTags.MathDescriptionTag, ns);
Element geomElement = root.getChild(XMLTags.GeometryTag, ns);
XmlReader reader = new XmlReader(true, ns);
Geometry geom = null;
if (geomElement != null) {
geom = reader.getGeometry(geomElement);
}
MathDescription md = reader.getMathDescription(mdElement, geom);
sim = reader.getSimulation(simElement, md);
} catch (Exception pve) {
pve.printStackTrace();
throw new XmlParseException("Unable to parse simulation string.", pve);
}
sim.refreshDependencies();
return sim;
}
Aggregations