/** * Returns the namespace prefix for the given URI. * * @param doc document object model of the XML source file * @param namespaceUri namespace URI to examine * @return namespace prefix for the given URI */ public static String getPrefixForNamespaceUri(IDOMDocument doc, String namespaceUri) { if (doc != null && namespaceUri != null) { NamespaceTable table = new NamespaceTable(doc); Element elem = doc.getDocumentElement(); table.addElementLineage(elem); return table.getPrefixForURI(namespaceUri); } return null; }
public CMDocument getCMDocument(Element element, String uri) { CMDocument result = null; NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument()); namespaceTable.addElementLineage(element); NamespaceInfo namespaceInfo = namespaceTable.getNamespaceInfoForURI(uri); if (namespaceInfo != null) { result = getCMDocument(namespaceInfo.uri, namespaceInfo.locationHint, "XSD"); // $NON-NLS-1$ } return result; }