1   /*
2    * Created on 31.08.2008
3    * (C) Copyright 2003-2008 Alexander Veit
4    */
5   
6   
7   package tests;
8   
9   import javax.xml.parsers.DocumentBuilderFactory;
10  
11  import junit.framework.TestCase;
12  
13  import org.apache.ws.commons.schema.XmlSchema;
14  import org.apache.ws.commons.schema.XmlSchemaCollection;
15  import org.apache.ws.commons.schema.constants.Constants;
16  import org.w3c.dom.Document;
17  import org.w3c.dom.Element;
18  import org.w3c.dom.NodeList;
19  
20  
21  /**
22   * @author alex
23   * $Revision$
24   */
25  public class WSCOMMONS377Test extends TestCase {
26  
27      public void testSchemaImport() throws Exception {
28          DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
29          fac.setNamespaceAware(true);
30  
31          String strUri = Resources.asURI("WSCOMMONS-377/importing.wsdl");
32          Document doc = fac.newDocumentBuilder().parse(strUri);
33  
34          XmlSchemaCollection xsColl = new XmlSchemaCollection();
35          xsColl.setBaseUri(Resources.TEST_RESOURCES + "/WSCOMMONS-377");
36  
37          NodeList nodesSchema = doc.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "schema");
38          XmlSchema[] schemas = new XmlSchema[nodesSchema.getLength()];
39  
40          String systemIdBase = "urn:schemas";
41          for (int i = 0; i < nodesSchema.getLength(); i++)
42              schemas[i] = xsColl.read((Element)nodesSchema.item(i), systemIdBase + i);
43      }
44  }