use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method processSimpleContentStruct.
protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, QName defaultName, Struct corbaStruct, QName schematypeName) throws Exception {
List<MemberType> attrMembers = null;
CorbaType basetype = null;
String uri;
if (schematypeName != null) {
uri = schematypeName.getNamespaceURI();
} else {
uri = defaultName.getNamespaceURI();
}
if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {
XmlSchemaSimpleContentExtension ext = (XmlSchemaSimpleContentExtension) simpleContent.getContent();
if (ext.getBaseTypeName() != null) {
basetype = processPrimitiveType(ext.getBaseTypeName());
}
if (basetype == null) {
XmlSchemaType base = getSchemaType(ext.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
}
if (basetype == null) {
return null;
}
// process ext types ????
MemberType basemember = new MemberType();
basemember.setName("_simpleTypeValue");
QName baseTypeName = checkPrefix(basetype.getQName());
basemember.setIdltype(baseTypeName);
corbaStruct.getMember().add(basemember);
if (!isDuplicate(basetype)) {
typeMappingType.getStructOrExceptionOrUnion().add(basetype);
}
attrMembers = processAttributesAsMembers(ext.getAttributes(), uri);
} else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
XmlSchemaSimpleContentRestriction restrict = (XmlSchemaSimpleContentRestriction) simpleContent.getContent();
if (restrict.getBaseTypeName() != null) {
basetype = processPrimitiveType(restrict.getBaseTypeName());
}
if (basetype == null) {
XmlSchemaType base = getSchemaType(restrict.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
}
MemberType basemember = new MemberType();
basemember.setName("_simpleTypeValue");
QName baseTypeName = checkPrefix(basetype.getQName());
basemember.setIdltype(baseTypeName);
corbaStruct.getMember().add(basemember);
if (!isDuplicate(basetype)) {
typeMappingType.getStructOrExceptionOrUnion().add(basetype);
}
attrMembers = processAttributesAsMembers(restrict.getAttributes(), uri);
}
// Deal with Attributes defined in Extension
if (attrMembers != null) {
for (int i = 0; i < attrMembers.size(); i++) {
MemberType member = attrMembers.get(i);
corbaStruct.getMember().add(member);
}
}
return corbaStruct;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method processElementType.
private CorbaType processElementType(XmlSchemaElement stype, QName defaultName, String uri) throws Exception {
String name = null;
QName schemaTypeName = null;
XmlSchemaType schemaType = stype.getSchemaType();
if (stype.getQName() == null) {
if (stype.getRef().getTargetQName() == null) {
schemaTypeName = defaultName;
} else {
name = stype.getRef().getTargetQName().getLocalPart();
schemaType = findSchemaType(stype.getRef().getTargetQName());
}
} else {
name = stype.getQName().getLocalPart();
}
if (schemaTypeName == null) {
schemaTypeName = createQNameTargetNamespace(name);
}
CorbaType result = convertSchemaToCorbaType(schemaType, schemaTypeName, schemaType, null, false);
result.setQualified(getElementQualification(stype, uri));
return result;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class UnionVisitor method processCaseNodes.
private void processCaseNodes(AST caseNode, Scope scope, XmlSchemaChoice choice, Union corbaUnion) {
while (caseNode != null) {
final AST typeNode;
final AST nameNode;
// xmlschema:element
XmlSchemaElement element = new XmlSchemaElement(schema, false);
// corba:unionbranch
Unionbranch unionBranch = new Unionbranch();
if (caseNode.getType() == IDLTokenTypes.LITERAL_default) {
// default:
unionBranch.setDefault(true);
typeNode = caseNode.getFirstChild();
nameNode = typeNode.getNextSibling();
} else {
// case:
createCase(caseNode, unionBranch);
AST labelNode = caseNode.getFirstChild();
if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
labelNode = labelNode.getNextSibling();
}
typeNode = labelNode.getNextSibling();
nameNode = typeNode.getNextSibling();
}
TypesVisitor visitor = new TypesVisitor(scope, definition, schema, wsdlVisitor, null);
visitor.visit(typeNode);
XmlSchemaType stype = visitor.getSchemaType();
CorbaType ctype = visitor.getCorbaType();
Scope fullyQualifiedName = visitor.getFullyQualifiedName();
// needed for anonymous arrays in unions
if (ArrayVisitor.accept(nameNode)) {
Scope anonScope = new Scope(scope, TypesUtils.getCorbaTypeNameNode(nameNode));
ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName);
arrayVisitor.setSchemaType(stype);
arrayVisitor.setCorbaType(ctype);
arrayVisitor.visit(nameNode);
stype = arrayVisitor.getSchemaType();
ctype = arrayVisitor.getCorbaType();
fullyQualifiedName = visitor.getFullyQualifiedName();
}
// xmlschema:element
element.setName(nameNode.toString());
if (stype != null) {
element.setSchemaTypeName(stype.getQName());
if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
element.setNillable(true);
}
} else {
UnionDeferredAction elementAction = new UnionDeferredAction(element);
wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
}
choice.getItems().add(element);
// corba:unionbranch
unionBranch.setName(nameNode.toString());
if (ctype != null) {
unionBranch.setIdltype(ctype.getQName());
} else {
// its type is forward declared.
UnionDeferredAction unionBranchAction = new UnionDeferredAction(unionBranch);
wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction);
}
corbaUnion.getUnionbranch().add(unionBranch);
caseNode = caseNode.getNextSibling();
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLParameter method findSchemaType.
// This willl search the current schemas and any included
// schemas for the schema type.
private static XmlSchemaType findSchemaType(XmlSchema xmlSchema, QName typeName) {
XmlSchemaType schemaType = xmlSchema.getTypeByName(typeName);
if (schemaType == null) {
for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
if (ext instanceof XmlSchemaImport) {
XmlSchemaImport xmlImport = (XmlSchemaImport) ext;
if (xmlImport.getNamespace().equals(typeName.getNamespaceURI())) {
XmlSchema importSchema = xmlImport.getSchema();
schemaType = importSchema.getTypeByName(typeName);
} else {
schemaType = findSchemaType(ext.getSchema(), typeName);
if (schemaType != null) {
return schemaType;
}
}
}
}
if (schemaType != null) {
return schemaType;
}
}
return schemaType;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaTypes.
private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
for (XmlSchemaType type : objs.values()) {
boolean anonymous = WSDLTypes.isAnonymous(type.getName());
CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null, null, anonymous);
if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
}
}
addCorbaElements(xmlSchemaTypes);
}
Aggregations