Package org.apache.woden.wsdl20.xml

Examples of org.apache.woden.wsdl20.xml.TypesElement


      XmlSchemaCollection xsc = new XmlSchemaCollection();
      xs1 = xsc.read(schemaDoc1.getDocumentElement());
      schemaNS = new URI("http://www.sample.org");
      schema.setSchemaDefinition(xs1);
      schema.setNamespace(schemaNS);
      TypesElement types = factory.newDescription().addTypesElement();
      types.addSchema(schema);
  }
  catch(Exception e)
  {
    fail("An error occurred while creating the sample types section.");
  }
   
    // Test that a null namespace returns true.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, null, reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a null namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to a namespace that is defined inline
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement types = descElem.addTypesElement();
      types.addSchema(schema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been defined inline.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that is imported
  // does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      ImportedSchema importedSchema = new ImportedSchemaImpl();
      importedSchema.setSchemaDefinition(xs1);
      importedSchema.setNamespace(schemaNS);
      typesImported.addSchema(importedSchema);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to the XML Schema namespace does not return an error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(!val.testAssertionSchema1066(descElem, new QName(Constants.TYPE_XSD_2001, "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for the XML Schema namespace.");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
    // Test that a reference to a namespace that has not been defined inline or imported returns an error.
  // This test also checks that the method functions correctly with no defined types element.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      //descElem.setTypesElement(types);
     
    if(val.testAssertionSchema1066(descElem, new QName("http://www.sample2.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned true for a namespace that is not available..");
    }
  }
  catch(WSDLException e)
    {
    fail("There was a problem running the test assertion method " + e);
  }
 
  // Test that a reference to an inline schema that does not define a
  // target namespace (the targetNamespace is null) does not return an
  // error.
  handler.reset();
    try
  {
      DescriptionElement descElem = factory.newDescription();
      TypesElement typesImported = descElem.addTypesElement();
      InlinedSchema inlinedSchema = new InlinedSchemaImpl();
      typesImported.addSchema(inlinedSchema);
      InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
      inlinedSchema2.setNamespace(schemaNS);
      typesImported.addSchema(inlinedSchema2);
     
    if(!val.testAssertionSchema1066(descElem, new QName("http://www.sample.org", "myElement"), reporter))
    {
      fail("The testAssertionSchema1066 method returned false for a namespace that has been imported.");
    }
View Full Code Here


        XmlSchemaCollection xsc = new XmlSchemaCollection();
        xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
     
        //Add it to the typesElement.
        TypesElement typesEl = fDescriptionElement.addTypesElement();
        typesEl.addSchema(schema);
       
      fDescription = fDescriptionElement.toComponent();
   
    }
View Full Code Here

    {
      //Get the namespace and the local name from the qualified name.
      String namespace = qualifiedName.getNamespaceURI();
    String localname = qualifiedName.getLocalPart();     

      TypesElement types = descElement.getTypesElement();
      if(types == null)
      {
      errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
        return false;
      }
      Schema[] schemas = types.getSchemas();
      int numSchemas = schemas.length;
      boolean schemaNotFound = true;
      // TODO: This linear search should be improved for performance.
      for(int i = 0; i < numSchemas; i++)
      {
View Full Code Here

            ImportElement[] imports = desc.getImportElements();
            for(int i=0; i<imports.length; i++) {
                ImportElement importElem = (ImportElement) imports[i];
                DescriptionElement nestedDesc = importElem.getDescriptionElement();
                if(nestedDesc != null) {
                    TypesElement typesElem = nestedDesc.getTypesElement();
                    if(typesElem != null) {
                        Schema[] schemas = typesElem.getSchemas(schema.getNamespace());
                        for(int j=0; j<schemas.length; j++) {
                            Schema s = (Schema)schemas[i];
                            XmlSchema x = s.getSchemaDefinition();
                            if(x != null) {
                                schemaDef = x;
                                break;
                            }
                        }
                    }
                }
            }
        }
       
        if(schemaDef == null) {
            //Check if any WSDL includes contain a schema with this namespace.
            //TODO there may be multiple schemas that this namespace import could resolve to. This is a temporary solution pending WODEN- post M7.
            IncludeElement[] includes = desc.getIncludeElements();
            for(int i=0; i<includes.length; i++) {
                IncludeElement includeElem = (IncludeElement) includes[i];
                DescriptionElement nestedDesc = includeElem.getDescriptionElement();
                if(nestedDesc != null) {
                    TypesElement typesElem = nestedDesc.getTypesElement();
                    if(typesElem != null) {
                        Schema[] schemas = typesElem.getSchemas(schema.getNamespace());
                        for(int j=0; j<schemas.length; j++) {
                            Schema s = (Schema)schemas[i];
                            XmlSchema x = s.getSchemaDefinition();
                            if(x != null) {
                                schemaDef = x;
View Full Code Here

        // Also, this method currently requires that the schema elements exist in the types element.
        // This may not be the best idea as it may imply that this schema contains an actual import
        // statement in a WSDL 2.0 document. This method also does not work for when building the
        // model programmatically.
        // This method should be reevaluated at a later point.
        TypesElement types = desc.getTypesElement();
        if (types == null) {
            types = desc.addTypesElement();
        }
        if (types.getTypeSystem() == null)
        {
          types.setTypeSystem(Constants.TYPE_XSD_2001);
        }

        try
        {
          Document schemaDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
View Full Code Here

    {
        XmlSchemaElement xse = null;
        if (fElement != null && fElement.isQName()) {
            InterfaceElement interfac = (InterfaceElement)getParentElement();
            DescriptionElement desc = (DescriptionElement)interfac.getParentElement();
            TypesElement types = desc.getTypesElement();
            if(types != null) {
                xse = ((TypesImpl)types).getElementDeclaration(fElement.getQName());
            }
        }
        return xse;
View Full Code Here

    private TypesElement parseTypes(
            XMLElement typesEl,
            DescriptionElement desc)
            throws WSDLException {

        TypesElement types = desc.addTypesElement();

        //TODO for now set to W3 XML Schema. Later, add support for non-XML Schema type systems
        types.setTypeSystem(Constants.TYPE_XSD_2001);

        parseExtensionAttributes(typesEl, TypesElement.class, types, desc);

        XMLElement[] children = typesEl.getChildElements();
        XMLElement tempEl = null;
        QName tempElQN = null;

        for(int i=0; i<children.length; i++)
        {
            tempEl = children[i];
            tempElQN = tempEl.getQName();

            //TODO validate element order? <documentation> must be first.

            if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
            {
                parseDocumentation(tempEl, desc, types);
            }
            else if (SchemaConstants.Q_ELEM_SCHEMA_IMPORT.equals(tempElQN))
            {
                types.addSchema(parseSchemaImport(tempEl, desc));
            }
            else if (SchemaConstants.Q_ELEM_SCHEMA.equals(tempElQN))
            {
                types.addSchema(parseSchemaInline(tempEl, desc));
            }
            else
            {
                types.addExtensionElement(
                        parseExtensionElement(TypesElement.class, types, tempEl, desc) );
            }
        }

        return types;
View Full Code Here

       
        // Default case
        assertNull("When 'element' attribute is omitted, no ElementDeclaration should be present", msgRef.getElementDeclaration());
       
        // Test that the expected ElementDeclaration is returned
        TypesElement typesElement = fDescriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Reader reader = new StringReader(schemaString);
        InputSource is = new InputSource(reader);       
        Document schemaDoc1 = builder.parse(is);
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
       
        fMessageReferenceElement.setElement(new QNameTokenUnion(elemQN));
        ElementDeclaration elemDecl = msgRef.getElementDeclaration();
View Full Code Here

       
        // Default case
        assertNull("When 'element' attribute is omitted, no ElementDeclaration should be present", fault.getElementDeclaration());
       
        // Test that the expected ElementDeclaration is returned
        TypesElement typesElement = fDescriptionElement.addTypesElement()//throws WSDLException
        InlinedSchema schema = new InlinedSchemaImpl();
        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
                  + "<complexType name=\"myType\">"    
                  + "<sequence>"    
                  + "<element  name=\"element\" type=\"string\"/>"     
                  + "</sequence>"    
                  + "</complexType>"
                  + "<element name=\"myElement\" type=\"string\"/>"
                  + "</schema>";
        DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Reader reader = new StringReader(schemaString);
        InputSource is = new InputSource(reader);      
        Document schemaDoc1 = builder.parse(is);
        XmlSchemaCollection xsc = new XmlSchemaCollection();
        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
        schema.setSchemaDefinition(xs1);
        URI schemaNS = URI.create("http://www.sample.org");
        schema.setNamespace(schemaNS);
        typesElement.addSchema(schema);
       
        QName elemQN = new QName("http://www.sample.org","myElement");
       
        fFaultElement.setElement(new QNameTokenUnion(elemQN));
        ElementDeclaration elemDecl = fault.getElementDeclaration();
View Full Code Here

            // }
            //
            // }

            DescriptionElement descriptionElement = description.toElement();
            TypesElement typesElement = descriptionElement
                    .getTypesElement();
            if (typesElement != null) {
                Schema[] schemas = typesElement.getSchemas();
                for (int i = 0; i < schemas.length; i++) {
                    XmlSchema schemaDefinition = schemas[i].getSchemaDefinition();

                    // WSDL 2.0 spec requires that even the built-in schema should be returned
                    // once asked for schema definitions. But for data binding purposes we can ignore that
View Full Code Here

TOP

Related Classes of org.apache.woden.wsdl20.xml.TypesElement

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.