String schemaSrc = docType.getSourceName();
InputStream stream = docType.getTypeSystem()
.getSourceAsStream(schemaSrc);
SchemaDocument.Schema schema = null;
if (schemaSrc.endsWith(".wsdl") || schemaSrc.endsWith(".WSDL")) {
DefinitionsDocument defDoc =
DefinitionsDocument.Factory.parse(stream);
TTypes tt = defDoc.getDefinitions().getTypesArray(0);
XmlObject[] kids = selectChildren
(tt, SchemaDocument.Schema.class);
SchemaDocument.Schema[] schemas =
new SchemaDocument.Schema[kids.length];
// NOTE jcolwell@bea.com 2005-Jan-10 -- this is the part that the
// fancy generics saves me from having to do after each call to
// selectChildren(XmlObject, Class)
for (int j = 0; j < kids.length; j++) {
schemas[j] = (SchemaDocument.Schema) kids[j];
}
if (schemas.length == 1) {
schema = schemas[0];
} else {
String stNS = docType.getName().getNamespaceURI();
for (int j = 0; j < schemas.length; j++) {
if (stNS.equals(schemas[j].getTargetNamespace())) {
schema = schemas[j];
break;
}
}
}
} else {
SchemaDocument schemaDoc = SchemaDocument.Factory.parse(stream);
schema = schemaDoc.getSchema();
}
/*
FIXME jcolwell@bea.com 2004-Oct-21 -- it would be great if
the Types.loadInputSchema took an input source instead of a
String so I could directly pass in the input stream instead of
providing the schema elements individually.
*/
DefinitionsDocument defDoc = DefinitionsDocument.Factory
.newInstance();
TDefinitions definitions = defDoc.addNewDefinitions();
definitions.addNewService();
Node defEl = definitions.newDomNode(new XmlOptions()
.setSaveOuter());
Document dDoc = defEl.getOwnerDocument();
if (null == dDoc.getDocumentElement()) {