org.apache.ws.commons.schema.XmlSchema Java Examples

The following examples show how to use org.apache.ws.commons.schema.XmlSchema. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addCorbaTypes(Definition definition) throws Exception {
    for (XmlSchema xmlSchemaTypes : xmlSchemaList.getXmlSchemas()) {

        for (XmlSchemaExternal ext : xmlSchemaTypes.getExternals()) {
            addCorbaTypes(ext.getSchema());
            // REVISIT: This was preventing certain types from being added to the corba
            // typemap even when they are referenced from other parts of the wsdl.
            //
            // Should this add the corba types if it IS an instance of the XmlSchemaImport
            // (and not an XmlSchemaInclude or XmlSchemaRedefine)?
            //if (!(extSchema instanceof XmlSchemaImport)) {
            //    addCorbaTypes(extSchema.getSchema());
            //}
        }
        if (!W3CConstants.NU_SCHEMA_XSD.equals(xmlSchemaTypes.getTargetNamespace())) {
            addCorbaTypes(xmlSchemaTypes);
        }
    }
}
 
Example #2
Source File: BindingHelper.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private void createDocumentEnvelope(XmlSchemaExtractor schemaExtractor, List<XmlSchemaElement> headerElements,
                                    List<XmlSchemaElement> bodyElements) {
    // envelope element
    final XmlSchema soapSchema = schemaExtractor.getTargetSchemas().getSchemaByTargetNamespace(soapVersion.getNamespace());
    final List<XmlSchemaSequenceMember> envelope = getSoapEnvelope(soapSchema);

    // check if there is a header included
    if (headerElements != null) {
        final List<XmlSchemaSequenceMember> headers = getXmlSchemaElement(soapSchema, envelope, soapVersion.getHeader());
        headers.addAll(headerElements);
    }

    // add body wrapper
    final List<XmlSchemaSequenceMember> bodySequence = getXmlSchemaElement(soapSchema, envelope, soapVersion.getBody());
    bodySequence.addAll(bodyElements);
}
 
Example #3
Source File: XsdToNeutralSchemaRepo.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private NeutralSchema parseSimpleType(XmlSchemaSimpleType schemaSimpleType, XmlSchema schema, String name) {

        NeutralSchema ns = recursiveParseSimpleType(schemaSimpleType, schema);
        if (schemaSimpleType.getName() == null) {
            // Type defined in-line. Need to capture it in the element schema set.
            int i = 1;
            NeutralSchema existing = elementSchemas.get(name + i);
            while (existing != null && !schemasEqual(ns, existing)) {
                i++;
                existing = schemas.get(name + i);
            }
            ns.setType(name + i);
            elementSchemas.put(name + i, ns);
        }
        return ns;
    }
 
Example #4
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * due to a bug, feature, or just plain oddity of JAXB, it isn't good enough
 * to just check the form of an element and of its schema. If schema 'a'
 * (default unqualified) has a complex type with an element with a ref= to
 * schema (b) (default unqualified), JAXB seems to expect to see a
 * qualifier, anyway. <br/> So, if the element is local to a complex type,
 * all we care about is the default element form of the schema and the local
 * form of the element. <br/> If, on the other hand, the element is global,
 * we might need to compare namespaces. <br/>
 *
 * @param element the element.
 * @param global if this element is a global element (complex type ref= to
 *                it, or in a part)
 * @param localSchema the schema of the complex type containing the
 *                reference, only used for the 'odd case'.
 * @param elementSchema the schema for the element.
 * @return if the element needs to be qualified.
 */
public static boolean isElementQualified(XmlSchemaElement element,
                                         boolean global,
                                         XmlSchema localSchema,
                                         XmlSchema elementSchema) {
    QName qn = getElementQualifiedName(element, localSchema);
    if (qn == null) {
        throw new RuntimeException("isElementQualified on anonymous element.");
    }
    if (element.isRef()) {
        throw new RuntimeException("isElementQualified on the 'from' side of ref=.");
    }


    if (global) {
        return isElementNameQualified(element, elementSchema)
            || (localSchema != null
                && !(qn.getNamespaceURI().equals(localSchema.getTargetNamespace())));
    }
    return isElementNameQualified(element, elementSchema);
}
 
Example #5
Source File: BindingHelper.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private void createRpcEnvelope(XmlSchemaExtractor schemaExtractor, QName operationWrapper) throws ParserException {

        // create soap envelope
        final XmlSchema soapSchema = schemaExtractor.getTargetSchemas().getSchemaByTargetNamespace(soapVersion.getNamespace());
        final List<XmlSchemaSequenceMember> soapEnvelope = getSoapEnvelope(soapSchema);

        if (headerParts != null) {
            // soap header
            final List<XmlSchemaSequenceMember> soapHeader = getXmlSchemaElement(soapSchema, soapEnvelope,
                soapVersion.getHeader());
            // add header elements
            soapHeader.addAll(getPartElements(schemaExtractor, soapSchema, headerParts));
        }

        // soap body
        final List<XmlSchemaSequenceMember> soapBody = getXmlSchemaElement(soapSchema, soapEnvelope, soapVersion.getBody());

        // top-level operation wrapper element
        final String namespaceURI = operationWrapper.getNamespaceURI();
        final XmlSchema operationSchema = schemaExtractor.getOrCreateTargetSchema(namespaceURI);
        final List<XmlSchemaSequenceMember> bodySequence = getXmlSchemaElement(operationSchema, soapSchema,
            soapBody, operationWrapper.getLocalPart(), true);

        // add bodyParts to wrapper element
        bodySequence.addAll(getPartElements(schemaExtractor, operationSchema, bodyParts));
    }
 
Example #6
Source File: JAXBSchemaInitializer.java    From cxf with Apache License 2.0 6 votes vote down vote up
private SchemaInfo createSchemaIfNeeded(String namespace, NamespaceMap nsMap) {
    SchemaInfo schemaInfo = serviceInfo.getSchema(namespace);
    if (schemaInfo == null) {
        XmlSchema xmlSchema = schemas.newXmlSchemaInCollection(namespace);

        if (qualifiedSchemas) {
            xmlSchema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
        }

        xmlSchema.setNamespaceContext(nsMap);

        schemaInfo = new SchemaInfo(namespace);
        schemaInfo.setSchema(xmlSchema);
        serviceInfo.addSchema(schemaInfo);
    }
    return schemaInfo;
}
 
Example #7
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName elName) {
    XmlSchemaElement schemaElement = null;

    schemaElement = xmlSchema.getElementByName(elName);
    if (schemaElement == null) {
        String prefix = definition.getPrefix(elName.getNamespaceURI());
        QName name = new QName(elName.getNamespaceURI(), prefix + ":" + elName.getLocalPart(), prefix);
        schemaElement = xmlSchema.getElementByName(name);
    }
    if (schemaElement != null) {
        return schemaElement;
    }
    for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
        if (!(ext instanceof XmlSchemaImport)) {
            schemaElement = findElement(ext.getSchema(), elName);
            if (schemaElement != null) {
                return schemaElement;
            }
        }
    }
    return schemaElement;
}
 
Example #8
Source File: Cob2Xsd.java    From legstar-core2 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Generate an XML Schema using a model of COBOL data items. The model is a
 * list of root level items. From these, we only process group items
 * (structures) with children.
 * 
 * @param cobolDataItems a list of COBOL data items
 * @param targetNamespace the target namespace to use (null for no namespace)
 * @return the XML schema
 */
public XmlSchema emitXsd(final List < CobolDataItem > cobolDataItems, final String targetNamespace) {
    if (_log.isDebugEnabled()) {
        _log.debug("5. Emitting XML Schema from model: {}",
                cobolDataItems.toString());
    }
    XmlSchema xsd = createXmlSchema(getConfig().getXsdEncoding(), targetNamespace);
    List < String > nonUniqueCobolNames = getNonUniqueCobolNames(cobolDataItems);
    XsdEmitter emitter = new XsdEmitter(xsd, getConfig());
    for (CobolDataItem cobolDataItem : cobolDataItems) {
        if (getConfig().ignoreOrphanPrimitiveElements()
                && cobolDataItem.getChildren().size() == 0) {
            continue;
        }
        XsdDataItem xsdDataItem = new XsdDataItem(cobolDataItem,
                getConfig(), null, 0, nonUniqueCobolNames, _errorHandler);
        // Create and add a root element
        xsd.getItems().add(emitter.createXmlSchemaElement(xsdDataItem));
    }
    return xsd;
}
 
Example #9
Source File: EnumType.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void writeSchema(XmlSchema root) {

    XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
    simple.setName(getSchemaType().getLocalPart());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    simple.setContent(restriction);

    Object[] constants = getTypeClass().getEnumConstants();

    List<XmlSchemaFacet> facets = restriction.getFacets();
    for (Object constant : constants) {
        XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
        f.setValue(getValue(constant));
        facets.add(f);
    }
}
 
Example #10
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected XmlSchemaType lookUpType(Part part) {
    XmlSchemaType schemaType = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
            if (schemaElement != null) {
                schemaType = schemaElement.getSchemaType();
            }
        } else {
            if (part.getTypeName() != null) {
                schemaType = xmlSchema.getTypeByName(part.getTypeName());
            }
        }
        if (schemaType != null) {
            return schemaType;
        }
    }

    return schemaType;
}
 
Example #11
Source File: XsdToNeutralSchemaRepo.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
protected void generateSchemas(Resource[] schemaResources) throws IOException {

        LOG.info("Starting XSD -> NeutralSchema Generator...");
        LOG.info("Using XML Schema Directory Path: " + getXsdPath());

        // Scan XML Schemas on path
        List<XmlSchema> xmlSchemas = parseXmlSchemas(schemaResources, XSD);

        // Iterate XML Schemas
        for (XmlSchema schema : xmlSchemas) {
            loadSchema(schema);
        }

        LOG.info("Statistics:");
        LOG.info("Xml Total Schema Files Parsed: " + xmlSchemas.size());
        LOG.info("Xml Total Schema Count: " + schemas.size());

        LOG.info("Finished.");
    }
 
Example #12
Source File: JAXBSchemaInitializer.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addExceptionMessage(Class<?> cls, XmlSchema schema, XmlSchemaSequence seq) {
    try {
        //a subclass could mark the message method as transient
        Method m = cls.getMethod("getMessage");
        if (!m.isAnnotationPresent(XmlTransient.class)
            && m.getDeclaringClass().equals(Throwable.class)) {
            JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
            XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
            exEle.setName("message");
            exEle.setSchemaTypeName(getTypeName(beanInfo));
            exEle.setMinOccurs(0);
            seq.getItems().add(exEle);
        }
    } catch (Exception e) {
        //ignore, just won't have the message element
    }
}
 
Example #13
Source File: Xsd2CobolTypesModelBuilder.java    From legstar-core2 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Process each element in the input Schema.
 * <p/>
 * 
 * @param xmlSchema the XML schema with COBOL annotations
 * @return a map of root elements in the XML schema, each one mapped to its
 *         composite types constituents
 * @throws Xsd2ConverterException if parsing the XML schema fails
 */
public Map < String, RootCompositeType > build(XmlSchema xmlSchema)
        throws Xsd2ConverterException {

    log.debug("visit XML Schema started");
    Map < String, RootCompositeType > rootComplexTypes = new LinkedHashMap < String, RootCompositeType >();

    for (Entry < QName, XmlSchemaElement > entry : xmlSchema.getElements()
            .entrySet()) {
        if (entry.getValue().getSchemaType() instanceof XmlSchemaComplexType) {
            CobolAnnotations cobolAnnotations = new CobolAnnotations(
                    entry.getValue());
            XmlSchemaComplexType xsdComplexType = (XmlSchemaComplexType) entry
                    .getValue().getSchemaType();
            RootCompositeType compositeTypes = new RootCompositeType(
                    cobolAnnotations.getCobolName());
            String complexTypeName = getComplexTypeName(xsdComplexType);
            rootComplexTypes.put(complexTypeName, compositeTypes);
            visit(xsdComplexType, compositeTypes, complexTypeName);
        }
    }

    log.debug("visit XML Schema ended");
    return rootComplexTypes;
}
 
Example #14
Source File: SchemaCollection.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the schema has already received (cross) imports for the schemaType
 *
 * @param schema
 * @param schemaType
 * @return false if cross imports for schemaType must still be added to schema
 */
private boolean crossImportsAdded(XmlSchema schema, XmlSchemaType schemaType) {
    boolean result = true;
    if (schemaType != null) {
        Set<XmlSchemaType> xmlTypesCheckedForCrossImports;
        if (!xmlTypesCheckedForCrossImportsPerSchema.containsKey(schema)) {
            xmlTypesCheckedForCrossImports = new HashSet<>();
            xmlTypesCheckedForCrossImportsPerSchema.put(schema, xmlTypesCheckedForCrossImports);
        } else {
            xmlTypesCheckedForCrossImports = xmlTypesCheckedForCrossImportsPerSchema.get(schema);
        }
        if (!xmlTypesCheckedForCrossImports.contains(schemaType)) {
            // cross imports for this schemaType have not yet been added
            xmlTypesCheckedForCrossImports.add(schemaType);
            result = false;
        }
    }
    return result;
}
 
Example #15
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * extract all complex types from a schema and cache into a map
 */
private void cacheComplexTypes(XmlSchema schema) {
    XmlSchemaObjectCollection schemaItems = schema.getItems();

    int numElements = schemaItems.getCount();

    // Iterate XML Schema items
    for (int i = 0; i < numElements; i++) {
        XmlSchemaObject schemaObject = schemaItems.getItem(i);
        if (schemaObject instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaObject;
            String elementTypeName = complexType.getName();
            complexTypes.put(elementTypeName, complexType);
        }
    }
}
 
Example #16
Source File: VisitorBase.java    From cxf with Apache License 2.0 6 votes vote down vote up
public VisitorBase(Scope scopeRef,
                   Definition defn,
                   XmlSchema schemaRef,
                   WSDLASTVisitor wsdlASTVisitor) {
    wsdlVisitor = wsdlASTVisitor;
    schemas = wsdlVisitor.getSchemas();
    scopedNames = wsdlVisitor.getScopedNames();
    deferredActions = wsdlVisitor.getDeferredActions();
    typeMap = wsdlVisitor.getTypeMap();

    manager = wsdlVisitor.getManager();
    mapper = wsdlVisitor.getModuleToNSMapper();

    scope = scopeRef;
    scope.setPrefix(wsdlASTVisitor.getPragmaPrefix());
    fullyQualifiedName = null;
    schemaType = null;
    corbaType = null;
    definition = defn;
    schema = schemaRef;
}
 
Example #17
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaType findSchemaType(QName typeName) {
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        // if the schema includes other schemas need to search there.
        XmlSchemaType schemaType = findTypeInSchema(xmlSchema, typeName);
        if (schemaType != null) {
            return schemaType;
        }
    }
    return null;
}
 
Example #18
Source File: WSDLASTVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean writeSchema(XmlSchema schemaRef, Writer writer) throws Exception  {
    //REVISIT, it should be easier to  write out the schema directly, but currently,
    //the XmlSchemaSerializer throws a NullPointerException, when setting up namespaces!!!
    //schemaRef.write(writer);
    Definition defn = manager.createWSDLDefinition(schemaRef.getTargetNamespace());
    manager.attachSchemaToWSDL(defn, schemaRef, true);
    writeSchemaDefinition(defn, writer);
    return true;
}
 
Example #19
Source File: ScopedNameVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected static void populateAliasSchemaType(CorbaType corbaType,
                                              WSDLASTVisitor wsdlVisitor,
                                              VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    holder.setCorbaType(corbaType);
    Alias alias = (Alias) corbaType;
    //loop through alias base types, till you get a non-alias corba type
    CorbaType type = findCorbaType(typeMap, alias.getBasetype());
    while ((type != null) && (type instanceof Alias)) {
        alias = (Alias) type;
        type = findCorbaType(typeMap, alias.getBasetype());
    }
    QName tname;
    if (type == null) {
        //it must be a primitive type
        tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
    } else {
        tname = type.getType();
    }
    XmlSchemaType stype = schemas.getTypeByQName(tname);
    if (stype == null) {
        XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
        if (xmlSchema != null) {
            stype = xmlSchema.getTypeByName(tname);
        } else {
            stype = wsdlVisitor.getSchema().getTypeByName(tname);
        }
    }
    holder.setSchemaType(stype);
}
 
Example #20
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public AttributeVisitor(Scope scope,
                        Definition defn,
                        XmlSchema schemaRef,
                        WSDLASTVisitor wsdlVisitor,
                        PortType wsdlPortType,
                        Binding wsdlBinding) {
    super(scope, defn, schemaRef, wsdlVisitor);
    extReg = definition.getExtensionRegistry();
    portType = wsdlPortType;
    binding = wsdlBinding;
}
 
Example #21
Source File: XsdReader.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
public static final XmlSchema readSchema(final File file, final URIResolver schemaResolver)
        throws FileNotFoundException {
    final InputStream istream = new BufferedInputStream(new FileInputStream(file));
    try {
        return readSchema(istream, schemaResolver);
    } finally {
        closeQuiet(istream);
    }
}
 
Example #22
Source File: TypesVisitorBase.java    From cxf with Apache License 2.0 5 votes vote down vote up
public TypesVisitorBase(XmlSchemaCollection xmlSchemas,
                        XmlSchema xmlSchema,
                        TypeMappingType typeMapRef) {
    schemas = xmlSchemas;
    schema = xmlSchema;
    typeMap = typeMapRef;
}
 
Example #23
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void buildXmlTypeInfos() {
    for (XmlSchema schema : xmlSchemaCollection.getXmlSchemas()) {
        // Global Elements
        for (Iterator iterator = schema.getElements().getValues(); iterator.hasNext(); ) {
            XmlSchemaElement globalElement = (XmlSchemaElement) iterator.next();
            addGlobalElement(globalElement);
        }

        // Global Types
        for (Iterator iterator = schema.getSchemaTypes().getValues(); iterator.hasNext(); ) {
            XmlSchemaType globalType = (XmlSchemaType) iterator.next();
            addType(globalType.getQName(), globalType);
        }
    }
}
 
Example #24
Source File: TypesVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public TypesVisitor(Scope scope,
                    Definition defn,
                    XmlSchema schemaRef,
                    WSDLASTVisitor wsdlVisitor,
                    AST identifierNodeRef) {
    super(scope, defn, schemaRef, wsdlVisitor);
    identifierNode = identifierNodeRef;
}
 
Example #25
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public OperationVisitor(Scope scope,
                        Definition defn,
                        XmlSchema schemaRef,
                        WSDLASTVisitor wsdlVisitor,
                        PortType wsdlPortType,
                        Binding wsdlBinding) {
    super(scope, defn, schemaRef, wsdlVisitor);
    extReg = definition.getExtensionRegistry();
    portType = wsdlPortType;
    binding = wsdlBinding;
}
 
Example #26
Source File: SchemaCollection.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addOneSchemaCrossImports(XmlSchema schema) {
    /*
     * We need to visit all the top-level items.
     */
    for (XmlSchemaElement element : schema.getElements().values()) {
        addElementCrossImportsElement(schema, element);
    }
    for (XmlSchemaAttribute attribute : schema.getAttributes().values()) {
        XmlSchemaUtils.addImportIfNeeded(schema, attribute.getRef().getTargetQName());
        XmlSchemaUtils.addImportIfNeeded(schema, attribute.getSchemaTypeName());
    }
    for (XmlSchemaType type : schema.getSchemaTypes().values()) {
        addCrossImportsType(schema, type);
    }
}
 
Example #27
Source File: DeclaratorVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public DeclaratorVisitor(Scope scope,
                         Definition defn,
                         XmlSchema schemaRef,
                         WSDLASTVisitor wsdlASTVisitor,
                         XmlSchemaType schemaTypeRef,
                         CorbaType corbaTypeRef,
                         Scope fQName) {
    super(scope, defn, schemaRef, wsdlASTVisitor);
    setSchemaType(schemaTypeRef);
    setCorbaType(corbaTypeRef);
    setFullyQualifiedName(fQName);
}
 
Example #28
Source File: ParamDeferredAction.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void execute(XmlSchemaType stype, CorbaTypeImpl ctype) {
    if (param != null) {
        param.setIdltype(ctype.getQName());
    }
    if (element != null) {
        element.setSchemaTypeName(stype.getQName());
        if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }

        if (manager == null) {
            return;
        }

        // Now we need to make sure we are importing any types we need
        XmlSchema importedSchema = null;
        if (stype.getQName().getNamespaceURI().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
            boolean alreadyImported = false;
            for (XmlSchemaExternal ext : schema.getExternals()) {
                if (ext instanceof XmlSchemaImport) {
                    XmlSchemaImport schemaImport = (XmlSchemaImport)ext;
                    if (schemaImport.getNamespace().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
                        alreadyImported = true;
                        break;
                    }
                }
            }

            if (!alreadyImported) {
                // We need to add an import statement to include the WS addressing types
                XmlSchemaImport wsaImport = new XmlSchemaImport(schema);
                wsaImport.setNamespace(ReferenceConstants.WSADDRESSING_NAMESPACE);
                wsaImport.setSchemaLocation(ReferenceConstants.WSADDRESSING_LOCATION);
            }
        } else if (!stype.getQName().getNamespaceURI().equals(schema.getTargetNamespace())) {
            importedSchema = manager.getXmlSchema(mapper.map(typeScope));
            manager.addXmlSchemaImport(schema, importedSchema, typeScope.toString("_"));
        }
    }
}
 
Example #29
Source File: Xsd2UmlConvert.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private static final void convertComplexType(final XmlSchemaComplexType complexType, final XmlSchema schema,
        final Xsd2UmlConfig config, final Visitor handler, final QName complexTypeName,
        final List<TaggedValue> taggedValues) {
    
    final Identifier complexTypeId = config.ensureId(complexTypeName);
    
    final List<Attribute> attributes = new LinkedList<Attribute>();
    
    if (complexType.getContentModel() != null && complexType.getContentModel().getContent() != null) {
        final XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentExtension) {
            final XmlSchemaComplexContentExtension complexContentExtension = (XmlSchemaComplexContentExtension) content;
            attributes.addAll(parseFields(complexContentExtension, schema, config));
            // The base of the restriction is interpreted as a UML
            // generalization.
            final QName base = complexContentExtension.getBaseTypeName();
            final Identifier baseId = config.ensureId(base);
            // Hack here to support anonymous complex types in the context
            // of elements.
            // Need to fix the SLI MongoDB schemes so that all types are
            // named.
            handler.visit(new Generalization(config.getPlugin().nameFromComplexTypeExtension(complexTypeName, base),
                    complexTypeId, baseId));
        } else if (content instanceof XmlSchemaComplexContentRestriction) {
            throw new AssertionError(content);
        } else if (content instanceof XmlSchemaSimpleContentExtension) {
            throw new AssertionError(content);
        } else if (content instanceof XmlSchemaSimpleContentRestriction) {
            throw new AssertionError(content);
        } else {
            throw new AssertionError(content);
        }
    }
    
    attributes.addAll(parseFields(complexType, schema, config));
    
    final String name = config.getPlugin().nameFromSchemaTypeName(complexTypeName);
    handler.visit(new ClassType(complexTypeId, name, false, attributes, taggedValues));
}
 
Example #30
Source File: ObjectReferenceVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean accept(Scope scope, XmlSchema s,
                             Definition def, AST node, WSDLASTVisitor wsdlVisitor) {
    boolean result = false;
    if (node.getType() == IDLTokenTypes.LITERAL_Object) {
        result = true;
    } else if (node.getType() == IDLTokenTypes.IDENT && hasBinding(scope, s, def, node, wsdlVisitor)) {
        result = true;
    }
    return result;
}