/** * Instantiates a PackageDisabler on the given SBMLDocument * <p> * PackageDisabler provides a method to remove unused packages that correspond * to {@link SBasePlugin} across a {@link SBMLDocument} * Additionally specific packages can be forcefully removed by use of * {@link #removePackage(String) removePackage} * * @param document * {@link SBMLDocument} to run the disabler on */ public PackageDisabler(SBMLDocument document) { this.document = document; namespaceMapping = document.getDeclaredNamespaces(); }
/** * Returns the map of declared namespaces of this SBMLDocument. * * @return the map of declared namespaces of this SBMLDocument. * @deprecated use {@link SBase#getDeclaredNamespaces()} */ @Deprecated public Map<String, String> getSBMLDocumentNamespaces() { return getDeclaredNamespaces(); }
/** * Removes the package namespace declaration in this {@link SBMLDocument}, * removes as well * the required attribute for this package. * * @param packageName * the name or short label of the package, for example: layout, comp, * qual, ... */ private void removePackageDeclaration(String packageName) { getDeclaredNamespaces().remove("xmlns:" + packageName); getSBMLDocumentAttributes().remove(packageName + ":required"); }
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); attributes.putAll(SBMLDocumentAttributes); if (isSetLevel()) { attributes.put("level", Integer.toString(getLevel())); } if (isSetVersion()) { attributes.put("version", Integer.toString(getVersion())); } Iterator<Map.Entry<String, String>> it = getDeclaredNamespaces().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); if (!entry.getKey().equals("xmlns")) { attributes.put(entry.getKey(), entry.getValue()); } } return attributes; }
Map<String, String> declaredNamespaces = doc.getDeclaredNamespaces(); List<String> packageNamespaces = new ArrayList<String>();
/** * Returns the namespace of an {@link SBMLDocument}. * * <p>The namespace is taken from the declared namespace map * to be able to validate models with wrong combination of * namespace and level and version.</p> * * @param d an {@link SBMLDocument} * @return the declared namespace of an {@link SBMLDocument} */ private String getSBMLDocumentNamespace(SBMLDocument d) { Map<String, String> namespaceMap = d.getDeclaredNamespaces(); String sbmlNamespace = null; if (namespaceMap.size() != 0) { String namespaceKey = "xmlns"; if (d.isSetUserObjects() && d.getUserObject(JSBML.ELEMENT_XML_PREFIX) != null) { namespaceKey = namespaceKey + ":" + d.getUserObject(JSBML.ELEMENT_XML_PREFIX); } sbmlNamespace = namespaceMap.get(namespaceKey); } return sbmlNamespace; }
if (sbase != null) { doc = sbase.getSBMLDocument(); sbmlNamespace = doc.getDeclaredNamespaces().get("xmlns");
sbmlNamespace = doc.getDeclaredNamespaces().get("xmlns");
System.out.println("Number of namespaces: " + testDocument.getDeclaredNamespaces().size()); for (String prefix : testDocument.getDeclaredNamespaces().keySet()) { System.out.println("PREFIX = "+prefix); String uri = testDocument.getDeclaredNamespaces().get(prefix); System.out.println("URI = "+uri);
if (sbmlDocument.getDeclaredNamespaces().size() > 0) { + sbmlDocument.getDeclaredNamespaces().size()); for (String prefix : sbmlDocument.getDeclaredNamespaces().keySet()) { String namespaceURI = sbmlDocument.getDeclaredNamespaces().get(prefix);
sbmlNamespace = doc.getDeclaredNamespaces().get("xmlns");