/** * Get the schema with the specified target namespace. * * @param targetNamespace * target namespace of the schema to get. * @return null if not found. */ private Schema getSchema( String targetNamespace ) { if ( _types == null ) { return null; } List<ExtensibilityElement> schemas = WsdlUtils.findExtensibilityElements( _types, "schema" ); for ( ExtensibilityElement e : schemas ) { Element schemaRoot = ( (Schema) e ).getElement(); String tns = schemaRoot.getAttribute( "targetNamespace" ); if ( targetNamespace.equals( tns ) ) { return (Schema) e; } } return null; } }
/** * Add an import to this LightWeightSchema * * @param importSchema the import to be added */ public void addImport(SchemaImport importSchema) { String namespaceURI = importSchema.getNamespaceURI(); List importList = (List) this.imports.get(namespaceURI); if (importList == null) { importList = new Vector(); this.imports.put(namespaceURI, importList); } importList.add(importSchema); }
schema.setElementType(elementType); schema.setElement(el); schema.setDocumentBaseURI(def.getDocumentBaseURI()); SchemaImport im = schema.createImport(); im.setId(DOMUtils.getAttribute(tempEl, SchemaConstants.ATTR_ID)); im.setNamespaceURI(DOMUtils.getAttribute(tempEl, Constants.ATTR_NAMESPACE)); im.setSchemaLocationURI(locationURI); schema.addImport(im); sr = schema.createInclude(); sr.setId(DOMUtils.getAttribute(tempEl, SchemaConstants.ATTR_ID)); sr.setSchemaLocationURI(locationURI); schema.addInclude(sr); sr = schema.createRedefine(); sr.setId(DOMUtils.getAttribute(tempEl, SchemaConstants.ATTR_ID)); sr.setSchemaLocationURI(locationURI); schema.addRedefine(sr);
private static Boolean setMtomEnabled(Schema schema) { if (schema != null) { if (hasExpectedContentTypes(schema.getElement())) { return true; } for (List<SchemaImport> c : ((Map<String, List<SchemaImport>>)schema.getImports()).values()) { for (SchemaImport simport : c) { if (setMtomEnabled(simport.getReferencedSchema())) { return true; } } } } return false; }
private void addSchemaImport(Schema schema, SchemaInfo schemaInfo, Schema referencedSchema) { SchemaImport imp = schema.createImport(); imp.setId(schemaInfo.getSystemId()); imp.setNamespaceURI(schemaInfo.getNamespaceURI()); imp.setSchemaLocationURI(referencedSchema.getDocumentBaseURI()); imp.setReferencedSchema(referencedSchema); schema.addImport(imp); }
if (schema.getDocumentBaseURI() != null) this.allSchemas.put(schema.getDocumentBaseURI(), schema); Collection ic = schema.getImports().values(); Iterator importsIterator = ic.iterator(); while(importsIterator.hasNext()) allSchemaRefs.addAll(schema.getIncludes()); allSchemaRefs.addAll(schema.getRedefines()); if (schemaRef.getSchemaLocationURI() == null) schemaRef.getSchemaLocationURI() + (schema.getDocumentBaseURI() == null ? "'." : "', relative to '" + schema.getDocumentBaseURI() + "'.")); schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI()); "Unable to locate with a locator " + "the schema referenced at '" + schemaRef.getSchemaLocationURI() + "' relative to document base '" + schema.getDocumentBaseURI() + "'"); String contextURI = schema.getDocumentBaseURI(); URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null;
private void addWSDLSchemaImport(Schema wsdlSchema, String tns, File file) { if (!wsdlSchema.getImports().containsKey(tns)) { SchemaImport schemaimport = wsdlSchema.createImport(); schemaimport.setNamespaceURI(tns); if (file != null && !ignoreImports) { schemaimport.setSchemaLocationURI(file.toURI().toString()); } wsdlSchema.addImport(schemaimport); } }
private void processSchema(javax.wsdl.extensions.schema.Schema schema, Collection<String> namespaceList) throws Exception { for (Iterator itImp = schema.getImports().values().iterator(); itImp.hasNext();) { Collection imps = (Collection) itImp.next(); for (Iterator itSi = imps.iterator(); itSi.hasNext();) { SchemaImport imp = (SchemaImport) itSi.next(); String namespaceUri = imp.getNamespaceURI(); namespaceList.add(namespaceUri); processSchema(imp.getReferencedSchema(), namespaceList); } } } }
/** * Build a list of schema target name spaces which are element form qualified. * * @return All target name spaces for schemas defined in the WSDL which are element form qualified. */ private List<String> getElementFormQualifiedNamespaces() { List<String> namespaces = new ArrayList<String>(); List<ExtensibilityElement> schemas = getSchemas(); for ( ExtensibilityElement schema : schemas ) { Element schemaElement = ( (Schema) schema ).getElement(); if ( schemaElement.hasAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR ) ) { String v = schemaElement.getAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR ); if ( WsdlUtils.ELEMENT_FORM_QUALIFIED.equalsIgnoreCase( v ) ) { namespaces.add( schemaElement.getAttribute( WsdlUtils.TARGET_NAMESPACE_ATTR ) ); } } } return namespaces; }
private static Boolean setMtomEnabled(Schema schema) { if (schema != null) { if (hasExpectedContentTypes(schema.getElement())) { return true; } for (List<SchemaImport> c : ((Map<String, List<SchemaImport>>)schema.getImports()).values()) { for (SchemaImport simport : c) { if (setMtomEnabled(simport.getReferencedSchema())) { return true; } } } } return false; }
private void addSchemaImport(Schema schema, SchemaInfo schemaInfo, Schema referencedSchema) { SchemaImport imp = schema.createImport(); imp.setId(schemaInfo.getSystemId()); imp.setNamespaceURI(schemaInfo.getNamespaceURI()); imp.setSchemaLocationURI(referencedSchema.getDocumentBaseURI()); imp.setReferencedSchema(referencedSchema); schema.addImport(imp); }
/** * Create a new instance, parse the WSDL file for named complex types. * * @param wsdlTypes * Name space resolver. */ protected WsdlComplexTypes( WsdlTypes wsdlTypes ) { List<ExtensibilityElement> schemas = wsdlTypes.getSchemas(); for ( ExtensibilityElement schema : schemas ) { Element schemaRoot = ( (Schema) schema ).getElement(); List<Element> types = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.COMPLEX_TYPE_NAME ); for ( Element t : types ) { String schemaTypeName = t.getAttribute( WsdlUtils.NAME_ATTR ); _complexTypes.put( schemaTypeName, new ComplexType( t, wsdlTypes ) ); } } }
private void addSchemaImport(Schema schema, SchemaInfo schemaInfo, Schema referencedSchema) { SchemaImport imp = schema.createImport(); imp.setId(schemaInfo.getSystemId()); imp.setNamespaceURI(schemaInfo.getNamespaceURI()); imp.setSchemaLocationURI(referencedSchema.getDocumentBaseURI()); imp.setReferencedSchema(referencedSchema); schema.addImport(imp); }
/** * Find a named <complexType> or <simpleType> in the types section of the WSDL. * * @param typeName * Name of the type to find. * @return null if type not found. */ protected Element findNamedType( QName typeName ) { Schema s = getSchema( typeName.getNamespaceURI() ); if ( s == null ) { return null; } Element schemaRoot = s.getElement(); // get all simple and complex types defined at the top-level. // List<Element> types = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.COMPLEX_TYPE_NAME ); types.addAll( DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.SIMPLE_TYPE_NAME ) ); Element namedType = null; for ( Element t : types ) { String schemaTypeName = t.getAttribute( WsdlUtils.NAME_ATTR ); if ( typeName.getLocalPart().equals( schemaTypeName ) ) { namedType = t; break; } } return namedType; }
Element schemaRoot = s.getElement(); List<Element> elements = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.ELEMENT_NAME );
public void marshall(Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { Schema schema = (Schema)extension; pw.print(" "); DOM2Writer.serializeAsXML(schema.getElement(), def.getNamespaces(), pw); pw.println(); } }
/** * Reads target namespace from schema definition element. * @param schema * @return */ private String getTargetNamespace(Schema schema) { return schema.getElement().getAttribute("targetNamespace"); }
public void visit( ExtensibilityElement el, Object parent, WSDLTraversalContext ctx) { if (el instanceof Schema) searchForImport(((Schema) el).getElement()); }
/** * (non-Javadoc) * @see org.eclipse.wst.wsi.wsdl.traversal.WSDLVisitor#visit(Message, Object, WSDLTraversalContext) */ public void visit(ExtensibilityElement obj, Object parent, WSDLTraversalContext ctx) { if((obj != null) && (obj instanceof Schema)) { Schema el = (Schema) obj; try { processor.processAllSchema(el.getElement()); } catch (WSIException e) {} } }
public void marshall(@SuppressWarnings("rawtypes") Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { try { writeXml(((Schema)extension).getElement(), pw); } catch (XMLStreamException e) { throw new WSDLException("", "Could not write schema.", e); } }