1 17 package org.apache.forrest.sourcetype; 18 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 22 26 public class XmlSchemaRule implements SourceTypeRule 27 { 28 protected String schemaLocation; 29 protected String noNamespaceSchemaLocation; 30 31 public void configure(Configuration configuration) throws ConfigurationException 32 { 33 schemaLocation = configuration.getAttribute("schema-location", null); 34 noNamespaceSchemaLocation = configuration.getAttribute("no-namespace-schema-location", null); 35 if (schemaLocation == null && noNamespaceSchemaLocation == null) 36 throw new ConfigurationException("Missing schema-location and/or no-namespace-schema-location attribute on w3c-xml-schema element at " + configuration.getLocation()); 37 } 38 39 public boolean matches(SourceInfo sourceInfo) 40 { 41 if (schemaLocation != null && noNamespaceSchemaLocation != null 42 && schemaLocation.equals(sourceInfo.getXsiSchemaLocation()) 43 && noNamespaceSchemaLocation.equals(sourceInfo.getXsiNoNamespaceSchemaLocation())) 44 return true; 45 else if (schemaLocation != null && noNamespaceSchemaLocation == null && schemaLocation.equals(sourceInfo.getXsiSchemaLocation())) 46 return true; 47 else if (schemaLocation == null && noNamespaceSchemaLocation != null && noNamespaceSchemaLocation.equals(sourceInfo.getXsiNoNamespaceSchemaLocation())) 48 return true; 49 else 50 return false; 51 } 52 53 } 54 | Popular Tags |