use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ServiceJavascriptBuilder method createResponseDeserializer.
// This ignores 'wrapped', because it assumes one part that we can use one way or
// the other. For simple cases, this is certainly OK.
private void createResponseDeserializer(MessageInfo outputMessage) {
List<MessagePartInfo> parts = outputMessage.getMessageParts();
if (parts.size() != 1) {
unsupportedConstruct("MULTIPLE_OUTPUTS", outputMessage.getName().toString());
}
List<ParticleInfo> elements = new ArrayList<>();
String functionName = outputDeserializerFunctionName(outputMessage);
code.append("function ").append(functionName).append("(cxfjsutils, partElement) {\n");
getElementsForParts(outputMessage, elements);
ParticleInfo element = elements.get(0);
if (isRPC) {
utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
utils.appendLine("partElement = cxfjsutils.getFirstElementChild(partElement);");
utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
}
XmlSchemaType type = element.getType();
if (!element.isEmpty()) {
if (type instanceof XmlSchemaComplexType) {
String typeObjectName = nameManager.getJavascriptName(element.getControllingName());
utils.appendLine("var returnObject = " + typeObjectName + "_deserialize (cxfjsutils, partElement);\n");
utils.appendLine("return returnObject;");
} else if (type instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
utils.appendLine("var returnText = cxfjsutils.getNodeText(partElement);");
utils.appendLine("var returnObject = " + utils.javascriptParseExpression(simpleType, "returnText") + ";");
utils.appendLine("return returnObject;");
} else if (type != null) {
utils.appendLine("// Unsupported construct " + type.getClass());
} else {
utils.appendLine("// No type for element " + element.getXmlName());
}
}
code.append("}\n");
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLRefValidator method validatePartType.
private boolean validatePartType(String namespace, String name, boolean isElement) {
boolean partvalid = false;
if (namespace.equals(WSDLConstants.NS_SCHEMA_XSD)) {
if (isElement) {
XmlSchemaElement schemaEle = schemaCollection.getElementByQName(new QName(WSDLConstants.NS_SCHEMA_XSD, name));
partvalid = schemaEle != null ? true : false;
} else {
if ("anyType".equals(name)) {
return true;
}
XmlSchemaType schemaType = schemaCollection.getTypeByQName(new QName(WSDLConstants.NS_SCHEMA_XSD, name));
partvalid = schemaType != null ? true : false;
}
} else {
if (isElement) {
if (schemaCollection.getElementByQName(new QName(namespace, name)) != null) {
partvalid = true;
}
} else {
if (schemaCollection.getTypeByQName(new QName(namespace, name)) != null) {
partvalid = true;
}
}
}
return partvalid;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ConstVisitor method visit.
public void visit(AST constNode) {
// <const_dcl> ::= "const" <const_type> <identifier> "=" <const_exp>
// <const_type> ::= <integer_type>
// | <char_type>
// | <wide_char_type>
// | <boolean_type>
// | <floating_pt_type>
// | <string_type>
// | <wide_string_type>
// | <fixed_pt_const_type>
// | <scoped_name>
// | <octet_type>
AST constTypeNode = constNode.getFirstChild();
AST constNameNode = TypesUtils.getCorbaTypeNameNode(constTypeNode);
AST constValueNode = constNameNode.getNextSibling();
// build value string
StringBuilder constValue = new StringBuilder();
if (constValueNode.toString() != null) {
constValue.append(constValueNode.toString());
}
constValueNode = constValueNode.getFirstChild();
if (constValue.length() == 1) {
// might be a control char
byte ch = (byte) constValue.charAt(0);
if (ch >= 0 && ch <= 31) {
// ascii code between 0 and 31 is invisible control code
constValue.deleteCharAt(0);
constValue.append('\\').append(Integer.toOctalString(ch));
}
}
while (constValueNode != null) {
constValue.append(constValueNode.toString());
constValueNode = constValueNode.getFirstChild();
}
QName constQName = new QName(typeMap.getTargetNamespace(), new Scope(getScope(), constNameNode).toString());
Visitor visitor = null;
if (PrimitiveTypesVisitor.accept(constTypeNode)) {
visitor = new PrimitiveTypesVisitor(getScope(), definition, schema, schemas);
} else if (StringVisitor.accept(constTypeNode)) {
// string_type_spec
// wstring_type_spec
visitor = new StringVisitor(getScope(), definition, schema, wsdlVisitor, constTypeNode);
} else if (FixedPtConstVisitor.accept(constTypeNode)) {
visitor = new FixedPtConstVisitor(getScope(), definition, schema, schemas);
} else if (ScopedNameVisitor.accept(getScope(), definition, schema, constTypeNode, wsdlVisitor)) {
visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
}
if (visitor == null) {
throw new RuntimeException("can't resolve type for const " + constNameNode.getText());
}
visitor.visit(constTypeNode);
XmlSchemaType constSchemaType = visitor.getSchemaType();
CorbaTypeImpl constCorbaType = visitor.getCorbaType();
// corba:const
Const corbaConst = new Const();
corbaConst.setQName(constQName);
corbaConst.setValue(constValue.toString());
corbaConst.setType(constSchemaType.getQName());
corbaConst.setIdltype(constCorbaType.getQName());
typeMap.getStructOrExceptionOrUnion().add(corbaConst);
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class DeclaratorVisitor method visitNewTypes.
private void visitNewTypes(Scope newScope) {
CorbaType nextCorbaType = null;
CorbaType oldCorbaType = getCorbaType();
QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
if (oldCorbaType instanceof Alias) {
// Alias
//
Alias oldAlias = (Alias) oldCorbaType;
Alias alias = new Alias();
alias.setQName(newQname);
alias.setBasetype(oldAlias.getBasetype());
alias.setType(oldAlias.getType());
alias.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = alias;
} else if (oldCorbaType instanceof Sequence) {
// Sequence
//
XmlSchemaType nextSchemaType = duplicateXmlSchemaComplexType(newScope);
Sequence oldSequence = (Sequence) oldCorbaType;
Sequence newSequence = new Sequence();
newSequence.setQName(newQname);
newSequence.setType(nextSchemaType.getQName());
newSequence.setElemtype(oldSequence.getElemtype());
newSequence.setElemname(oldSequence.getElemname());
newSequence.setBound(oldSequence.getBound());
newSequence.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = newSequence;
} else if (oldCorbaType instanceof Fixed) {
// Fixed
//
// nextSchemaType =
duplicateXmlSchemaSimpleType(newScope);
Fixed oldFixed = (Fixed) getCorbaType();
Fixed newFixed = new Fixed();
newFixed.setQName(newQname);
newFixed.setDigits(oldFixed.getDigits());
newFixed.setScale(oldFixed.getScale());
newFixed.setType(oldFixed.getType());
newFixed.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = newFixed;
} else {
System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
// NOPMD
System.exit(1);
}
if (nextCorbaType != null) {
typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.
the class ComponentBuilder method collectAllXmlSchemaType.
/**
* DOC gcui Comment method "collectAllXmlSchemaType".
*/
private void collectAllXmlSchemaType() {
for (int i = 0; i < wsdlTypes.size(); i++) {
XmlSchema xmlSchema = (wsdlTypes.elementAt(i));
if (xmlSchema == null) {
continue;
}
XmlSchemaObjectTable xmlSchemaObjectTable = xmlSchema.getSchemaTypes();
Iterator typesItr = xmlSchemaObjectTable.getValues();
while (typesItr.hasNext()) {
XmlSchemaType xmlSchemaType = (XmlSchemaType) typesItr.next();
allXmlSchemaType.add(xmlSchemaType);
}
}
}
Aggregations