<%@ jet package="org.geotools.xml.codegen.templates" imports="java.util.* java.io.* org.eclipse.xsd.*" class="SchemaLocationResolverTemplate" %> <% Object[] args = (Object[])argument; XSDSchema schema = (XSDSchema)args[0] ; List includes = (List)args[1]; List namespaces = (List)args[2]; String ns = schema.getTargetNamespace(); Map pre2ns = schema.getQNamePrefixToNamespaceMap(); String prefix = null; for (Iterator itr = pre2ns.entrySet().iterator(); itr.hasNext();) { Map.Entry entry = (Map.Entry)itr.next(); if (entry.getValue().equals(ns)) { prefix = (String)entry.getKey(); break; } } %> import org.eclipse.xsd.XSDSchema; import org.eclipse.xsd.util.XSDSchemaLocationResolver; /** * * @generated */ public class <%=prefix.toUpperCase()%>SchemaLocationResolver implements XSDSchemaLocationResolver { /** * * * * @generated modifiable */ public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { if (schemaLocationURI == null) return null; //if no namespace given, assume default for the current schema if ((namespaceURI == null || "".equals(namespaceURI)) && xsdSchema != null) { namespaceURI = xsdSchema.getTargetNamespace(); } <% for (int i = 0; i < includes.size(); i++) { File include = (File)includes.get(i); String namespace = (String)namespaces.get(i); %> if ("<%=namespace%>".equals(namespaceURI)) { if (schemaLocationURI.endsWith("<%=include.getName()%>")) { return getClass().getResource("<%=include.getName()%>").toString(); } } <% } %> return null; } }