Package javax.wsdl.extensions.schema

Examples of javax.wsdl.extensions.schema.Schema


   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11Validator#validate(java.lang.Object, java.util.List, org.eclipse.wsdl.validate.wsdl11.WSDL11ValidationInfo)
   */
  public void validate(Object element, List parents, IWSDL11ValidationInfo valInfo)
  {
    List elements = new ArrayList();
    Schema elem = (Schema) element;
    Definition wsdlDefinition = (Definition) parents.get(parents.size() - 1);
    String baseLocation = wsdlDefinition.getDocumentBaseURI();
    // Add in the namespaces defined in the doc already that aren't defined locally in this schema.
    // There is no need to check for namespaces other then in the defintions and types elements as
    // inline schema can not have any other parents and must have there two parents.
    // First take care of the definitions element
   
    // create the inline schema string
  Element w3celement = elem.getElement();
  Hashtable parentnamespaces = getNamespaceDeclarationsFromParents(wsdlDefinition,w3celement);
  String targetNamespace = w3celement.getAttribute(Constants.ATTR_TARGET_NAMESPACE);
  // if the targetNamespace hasn't been defined for the schema use the
  // targetNamespace of the definitions element
  if(USE_WSDL_TARGETNAMESPACE && (targetNamespace == null || targetNamespace.equals(EMPTY_STRING)))
   {
    targetNamespace = wsdlDefinition.getTargetNamespace();
    w3celement.setAttribute(Constants.ATTR_TARGET_NAMESPACE,targetNamespace);
  }
 
    // If the namespace given is one of the old schema namespaces produce a warning.
  String namespace = w3celement.getNamespaceURI();
  if(namespace.equals(SchemaConstants.NS_URI_XSD_1999) || namespace.equals(SchemaConstants.NS_URI_XSD_2000))
   {
    valInfo.addWarning(
        messagegenerator.getString(_WARN_OLD_SCHEMA_NAMESPACE, QUOTE + SchemaConstants.NS_URI_XSD_2001 + QUOTE), element);
  }
 
    // now create and call the validator for the inline schema
    XSDValidator schemav = new XSDValidator();
   
    //String fileLocation = new URL(validatormanager.getFilename()).getPath();
    InlineXSDResolver inlineEntityResolver =
      getEntityResolver(wsdlDefinition, (Types) parents.get(0), baseLocation, targetNamespace);
    //  add in the external XSD Catalog to resolve schemas offline
    XMLEntityResolverChain entityResolverChain = new XMLEntityResolverChain();
    entityResolverChain.addEntityResolver(inlineEntityResolver);
    entityResolverChain.addEntityResolver(valInfo.getURIResolver());
    //entityResolverChain.addEntityResolver(XMLCatalogResolver.getInstance());
    entityResolverChain.addEntityResolver(new FileEntityResolver());
 
    //   Create the string representation of the inline schema.
    String xsd = InlineSchemaGenerator.createXSDString(w3celement, elements, baseLocation, parentnamespaces, inlineEntityResolver.getInlineSchemaNSs());

 
    schemav.validateInlineSchema(xsd, targetNamespace, baseLocation, entityResolverChain, inlineEntityResolver, valInfo.getSchemaCache());
   
//  check if the SOAP Encoding namespace is required but not imported
     if (InlineSchemaGenerator.soapEncodingRequiredNotImported(elem.getElement(), baseLocation, parentnamespaces))
     {
       valInfo.addWarning(messagegenerator.getString(_WARN_SOAPENC_IMPORTED_SCHEMA), element);
     }

    // If the schema isn't valid add the error messages produced to valinfo.
View Full Code Here


    {
      Iterator iSchemas = schemas.iterator();
    Set namespaces = new TreeSet();
      while (iSchemas.hasNext())
      {
        Schema extElem = (Schema) iSchemas.next();
        String thisNamespace = extElem.getElement().getAttribute(Constants.ATTR_TARGET_NAMESPACE);
        if(thisNamespace != null)
        {
                namespaces.add(thisNamespace);
        }
      }
      iSchemas = schemas.iterator();

      while (iSchemas.hasNext())
      {
        Schema extElem = (Schema) iSchemas.next();
        String thisNamespace = extElem.getElement().getAttribute(Constants.ATTR_TARGET_NAMESPACE);
        if (thisNamespace != null && !thisNamespace.equalsIgnoreCase(targetNamespace))
        {
         
          Element element = extElem.getElement();
     
//      create the inline schema string
       //Element w3celement = elem.getElement();
       Hashtable parentnamespaces = getNamespaceDeclarationsFromParents(wsdlDefinition,element);
       String xsd = InlineSchemaGenerator.createXSDString(element, new ArrayList(), referenceLocation, parentnamespaces, namespaces);
View Full Code Here


  public Map validate(Object element, List parents, String filename) throws Exception
  {
    elements = new Vector();
    Schema elem = (Schema) element;
    Definition wsdlDefinition = (Definition) parents.get(parents.size() - 1);
    // Add in the namespaces defined in the doc already that aren't defined locally in this schema.
    // There is no need to check for namespaces other then in the defintions and types elements as
    // inline schema can not have any other parents and must have there two parents.
    // First take care of the definitions element

    // create the inline schema string
  Element w3celement = elem.getElement();
  Hashtable parentnamespaces = getNamespaceDeclarationsFromParents(wsdlDefinition,w3celement);
  String targetNamespace = w3celement.getAttribute(Constants.ATTR_TARGET_NAMESPACE);
  // if the targetNamespace hasn't been defined for the schema use the
  // targetNamespace of the definitions element
  /*if(targetNamespace == null || targetNamespace.equals(""))
   {
    targetNamespace = wsdlDefinition.getTargetNamespace();
    w3celement.setAttribute(Constants.ATTR_TARGET_NAMESPACE,targetNamespace);
  }*/

  String xsd = InlineSchemaGenerator.createXSDString(w3celement, elements, filename, parentnamespaces);

    // If the namespace given is one of the old schema namespaces produce a warning.
    String namespace = w3celement.getNamespaceURI();
    if(namespace.equals(SchemaConstants.NS_URI_XSD_1999) || namespace.equals(SchemaConstants.NS_URI_XSD_2000))
    {
      throw new Exception("An old version of the schema namespace is specified.");
    }

    // now create and call the validator for the inline schema
    XSDValidator schemav = new XSDValidator();

    //String fileLocation = new URL(validatormanager.getFilename()).getPath();
    InlineXSDResolver inlineEntityResolver =
      getEntityResolver(wsdlDefinition, (Types) parents.get(0), filename, targetNamespace);
    //  add in the external XSD Catalog to resolve schemas offline
    XMLEntityResolverChain entityResolverChain = new XMLEntityResolverChain();
    entityResolverChain.addEntityResolver(inlineEntityResolver);
    entityResolverChain.addEntityResolver(new FileEntityResolver());
    entityResolverChain.addEntityResolver(XMLCatalogResolver.getInstance());
    schemav.validateInlineSchema(xsd, targetNamespace, filename, entityResolverChain, inlineEntityResolver);

    // check if the SOAP Encoding namespace is required but not imported
    if (InlineSchemaGenerator.soapEncodingRequiredNotImported(elem.getElement(), filename,parentnamespaces))
    {
      throw new Exception("The inline schema uses an element or type from "
        + "the SOAP encoding namespace but the namespace has not been imported. "
        + "The SOAP encoding namespace should be imported with an import "
        + "statement before it is used.");
View Full Code Here

    if (schemas != null)
    {
      Iterator iSchemas = schemas.iterator();
      while (iSchemas.hasNext())
      {
      Schema extElem = (Schema) iSchemas.next();
        String thisNamespace = extElem.getElement().getAttribute(Constants.ATTR_TARGET_NAMESPACE);
        if (thisNamespace != null && !thisNamespace.equalsIgnoreCase(targetNamespace))
        {

          Element element = extElem.getElement();
     
//      create the inline schema string
       //Element w3celement = elem.getElement();
       Hashtable parentnamespaces = getNamespaceDeclarationsFromParents(wsdlDefinition,element);
       String xsd = InlineSchemaGenerator.createXSDString(element, elements, referenceLocation, parentnamespaces);
View Full Code Here

            fileNameToSave = getFileNameToSave(wsdlFileName, ++i + ".wsdl");
        }
        Types types = wsdlDefinition.getTypes();
        if (types != null) {
            List extensibleElements = types.getExtensibilityElements();
            Schema schemaExtension;
            Object extensionObject;
            XmlSchema xmlSchema;
            XmlSchemaCollection xmlSchemaCollection;
            SchemaFileProcessor schemaFileProcessor;
            Map changedLocationMap;
            String basuri = wsdlDefinition.getDocumentBaseURI();
            basuri = basuri.substring(0, basuri.lastIndexOf("/") + 1);
            for (Object extensibleElement : extensibleElements) {
                extensionObject = extensibleElement;
                if (extensionObject instanceof Schema) {
                    // first get the schema object
                    schemaExtension = (Schema)extensionObject;
                    // create an xml schema object to be processed by SchemaFile procesor.
                    xmlSchemaCollection = new XmlSchemaCollection();
                    xmlSchemaCollection.setBaseUri(basuri);
                    xmlSchema = xmlSchemaCollection.read(schemaExtension.getElement());
                    schemaFileProcessor = new SchemaFileProcessor(registry);
                    changedLocationMap = new HashMap();
                    HashSet visitedSchemas = new HashSet();
                    schemaFileProcessor.calculateNewSchemaNames(
                            xmlSchema, processedScheamMap, visitedSchemas, true, processImports);
                    schemaFileProcessor.saveSchemaFileToRegistry(
                            xmlSchema, processedScheamMap, changedLocationMap, new HashSet(), true,
                            registryBasePath, processImports, null);
                    schemaFileProcessor.persistAssociations();

                    ArrayList xsdPaths = schemaFileProcessor.getSchemaPath();
                    for (Object xsdPath : xsdPaths) {
                        String xsd = (String)xsdPath;
                        String assocPath = "/" + fileNameToSave;
                        if (!"/".equals(registryBasePath)) {
                            assocPath = registryBasePath + assocPath;
                        }
                        associationsBuffer.add(new Association(assocPath, xsd,
                                CommonConstants.DEPENDS));
                        associationsBuffer.add(new Association(xsd, assocPath,
                                CommonConstants.USED_BY));
                    }

                    // update the current schema locations with the generated ones.
                    changeLocations(schemaExtension.getElement(), changedLocationMap);
                }
            }
        }

        // after processing the defintions save this to the registry
View Full Code Here

    */
   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) {}
     }
   }
View Full Code Here

        // adjust the schema locations in types section
        Types types = definition.getTypes();
        if (types != null) {
            List extensibilityElements = types.getExtensibilityElements();
            Object extensibilityElement = null;
            Schema schema = null;
            for (Iterator iter = extensibilityElements.iterator(); iter.hasNext();) {
                extensibilityElement = iter.next();
                if (extensibilityElement instanceof Schema) {
                    schema = (Schema) extensibilityElement;
                    changeLocations(schema.getElement());
                }
            }
        }

        Iterator iter = definition.getImports().values().iterator();
View Full Code Here

        List typeList = types.getExtensibilityElements();
        Iterator iterator = typeList.iterator();
        while (iterator.hasNext()) {
            Object o = iterator.next();
            if (o instanceof Schema) {
                Schema schema = (Schema)o;
                Map map = schema.getImports();
               
                List schemaImports = (List)
                    map.get("http://www.wfmc.org/wfxml/2.0/wfxml20.xsd");
                SchemaImport schemaImport = (SchemaImport) schemaImports.get(0);
                Schema ref = schemaImport.getReferencedSchema();
               
                schemaImport
                    .setSchemaLocationURI(requestBasePath + "/wfxml20.xsd");
            }
        }
View Full Code Here

        if (types != null) {
            List schemas = types.getExtensibilityElements();
            for (Iterator iterator = schemas.iterator(); iterator.hasNext();) {
                Object o = iterator.next();
                if (o instanceof Schema) {
                    Schema unknownExtensibilityElement = (Schema) o;
                    QName elementType = unknownExtensibilityElement.getElementType();
                    if (new QName("http://www.w3.org/2001/XMLSchema", "schema").equals(elementType)) {
                        Element element = unknownExtensibilityElement.getElement();
                        addSchemaElement(element, namespaceMap, schemaList);
                    }
                } else if (o instanceof UnknownExtensibilityElement) {
                    //This is allegedly obsolete as of axis-wsdl4j-1.2-RC3.jar which includes the Schema extension above.
                    //The change notes imply that imported schemas should end up in Schema elements.  They don't, so this is still needed.
                    UnknownExtensibilityElement unknownExtensibilityElement = (UnknownExtensibilityElement) o;
                    Element element = unknownExtensibilityElement.getElement();
                    String elementNamespace = element.getNamespaceURI();
                    String elementLocalName = element.getNodeName();
                    if ("http://www.w3.org/2001/XMLSchema".equals(elementNamespace) && "schema".equals(elementLocalName)) {
                        addSchemaElement(element, namespaceMap, schemaList);
                    }
View Full Code Here

        Types types = def.getTypes();
        if (types != null) {
            for (Iterator it = types.getExtensibilityElements().iterator(); it.hasNext();) {
                ExtensibilityElement ee = (ExtensibilityElement) it.next();
                if (ee instanceof Schema) {
                    Schema schema = (Schema) ee;
                    Map schemaImports = schema.getImports();
                    for (Iterator iter = schemaImports.values().iterator(); iter.hasNext();) {
                        List imps = (List) iter.next();
                        for (Iterator iterator = imps.iterator(); iterator.hasNext();) {
                            SchemaImport schemaImport = (SchemaImport) iterator.next();
                            Schema schemaImp = schemaImport.getReferencedSchema();
                            String schemaLoc = schemaImport.getSchemaLocationURI();
                            if (schemaLoc != null && schemaImp != null && schemaImp.getElement() != null && !URI.create(schemaLoc).isAbsolute()) {
                                wsdls.put(schemaLoc, schemaImp.getElement());
                            }
                        }
                    }
                }
            }
View Full Code Here

TOP

Related Classes of javax.wsdl.extensions.schema.Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.