3737
3838import org .apache .commons .logging .Log ;
3939import org .apache .commons .logging .LogFactory ;
40- import org .apache .ws .commons .schema .ValidationEventHandler ;
4140import org .apache .ws .commons .schema .XmlSchema ;
4241import org .apache .ws .commons .schema .XmlSchemaCollection ;
4342import org .apache .ws .commons .schema .XmlSchemaExternal ;
4443import org .apache .ws .commons .schema .XmlSchemaImport ;
4544import org .apache .ws .commons .schema .XmlSchemaInclude ;
4645import org .apache .ws .commons .schema .XmlSchemaObject ;
47- import org .apache .ws .commons .schema .XmlSchemaObjectCollection ;
4846import org .apache .ws .commons .schema .resolver .DefaultURIResolver ;
4947import org .apache .ws .commons .schema .resolver .URIResolver ;
5048import org .xml .sax .InputSource ;
5452 * <p/>
5553 * Setting the {@link #setInline(boolean) inline} flag to <code>true</code> will result in all referenced schemas
5654 * (included and imported) being merged into the referred schema. When including the schemas into a WSDL, this greatly
57- * simplifies the deloyment of the schemas.
55+ * simplifies the deployment of the schemas.
5856 *
5957 * @author Arjen Poutsma
6058 * @see <a href="http://ws.apache.org/commons/XmlSchema/">Commons XML Schema</a>
@@ -72,8 +70,6 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
7270
7371 private boolean inline = false ;
7472
75- private ValidationEventHandler validationEventHandler ;
76-
7773 private URIResolver uriResolver = new ClasspathUriResolver ();
7874
7975 private ResourceLoader resourceLoader ;
@@ -105,21 +101,14 @@ public void setXsds(Resource[] xsdResources) {
105101 }
106102
107103 /**
108- * Defines whether included schemas should be inlinded into the including schema.
104+ * Defines whether included schemas should be inlined into the including schema.
109105 * <p/>
110106 * Defaults to <code>false</code>.
111107 */
112108 public void setInline (boolean inline ) {
113109 this .inline = inline ;
114110 }
115111
116- /**
117- * Sets the WS-Commons validation event handler to use while parsing schemas.
118- */
119- public void setValidationEventHandler (ValidationEventHandler validationEventHandler ) {
120- this .validationEventHandler = validationEventHandler ;
121- }
122-
123112 /**
124113 * Sets the WS-Commons uri resolver to use when resolving (relative) schemas.
125114 * <p/>
@@ -146,7 +135,7 @@ public void afterPropertiesSet() throws IOException {
146135 Assert .isTrue (xsdResource .exists (), xsdResource + " does not exit" );
147136 try {
148137 XmlSchema xmlSchema =
149- schemaCollection .read (SaxUtils .createInputSource (xsdResource ), validationEventHandler );
138+ schemaCollection .read (SaxUtils .createInputSource (xsdResource ));
150139 xmlSchemas .add (xmlSchema );
151140
152141 if (inline ) {
@@ -188,32 +177,30 @@ public XmlValidator createValidator() throws IOException {
188177 private void inlineIncludes (XmlSchema schema , Set <XmlSchema > processedIncludes , Set <XmlSchema > processedImports ) {
189178 processedIncludes .add (schema );
190179
191- XmlSchemaObjectCollection schemaItems = schema .getItems ();
192- for (int i = 0 ; i < schemaItems .getCount (); i ++) {
193- XmlSchemaObject schemaObject = schemaItems .getItem (i );
180+ List < XmlSchemaObject > schemaItems = schema .getItems ();
181+ for (int i = 0 ; i < schemaItems .size (); i ++) {
182+ XmlSchemaObject schemaObject = schemaItems .get (i );
194183 if (schemaObject instanceof XmlSchemaInclude ) {
195184 XmlSchema includedSchema = ((XmlSchemaInclude ) schemaObject ).getSchema ();
196185 if (!processedIncludes .contains (includedSchema )) {
197186 inlineIncludes (includedSchema , processedIncludes , processedImports );
198187 findImports (includedSchema , processedImports , processedIncludes );
199- XmlSchemaObjectCollection includeItems = includedSchema .getItems ();
200- for (int j = 0 ; j < includeItems .getCount (); j ++) {
201- XmlSchemaObject includedItem = includeItems .getItem (j );
188+ List <XmlSchemaObject > includeItems = includedSchema .getItems ();
189+ for (XmlSchemaObject includedItem : includeItems ) {
202190 schemaItems .add (includedItem );
203191 }
204192 }
205193 // remove the <include/>
206- schemaItems .removeAt (i );
194+ schemaItems .remove (i );
207195 i --;
208196 }
209197 }
210198 }
211199
212200 private void findImports (XmlSchema schema , Set <XmlSchema > processedImports , Set <XmlSchema > processedIncludes ) {
213201 processedImports .add (schema );
214- XmlSchemaObjectCollection includes = schema .getIncludes ();
215- for (int i = 0 ; i < includes .getCount (); i ++) {
216- XmlSchemaExternal external = (XmlSchemaExternal ) includes .getItem (i );
202+ List <XmlSchemaExternal > externals = schema .getExternals ();
203+ for (XmlSchemaExternal external : externals ) {
217204 if (external instanceof XmlSchemaImport ) {
218205 XmlSchemaImport schemaImport = (XmlSchemaImport ) external ;
219206 XmlSchema importedSchema = schemaImport .getSchema ();
0 commit comments