* @param model
* @param uri
* @return null means this is tld is not declared in the jsp file
*/
public static String getPrefix(IDOMModel model, String uri) {
TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
.getStructuredDocument());
if (m == null) {
// if the doc manager has nothing but the type is XML,
// then see if the prefix is encoded as a namespace in
// the doc root
if (model.getDocument().isXMLType())
{
Element root = getRootElement(model);
if (root != null){
NamedNodeMap attrs = root.getAttributes();
for (int i=0;i<attrs.getLength();i++){
Attr a = (Attr)attrs.item(i);
//is the taglib uri already declared?
if (a.getValue().equals(uri)
&& a.getName().startsWith("xmlns:")) //$NON-NLS-1$
{
String prefix = a.getNodeName().substring("xmlns:".length()); //$NON-NLS-1$
if ("".equals(prefix)) //$NON-NLS-1$
{
prefix = null;
}
return prefix;
}
}
}
}
return null;
}
List trackers = m.getTaglibTrackers();
for (Iterator iter = trackers.iterator(); iter.hasNext();) {
TaglibTracker tracker = (TaglibTracker) iter.next();
if (uri.equals(tracker.getURI())) {
return tracker.getPrefix();
}