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

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction. 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: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Extract a particle from a complex type, respecting both extensions and restrictions
 * returns null if there isn't one.
 */
private String extractBaseTypeName(XmlSchemaComplexType complexType) {
    String baseTypeName = null;

    if (complexType.getBaseSchemaTypeName() != null) {
        baseTypeName = complexType.getBaseSchemaTypeName().getLocalPart();
    } else if (complexType.getContentModel() != null && complexType.getContentModel().getContent() != null) {
        XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentRestriction) {
            XmlSchemaComplexContentRestriction contentRestriction = (XmlSchemaComplexContentRestriction) content;
            if (contentRestriction.getBaseTypeName() != null) {
                baseTypeName = contentRestriction.getBaseTypeName().getLocalPart();
            }
        }
    }

    return baseTypeName;
}
 
Example #2
Source File: XmlSchemaExtractor.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private void handleComplexContentRestriction(XmlSchemaComplexContentRestriction target,
                                             XmlSchemaComplexContentRestriction source) throws ParserException {
    handleAttributesOrGroupRefs(target.getAttributes(), source.getAttributes());
    handleParticle(source.getParticle(), target::setParticle);

    // copy baseTypeName
    setTargetTypeQName(source.getBaseTypeName(), target::setBaseTypeName);
}
 
Example #3
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createDerivedType2(XmlSchema importingSchema) {
    XmlSchemaComplexContent complexContent;
    XmlSchemaComplexType derivedType2 = new XmlSchemaComplexType(importingSchema, true);
    derivedType2.setName("derivedRestriction");
    XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
    restriction.setBaseTypeName(new QName(BASE_TYPE_SCHEMA2, "baseType2"));
    complexContent = new XmlSchemaComplexContent();
    complexContent.setContent(restriction);
    derivedType2.setContentModel(complexContent);
}
 
Example #4
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static boolean isSoapArray(XmlSchemaComplexType complexType) {
    // Soap arrays are based on complex content restriction
    XmlSchemaContentModel contentModel = complexType.getContentModel();
    if (contentModel == null) {
        return false;
    }
    XmlSchemaContent content = contentModel.getContent();
    if (!(content instanceof XmlSchemaComplexContentRestriction)) {
        return false;
    }

    XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
    return SOAP_ARRAY.equals(restriction.getBaseTypeName());
}
 
Example #5
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Extract a particle from a complex type
 * returns null if it can't be extracted.
 */
private XmlSchemaParticle extractParticleWithRestriction(XmlSchemaComplexType complexType) {
    XmlSchemaParticle particle = complexType.getParticle();

    if (particle == null && complexType.getContentModel() != null
            && complexType.getContentModel().getContent() != null) {
        XmlSchemaContent content = complexType.getContentModel().getContent();
        if (content instanceof XmlSchemaComplexContentRestriction) {
            XmlSchemaComplexContentRestriction complexContent = (XmlSchemaComplexContentRestriction) content;
            particle = complexContent.getParticle();
        }
    }
    return particle;
}
 
Example #6
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));
}