Java Code Examples for org.apache.ws.commons.schema.XmlSchemaElement#setSchemaType()
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaElement#setSchemaType() .
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: ExceptionVisitor.java From cxf with Apache License 2.0 | 6 votes |
private XmlSchemaElement createElementType(AST memberNode, XmlSchemaType stype, Scope fqName) { // xmlschema:member XmlSchemaElement member = new XmlSchemaElement(schema, false); String memberName = memberNode.toString(); member.setName(memberName); if (stype != null) { member.setSchemaType(stype); member.setSchemaTypeName(stype.getQName()); if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { member.setNillable(true); } } else { wsdlVisitor.getDeferredActions(). add(fqName, new ExceptionDeferredAction(member)); } return member; }
Example 2
Source File: StructVisitor.java From cxf with Apache License 2.0 | 6 votes |
private XmlSchemaElement createXmlSchemaElement(AST memberNode, XmlSchemaType schemaType, Scope fqName) { // xmlschema:member XmlSchemaElement member = new XmlSchemaElement(schema, false); String memberName = memberNode.toString(); member.setName(memberName); member.setSchemaType(schemaType); if (schemaType != null) { member.setSchemaTypeName(schemaType.getQName()); if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { member.setNillable(true); } } else { wsdlVisitor.getDeferredActions(). add(fqName, new StructDeferredAction(member)); } return member; }
Example 3
Source File: XsdEmitter.java From legstar-core2 with GNU Affero General Public License v3.0 | 5 votes |
/** * Create an XML Schema element from a COBOL data item. * * @param xsdDataItem COBOL data item decorated with XSD attributes * @return the XML schema element */ public XmlSchemaElement createXmlSchemaElement(final XsdDataItem xsdDataItem) { // Let call add root elements if he needs to so for now pretend this is // not a root element XmlSchemaElement element = new XmlSchemaElement(getXsd(), false); element.setName(xsdDataItem.getXsdElementName()); if (xsdDataItem.getMaxOccurs() != 1) { element.setMaxOccurs(xsdDataItem.getMaxOccurs()); } if (xsdDataItem.getMinOccurs() != 1) { element.setMinOccurs(xsdDataItem.getMinOccurs()); } /* * Create this element schema type, then if its a simple type set it as * an anonymous type. Otherwise, it is a named complex type, so * reference it by name. */ XmlSchemaType xmlSchemaType = createXmlSchemaType(xsdDataItem); if (xmlSchemaType == null) { return null; } if (xmlSchemaType instanceof XmlSchemaSimpleType) { element.setSchemaType(xmlSchemaType); } else { element.setSchemaTypeName(xmlSchemaType.getQName()); } if (getConfig().addLegStarAnnotations()) { element.setAnnotation(_annotationEmitter .createLegStarAnnotation(xsdDataItem)); } return element; }
Example 4
Source File: OperationVisitor.java From cxf with Apache License 2.0 | 5 votes |
private XmlSchemaElement generateWrapper(QName el, XmlSchemaSequence wrappingSequence) { XmlSchemaComplexType schemaComplexType = new XmlSchemaComplexType(schema, false); schemaComplexType.setParticle(wrappingSequence); XmlSchemaElement wrappingSchemaElement = new XmlSchemaElement(schema, true); wrappingSchemaElement.setName(el.getLocalPart()); wrappingSchemaElement.setSchemaType(schemaComplexType); return wrappingSchemaElement; }
Example 5
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
/** * Code elsewhere in this function will fill in the name of the type of an * element but not the reference to the type. This function fills in the * type references. This does not set the type reference for elements that * are declared as refs to other elements. It is a giant pain to find them, * since they are not (generally) root elements and the code would have to * traverse all the types to find all of them. Users should look them up * through the collection, that's what it is for. */ private void fillInSchemaCrossreferences() { Service service = getService(); for (ServiceInfo serviceInfo : service.getServiceInfos()) { SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection(); // First pass, fill in any types for which we have a name but no // type. for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) { Map<QName, XmlSchemaElement> elementsTable = schemaInfo.getSchema().getElements(); for (XmlSchemaElement element : elementsTable.values()) { if (element.getSchemaType() == null) { QName typeName = element.getSchemaTypeName(); if (typeName != null) { XmlSchemaType type = schemaCollection.getTypeByQName(typeName); if (type == null) { Message message = new Message("REFERENCE_TO_UNDEFINED_TYPE", LOG, element .getQName(), typeName, service.getName()); LOG.severe(message.toString()); } else { element.setSchemaType(type); } } } } } } }
Example 6
Source File: AttributeVisitor.java From cxf with Apache License 2.0 | 4 votes |
/** Generate a wrapped doc style XmlSchemaElement containing one element. * * I.e.: generateWrappedDocElement(null, "foo", "bar"); * <xs:element name="foo"> * <xs:complexType> * <xs:sequence> * </xs:sequence> * </xs:complexType> * </xs:element> * * i.e.: generateWrappedDocElement(type, "foo", "bar"); * <xs:element name="foo"> * <xs:complexType> * <xs:sequence> * <xs:element name="bar" type="xs:short"> * </xs:element> * </xs:sequence> * </xs:complexType> * </xs:element> * * @param typeNode is the type of the element wrapped in the sequence, no element is created if null. * @param name is the name of the wrapping element. * @param paramName is the name of the wrapping element. * @return the wrapping element. */ private XmlSchemaElement generateWrappedDocElement(AST typeNode, String name, String paramName) { XmlSchemaElement element = new XmlSchemaElement(schema, false); if (typeNode != null) { ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), definition, schema, wsdlVisitor); visitor.visit(typeNode); XmlSchemaType stype = visitor.getSchemaType(); Scope fqName = visitor.getFullyQualifiedName(); if (stype != null) { element.setSchemaTypeName(stype.getQName()); if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { element.setNillable(true); } } else { wsdlVisitor.getDeferredActions(). add(fqName, new AttributeDeferredAction(element)); } element.setName(paramName); } XmlSchemaSequence sequence = new XmlSchemaSequence(); if (typeNode != null) { sequence.getItems().add(element); } XmlSchemaComplexType complex = new XmlSchemaComplexType(schema, false); complex.setParticle(sequence); QName qName = new QName(definition.getTargetNamespace(), name); XmlSchemaElement result = new XmlSchemaElement(schema, true); result.setSchemaType(complex); if (duplicateTypeTrackerMap.containsKey(qName.toString())) { result.setName(getScope().toString() + "." + name); qName = new QName(definition.getTargetNamespace(), getScope().toString() + "." + name); } else { result.setName(name); } duplicateTypeTrackerMap.put(qName.toString(), name); return result; }
Example 7
Source File: ObjectReferenceVisitor.java From cxf with Apache License 2.0 | 4 votes |
private void isDuplicateReference(QName referenceName, QName bindingName, Scope refScope, XmlSchemaType wsaType, AST node) { XmlSchema refSchema = null; if (!mapper.isDefaultMapping()) { String tns = mapper.map(refScope.getParent()); String refSchemaFileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + refScope.getParent().toString("_") + ".xsd"; refSchema = manager.getXmlSchema(tns); if (refSchema == null) { refSchema = manager.createXmlSchema(tns, wsdlVisitor.getSchemas()); } addWSAddressingImport(refSchema); manager.addXmlSchemaImport(schema, refSchema, refSchemaFileName); } else { refSchema = schema; } // Check to see if we have already defined an element for this reference type. If // we have, then there is no need to add it to the schema again. if (!isReferenceSchemaTypeDefined(referenceName, refSchema)) { // We need to add a new element definition to the schema section of our WSDL. // For custom endpoint types, this should contain an annotation which points // to the binding which will be used for this endpoint type. XmlSchemaElement refElement = new XmlSchemaElement(schema, true); refElement.setName(referenceName.getLocalPart()); refElement.setSchemaType(wsaType); refElement.setSchemaTypeName(wsaType.getQName()); // Create an annotation which contains the CORBA binding for the element XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); Element el = doc.createElement("appinfo"); el.setTextContent("corba:binding=" + bindingName.getLocalPart()); // TODO: This is correct but the appinfo markup is never added to the // schema. Investigate. appInfo.setMarkup(el.getChildNodes()); } catch (ParserConfigurationException ex) { throw new RuntimeException("[ObjectReferenceVisitor: error creating endpoint schema]"); } annotation.getItems().add(appInfo); refElement.setAnnotation(annotation); } }
Example 8
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
protected void createBareMessage(ServiceInfo serviceInfo, OperationInfo opInfo, boolean isOut) { MessageInfo message = isOut ? opInfo.getOutput() : opInfo.getInput(); final List<MessagePartInfo> messageParts = message.getMessageParts(); if (messageParts.isEmpty()) { return; } Method method = (Method)opInfo.getProperty(METHOD); int paraNumber = 0; for (MessagePartInfo mpi : messageParts) { SchemaInfo schemaInfo = null; XmlSchema schema = null; QName qname = (QName)mpi.getProperty(ELEMENT_NAME); if (messageParts.size() == 1 && qname == null) { qname = !isOut ? getInParameterName(opInfo, method, -1) : getOutParameterName(opInfo, method, -1); if (qname.getLocalPart().startsWith("arg") || qname.getLocalPart().startsWith("return")) { qname = isOut ? new QName(qname.getNamespaceURI(), method.getName() + "Response") : new QName(qname .getNamespaceURI(), method.getName()); } } else if (isOut && messageParts.size() > 1 && qname == null) { while (!isOutParam(method, paraNumber)) { paraNumber++; } qname = getOutParameterName(opInfo, method, paraNumber); } else if (qname == null) { qname = getInParameterName(opInfo, method, paraNumber); } for (SchemaInfo s : serviceInfo.getSchemas()) { if (s.getNamespaceURI().equals(qname.getNamespaceURI())) { schemaInfo = s; break; } } if (schemaInfo == null) { schemaInfo = getOrCreateSchema(serviceInfo, qname.getNamespaceURI(), true); schema = schemaInfo.getSchema(); } else { schema = schemaInfo.getSchema(); if (schema != null && schema.getElementByName(qname) != null) { mpi.setElement(true); mpi.setElementQName(qname); mpi.setXmlSchema(schema.getElementByName(qname)); paraNumber++; continue; } } schemaInfo.setElement(null); //cached element is now invalid XmlSchemaElement el = new XmlSchemaElement(schema, true); el.setName(qname.getLocalPart()); el.setNillable(true); if (mpi.isElement()) { XmlSchemaElement oldEl = (XmlSchemaElement)mpi.getXmlSchema(); if (null != oldEl && !oldEl.getQName().equals(qname)) { el.setSchemaTypeName(oldEl.getSchemaTypeName()); el.setSchemaType(oldEl.getSchemaType()); if (oldEl.getSchemaTypeName() != null) { addImport(schema, oldEl.getSchemaTypeName().getNamespaceURI()); } } mpi.setElement(true); mpi.setXmlSchema(el); mpi.setElementQName(qname); mpi.setConcreteName(qname); continue; } if (null == mpi.getTypeQName() && mpi.getXmlSchema() == null) { throw new ServiceConstructionException(new Message("UNMAPPABLE_PORT_TYPE", LOG, method.getDeclaringClass().getName(), method.getName(), mpi.getName())); } if (mpi.getTypeQName() != null) { el.setSchemaTypeName(mpi.getTypeQName()); } else { el.setSchemaType((XmlSchemaType)mpi.getXmlSchema()); } mpi.setXmlSchema(el); mpi.setConcreteName(qname); if (mpi.getTypeQName() != null) { addImport(schema, mpi.getTypeQName().getNamespaceURI()); } mpi.setElement(true); mpi.setElementQName(qname); paraNumber++; } }