/** * Returns the qname of the element that has the first parameter as the namespace, the second as * the element. * * @param list The arguments. * @return The qname. */ public Object exec(List list) throws TemplateModelException { if (list.size() < 1) { throw new TemplateModelException( "The isDefinedGlobally method must have a local element declaration as a parameter."); } TemplateModel from = (TemplateModel) list.get(0); Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from); if (!LocalElementDeclaration.class.isInstance(unwrapped)) { throw new TemplateModelException( "The isDefinedGlobally method must have a local element declaration as a parameter."); } LocalElementDeclaration decl = (LocalElementDeclaration) unwrapped; String namespace = decl.getNamespace(); SchemaInfo schemaInfo = getModel().getNamespacesToSchemas().get(namespace); if (schemaInfo != null) { for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) { if (rootElementDeclaration.getName().equals(decl.getName())) { return true; } } for (ImplicitSchemaElement implicitSchemaElement : schemaInfo.getImplicitSchemaElements()) { if (implicitSchemaElement.getElementName().equals(decl.getName())) { return true; } } } return false; }