throw new JspException("Cannot find servlet context");
InputStream stream =
context.getResourceAsStream(resource);
if (stream == null)
throw new JspException("Missing resource '" + resource + "'");
return new XSLTInputSource(stream);
}
// Locate the source object
Object source = null;
Object bean = pageContext.findAttribute(name);
if (bean == null)
throw new JspException("Missing bean '" + name + "'");
if (property == null)
source = bean;
else {
try {
char first = Character.toUpperCase(property.charAt(0));
String methodName = "get" + first + property.substring(1);
Class paramTypes[] = new Class[0];
Method method =
bean.getClass().getMethod(methodName, paramTypes);
source = method.invoke(bean, new Object[0]);
} catch (Exception e) {
throw new JspException(e.toString());
}
}
// Create an XSLTInputSource for the specified source object
if (source instanceof XSLTInputSource)
return ((XSLTInputSource) source);
else if (source instanceof String)
return (new XSLTInputSource(new StringReader((String) source)));
else if (source instanceof InputSource)
return (new XSLTInputSource((InputSource) source));
else if (source instanceof InputStream)
return (new XSLTInputSource((InputStream) source));
else if (source instanceof Node)
return (new XSLTInputSource((Node) source));
else if (source instanceof Reader)
return (new XSLTInputSource((Reader) source));
else
throw new JspException("Invalid input source type '" +
source.getClass().getName() + "'");
}