Search in sources :

Example 1 with XmlSchemaAnnotation

use of org.apache.ws.commons.schema.XmlSchemaAnnotation in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaElements.

private void addCorbaElements(CorbaType corbaTypeImpl, XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
    for (XmlSchemaElement el : elements.values()) {
        QName elName = el.getQName();
        XmlSchemaType schemaType = el.getSchemaType();
        if (elName == null) {
            elName = el.getRef().getTargetQName();
            schemaType = helper.getSchemaType(elName);
        }
        boolean anonymous = false;
        if (schemaType == null) {
            anonymous = true;
        } else {
            anonymous = WSDLTypes.isAnonymous(schemaType.getName());
        }
        if (schemaType != null) {
            XmlSchemaAnnotation annotation = null;
            if (el.getAnnotation() != null) {
                annotation = el.getAnnotation();
            }
            // this situation won't be handled. REVISIT.
            if (annotation != null) {
                XmlSchemaAppInfo appInfo = null;
                for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
                    if (ann instanceof XmlSchemaAppInfo) {
                        appInfo = (XmlSchemaAppInfo) ann;
                        break;
                    }
                }
                if (appInfo != null) {
                    NodeList nlist = appInfo.getMarkup();
                    Node node = nlist.item(0);
                    String info = node.getNodeValue();
                    info = info.trim();
                    String annotationBindingName = "";
                    if ("corba:binding=".equals(info.substring(0, 14))) {
                        annotationBindingName = info.substring(14);
                    }
                    if (bindingName.equals(annotationBindingName)) {
                        annotation = null;
                    }
                }
            }
            corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
            if (el.isNillable()) {
                QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
                corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
            }
            if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
            }
        }
    }
}
Also used : XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 2 with XmlSchemaAnnotation

use of org.apache.ws.commons.schema.XmlSchemaAnnotation in project cxf by apache.

the class WSDLParameter method getIdlType.

private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, QName typeName, boolean nill) throws Exception {
    QName idltype = null;
    CorbaType corbaTypeImpl = null;
    if (schemaType == null) {
        corbaTypeImpl = (CorbaType) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
        if (nill) {
            QName qname = corbaTypeImpl.getQName();
            idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
        } else {
            if (corbaTypeImpl == null) {
                XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
                XmlSchemaAnnotation annotation = null;
                if (schemaObj instanceof XmlSchemaElement) {
                    XmlSchemaElement el = (XmlSchemaElement) schemaObj;
                    schemaType = el.getSchemaType();
                    annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
                }
                idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
            } else {
                idltype = corbaTypeImpl.getQName();
            }
        }
    } else {
        // We need to get annotation information for the schema type we are
        // about to pass in.
        // This is used to produce the correct object reference type.
        XmlSchemaElement schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
        XmlSchemaAnnotation annotation = null;
        if (schemaObj != null) {
            annotation = schemaObj.getAnnotation();
        }
        idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
    }
    return idltype;
}
Also used : XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 3 with XmlSchemaAnnotation

use of org.apache.ws.commons.schema.XmlSchemaAnnotation in project cxf by apache.

the class ObjectReferenceVisitor method isDuplicateReference.

private void isDuplicateReference(QName referenceName, QName bindingName, Scope refScope, XmlSchemaType wsaType, AST node) {
    XmlSchema refSchema = null;
    if (!mapper.isDefaultMapping()) {
        String tns = mapper.map(refScope.getParent());
        String refSchemaFileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + refScope.getParent().toString("_") + ".xsd";
        refSchema = manager.getXmlSchema(tns);
        if (refSchema == null) {
            refSchema = manager.createXmlSchema(tns, wsdlVisitor.getSchemas());
        }
        addWSAddressingImport(refSchema);
        manager.addXmlSchemaImport(schema, refSchema, refSchemaFileName);
    } else {
        refSchema = schema;
    }
    // we have, then there is no need to add it to the schema again.
    if (!isReferenceSchemaTypeDefined(referenceName, refSchema)) {
        // We need to add a new element definition to the schema section of our WSDL.
        // For custom endpoint types, this should contain an annotation which points
        // to the binding which will be used for this endpoint type.
        XmlSchemaElement refElement = new XmlSchemaElement(schema, true);
        refElement.setName(referenceName.getLocalPart());
        refElement.setSchemaType(wsaType);
        refElement.setSchemaTypeName(wsaType.getQName());
        // Create an annotation which contains the CORBA binding for the element
        XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
        XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo();
        try {
            DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = db.newDocument();
            Element el = doc.createElement("appinfo");
            el.setTextContent("corba:binding=" + bindingName.getLocalPart());
            // TODO: This is correct but the appinfo markup is never added to the
            // schema.  Investigate.
            appInfo.setMarkup(el.getChildNodes());
        } catch (ParserConfigurationException ex) {
            throw new RuntimeException("[ObjectReferenceVisitor: error creating endpoint schema]");
        }
        annotation.getItems().add(appInfo);
        refElement.setAnnotation(annotation);
    }
}
Also used : XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) XmlSchema(org.apache.ws.commons.schema.XmlSchema) DocumentBuilder(javax.xml.parsers.DocumentBuilder) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Aggregations

XmlSchemaAnnotation (org.apache.ws.commons.schema.XmlSchemaAnnotation)3 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)3 QName (javax.xml.namespace.QName)2 XmlSchemaAppInfo (org.apache.ws.commons.schema.XmlSchemaAppInfo)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 XmlSchemaAnnotationItem (org.apache.ws.commons.schema.XmlSchemaAnnotationItem)1 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1