Java Code Examples for org.apache.ws.commons.schema.XmlSchemaElement#getQName()
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaElement#getQName() .
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: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 6 votes |
private boolean getElementQualification(XmlSchemaElement element, String uri) { QName schemaName = element.getQName(); if (element.isRef()) { schemaName = element.getRef().getTargetQName(); } if (schemaName.getNamespaceURI().isEmpty()) { schemaName = new QName(uri, schemaName.getLocalPart()); } boolean qualified = false; if (element.getForm() == XmlSchemaForm.QUALIFIED) { qualified = true; } else { qualified = WSDLUtils.isElementFormQualified(xmlSchemaList, schemaName); } return qualified; }
Example 3
Source File: ProcessorUtil.java From cxf with Apache License 2.0 | 6 votes |
private static List<WrapperElement> createWrappedElements(XmlSchemaSequence seq) { List<WrapperElement> qnames = new ArrayList<>(); if (seq != null) { List<XmlSchemaSequenceMember> items = seq.getItems(); for (XmlSchemaSequenceMember seqMember : items) { XmlSchemaElement subElement = (XmlSchemaElement)seqMember; if (subElement.getQName() != null) { qnames.add(new WrapperElement(subElement.getWireName(), subElement.getSchemaTypeName())); } else { qnames.add(new WrapperElement(subElement.getRef().getTargetQName(), subElement.getSchemaTypeName())); } } } return qnames; }
Example 4
Source File: ParticleInfo.java From cxf with Apache License 2.0 | 5 votes |
/** * As a general rule, the JavaScript code is organized by types. The * exception is global elements that have anonymous types. In those cases, * the JavaScript code has its functions named according to the element. * This method returns the QName for the type or element, accordingly. If a * schema has a local element with an anonymous, complex, type, this will * throw. This will need to be fixed. * * @return the qname. */ public QName getControllingName() { if (type != null && type.getQName() != null) { return type.getQName(); } else if (particle instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement)particle; if (element.getQName() != null) { return element.getQName(); } } Message message = new Message("IMPOSSIBLE_GLOBAL_ITEM", LOG, JavascriptUtils.cleanedUpSchemaSource(particle)); LOG.severe(message.toString()); throw new UnsupportedConstruct(message); }
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: XmlSchemaUtils.java From cxf with Apache License 2.0 | 5 votes |
/** * Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with * name and QName. * @param element * @param name */ public static void setElementRefName(XmlSchemaElement element, QName name) { if (name != null && ((element.getQName() != null && !element.getQName().equals(name)) || (element.getName() != null && !element.getName().equals(name.getLocalPart())))) { LOG.severe("Attempt to set the refName of an element with a name or QName"); throw new XmlSchemaInvalidOperation("Attempt to set the refName of an element " + "with a name or QName."); } element.getRef().setTargetQName(name); // cxf conventionally keeps something in the name slot. }
Example 7
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 5 votes |
/** * By convention, an element that is named in its schema's TNS can have a 'name' but * no QName. This can get inconvenient for consumers who want to think about qualified names. * Unfortunately, XmlSchema elements, unlike types, don't store a reference to their containing * schema. * @param element * @param schema */ public static QName getElementQualifiedName(XmlSchemaElement element, XmlSchema schema) { if (element.getQName() != null) { return element.getQName(); } else if (element.getName() != null) { return new QName(schema.getTargetNamespace(), element.getName()); } else { return null; } }
Example 8
Source File: WSDLToDataService.java From micro-integrator with Apache License 2.0 | 4 votes |
private static List<QueryParam> getQueryParamsFromAxisOperation(Map<QName, Document> modelMap, Map<QName, String> elementMap, AxisOperation axisOperation) throws DataServiceFault { AxisMessage axisMessage = getAxisMessageFromOperation(axisOperation, "in"); if (axisMessage == null) { throw new DataServiceFault( "Valid in message cannot be found for the operation '" + axisOperation.getName() + "'"); } XmlSchemaElement inMsgElement = axisMessage.getSchemaElement(); /* no query params - return empty list */ if (inMsgElement == null) { return new ArrayList<QueryParam>(); } XmlSchemaType inMsgType = inMsgElement.getSchemaType(); if (!(inMsgType instanceof XmlSchemaComplexType)) { throw new DataServiceFault( "Xmlschema complex type is expected for the in message of the operation '" + axisOperation.getName() + "'"); } QName inMsgTypeName = inMsgElement.getQName(); String elementName = elementMap.get(inMsgTypeName); Document operationDoc = modelMap.get(new QName(inMsgTypeName.getNamespaceURI(), elementName)); ModelBean operationBean = createModelBean(modelMap, operationDoc); List<QueryParam> queryParams = new ArrayList<QueryParam>(); String tmpType; List<ModelProperty> props = operationBean.getProperties(); ModelProperty prop; int count = props.size(); for (int i = 0; i < count; i++) { prop = props.get(i); tmpType = prop.getSimpleType(); if (tmpType == null) { if (prop.getType().isSimple()) { tmpType = prop.getType().getProperties().get(0).getSimpleType(); } else { throw new DataServiceFault( "A list of elements with simple types are expected at the in message of the operation '" + axisOperation.getName() + "'"); } } queryParams.add(new QueryParam( prop.getName(), DBUtils.getSQLTypeFromXsdType(tmpType), DBConstants.QueryTypes.IN, prop.isArray() ? DBConstants.QueryParamTypes.ARRAY : DBConstants.QueryParamTypes.SCALAR, i + 1, // ordinal null, null, new ArrayList<Validator>(), false, false)); } return queryParams; }
Example 9
Source File: SchemaJavascriptBuilder.java From cxf with Apache License 2.0 | 4 votes |
private void deserializeElement(XmlSchemaComplexType type, ParticleInfo itemInfo) { if (itemInfo.isGroup()) { for (ParticleInfo childElement : itemInfo.getChildren()) { deserializeElement(type, childElement); } return; } XmlSchemaType itemType = itemInfo.getType(); boolean simple = itemType instanceof XmlSchemaSimpleType || JavascriptUtils.notVeryComplexType(itemType); boolean mtomCandidate = JavascriptUtils.mtomCandidateType(itemType); String accessorName = "set" + StringUtils.capitalize(itemInfo.getJavascriptName()); utils.appendLine("cxfjsutils.trace('processing " + itemInfo.getJavascriptName() + "');"); XmlSchemaElement element = (XmlSchemaElement)itemInfo.getParticle(); QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, xmlSchema); String elementNamespaceURI = elementQName.getNamespaceURI(); boolean elementNoNamespace = "".equals(elementNamespaceURI); XmlSchema elementSchema = null; if (!elementNoNamespace) { elementSchema = xmlSchemaCollection.getSchemaByTargetNamespace(elementNamespaceURI); } boolean qualified = !elementNoNamespace && XmlSchemaUtils.isElementQualified(element, itemInfo.isGlobal(), xmlSchema, elementSchema); if (!qualified) { elementNamespaceURI = ""; } String localName = elementQName.getLocalPart(); String valueTarget = "item"; if (itemInfo.isOptional() || itemInfo.isArray()) { utils.startIf("curElement != null && cxfjsutils.isNodeNamedNS(curElement, '" + elementNamespaceURI + "', '" + localName + "')"); if (itemInfo.isArray()) { utils.appendLine("item = [];"); utils.startDo(); valueTarget = "arrayItem"; utils.appendLine("var arrayItem = null;"); } } utils.appendLine("var value = null;"); utils.startIf("!cxfjsutils.isElementNil(curElement)"); if (itemInfo.isAnyType()) { // use our utility utils.appendLine(valueTarget + " = org_apache_cxf_deserialize_anyType(cxfjsutils, curElement);"); } else if (simple) { if (mtomCandidate) { utils.appendLine(valueTarget + " = cxfjsutils.deserializeBase64orMom(curElement);"); } else { utils.appendLine("value = cxfjsutils.getNodeText(curElement);"); utils.appendLine(valueTarget + " = " + utils.javascriptParseExpression(itemType, "value") + ";"); } } else { XmlSchemaComplexType complexType = (XmlSchemaComplexType)itemType; QName baseQName = complexType.getQName(); if (baseQName == null) { baseQName = element.getQName(); } String elTypeJsName = nameManager.getJavascriptName(baseQName); utils.appendLine(valueTarget + " = " + elTypeJsName + "_deserialize(cxfjsutils, curElement);"); } utils.endBlock(); // the if for the nil. if (itemInfo.isArray()) { utils.appendLine("item.push(arrayItem);"); utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);"); utils.endBlock(); utils.appendLine(" while(curElement != null && cxfjsutils.isNodeNamedNS(curElement, '" + elementNamespaceURI + "', '" + localName + "'));"); } utils.appendLine("newobject." + accessorName + "(item);"); utils.appendLine("var item = null;"); if (!itemInfo.isArray()) { utils.startIf("curElement != null"); utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);"); utils.endBlock(); } if (itemInfo.isOptional() || itemInfo.isArray()) { utils.endBlock(); } }
Example 10
Source File: CommonsSchemaInfoBuilder.java From tomee with Apache License 2.0 | 4 votes |
private void addNestedElement(XmlSchemaElement element, XmlTypeInfo enclosingType) { QName elementQName; QName typeQName; if (element.getRefName() == null) { // // Normal element in a type // // Element Name with namespace String elementNamespace = element.getQName().getNamespaceURI(); if (elementNamespace == null || elementNamespace.equals("")) { elementNamespace = enclosingType.qname.getNamespaceURI(); } elementQName = new QName(elementNamespace, element.getQName().getLocalPart()); // Type name if (element.getSchemaTypeName() != null) { // Global type typeQName = element.getSchemaTypeName(); } else { // Anonymous type, so we need to declare it // Rule 2.b: Anonymous element absolute name "T>N" String anonymoustName = enclosingType.qname.getLocalPart() + ">" + elementQName.getLocalPart(); QName anonymousQName = new QName(elementNamespace, anonymoustName); // Rule 1.b: Anonymous type name ">E" typeQName = new QName(elementNamespace, ">" + anonymousQName.getLocalPart()); addType(typeQName, element.getSchemaType()); } } else { // // Referenced global element // // Local the referenced global element XmlSchemaElement refElement = xmlSchemaCollection.getElementByQName(element.getRefName()); // The name and type of the nested element are determined by the referenced element elementQName = refElement.getQName(); typeQName = refElement.getSchemaTypeName(); } // Add element to enclosing type XmlElementInfo nestedElement = createXmlElementInfo(elementQName, typeQName, element); enclosingType.elements.put(nestedElement.qname, nestedElement); }