use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ScopedNameVisitor method populateAliasSchemaType.
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);
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ScopedNameVisitor method visit.
public void visit(AST node) {
// <scoped_name> ::= <identifier>
// | :: <identifier>
// | <scoped_name> "::" <identifier>
XmlSchemaType stype = null;
CorbaType ctype = null;
if (PrimitiveTypesVisitor.accept(node)) {
// primitive type
PrimitiveTypesVisitor primitiveVisitor = new PrimitiveTypesVisitor(null, definition, schema, schemas);
primitiveVisitor.visit(node);
stype = primitiveVisitor.getSchemaType();
ctype = primitiveVisitor.getCorbaType();
} else if (isforwardDeclared(getScope(), node, wsdlVisitor)) {
// forward declaration
Scope scope = forwardDeclared(getScope(), definition, schema, node, wsdlVisitor);
setFullyQualifiedName(scope);
// how will we create the corbatype ????
} else if (ObjectReferenceVisitor.accept(getScope(), schema, definition, node, wsdlVisitor)) {
ObjectReferenceVisitor objRefVisitor = new ObjectReferenceVisitor(getScope(), definition, schema, wsdlVisitor);
objRefVisitor.visit(node);
stype = objRefVisitor.getSchemaType();
ctype = objRefVisitor.getCorbaType();
} else {
VisitorTypeHolder holder = new VisitorTypeHolder();
boolean found = findSchemaType(getScope(), definition, schema, node, wsdlVisitor, holder);
if (found) {
ctype = holder.getCorbaType();
stype = holder.getSchemaType();
} else {
Scope scopedName = new Scope(getScope(), node);
QName qname = new QName(schema.getTargetNamespace(), scopedName.toString());
throw new RuntimeException("[ScopedNameVisitor: Corba type " + qname + " not found in typeMap]");
}
}
setSchemaType(stype);
setCorbaType(ctype);
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ScopedNameVisitor method findScopeSchemaType.
// Searches this scope for the schema type.
private static boolean findScopeSchemaType(Scope scopedName, XmlSchema schemaRef, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
WSDLSchemaManager manager = wsdlVisitor.getManager();
boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor, holder);
if (!result) {
XmlSchema xmlSchema = schemaRef;
String tns = wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
if (tns != null) {
xmlSchema = wsdlVisitor.getManager().getXmlSchema(tns);
}
XmlSchemaType stype = null;
if (xmlSchema != null) {
// Exceptions are treated as a special case as for the
// doc/literal style
// in the schema we will have an element and a complextype
// so the name
// and the typename will be different.
final String scopedNameString;
if (mapper.isDefaultMapping()) {
scopedNameString = scopedName.toString();
} else {
scopedNameString = scopedName.tail();
}
final QName qname;
if (exceptionMode) {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString + "Type");
} else {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString);
}
stype = xmlSchema.getTypeByName(qname);
if (stype == null) {
stype = schemas.getTypeByQName(qname);
}
}
if (stype != null) {
result = true;
}
if (result && holder != null) {
holder.setSchemaType(stype);
holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
// add a xmlschema import
if (!schemaRef.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
String importFile = wsdlVisitor.getOutputDir() + System.getProperty("file.separator") + scopedName.getParent().toString("_");
manager.addXmlSchemaImport(schemaRef, xmlSchema, importFile);
}
}
}
return result;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class FixedPtConstVisitor method visit.
public void visit(AST fixedNode) {
// <fixed_pt_const_type> ::= "fixed"
CorbaType ctype = null;
QName schemaTypeQName = Constants.XSD_DECIMAL;
XmlSchemaType stype = schemas.getTypeByQName(schemaTypeQName);
if (stype != null) {
ctype = new CorbaType();
ctype.setQName(CorbaConstants.NE_CORBA_FIXED);
ctype.setType(stype.getQName());
ctype.setName(stype.getQName().getLocalPart());
}
schemaType = stype;
corbaType = ctype;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class StructVisitor method visitStructMembers.
private void visitStructMembers(AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
AST memberTypeNode = identifierNode.getNextSibling();
while (memberTypeNode != null) {
AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
final XmlSchemaType schemaType;
final CorbaType corbaType;
Scope fqName;
try {
TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
visitor.visit(memberTypeNode);
schemaType = visitor.getSchemaType();
corbaType = visitor.getCorbaType();
fqName = visitor.getFullyQualifiedName();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
// (hence the ScopedNameVisitor.accept() call).
while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) {
XmlSchemaType memberSchemaType = schemaType;
CorbaType memberCorbaType = corbaType;
// needed for anonymous arrays in structs
if (ArrayVisitor.accept(memberNode)) {
Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
arrayVisitor.setSchemaType(schemaType);
arrayVisitor.setCorbaType(corbaType);
arrayVisitor.visit(memberNode);
memberSchemaType = arrayVisitor.getSchemaType();
memberCorbaType = arrayVisitor.getCorbaType();
fqName = arrayVisitor.getFullyQualifiedName();
}
XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
sequence.getItems().add(member);
MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
struct.getMember().add(memberType);
memberNode = memberNode.getNextSibling();
}
memberTypeNode = memberNode;
}
}
Aggregations