org.apache.ws.commons.schema.XmlSchemaParticle Java Examples
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaParticle.
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: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 6 votes |
/** * Extract a particle from a complex type * returns null if it can't be extracted. */ private XmlSchemaParticle extractParticle(XmlSchemaComplexType complexType) { XmlSchemaParticle particle = complexType.getParticle(); // handle case where the complexType is an extension if (particle == null && complexType.getContentModel() != null && complexType.getContentModel().getContent() != null) { XmlSchemaContent content = complexType.getContentModel().getContent(); if (content instanceof XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension complexContent = (XmlSchemaComplexContentExtension) content; particle = complexContent.getParticle(); } } return particle; }
Example #2
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 6 votes |
/** * Recursively parse through an XmlSchemaPatricle to the elements * collecting all DidRefSources */ private XmlSchemaElement parseParticleForIdentityType(XmlSchemaParticle particle) { XmlSchemaElement identityType = null; if (particle != null) { if (particle instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement) particle; String elementName = element.getSchemaTypeName().getLocalPart(); if (elementName.contains(IDENTITY_TYPE)) { identityType = element; } } else if (particle instanceof XmlSchemaSequence) { XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle; for (int i = 0; i < schemaSequence.getItems().getCount(); i++) { XmlSchemaObject item = schemaSequence.getItems().getItem(i); if (item instanceof XmlSchemaParticle) { identityType = parseParticleForIdentityType((XmlSchemaParticle) item); } } } } return identityType; }
Example #3
Source File: WSDLToDataService.java From micro-integrator with Apache License 2.0 | 5 votes |
private static boolean hasResultRowName(XmlSchemaComplexType wrapperSchemaComplexType) { XmlSchemaParticle wrapperSchemaParticle = wrapperSchemaComplexType.getParticle(); // a single sequence must be there if (!(wrapperSchemaParticle instanceof XmlSchemaSequence)) { return false; } XmlSchemaSequence wrapperSchemaSequence = (XmlSchemaSequence) wrapperSchemaParticle; XmlSchemaObjectCollection objects = wrapperSchemaSequence.getItems(); if (objects.getCount() != 1) { return false; } XmlSchemaObject schemaObject = objects.getItem(0); if (!(schemaObject instanceof XmlSchemaElement)) { return false; } XmlSchemaElement schemaElement = (XmlSchemaElement) schemaObject; if (!((((XmlSchemaComplexType) schemaElement.getSchemaType()) .getParticle()) instanceof XmlSchemaSequence)) { return false; } // cannot contain any attributes if (wrapperSchemaComplexType.getAttributes().getCount() > 0) { return false; } return true; }
Example #4
Source File: JavascriptUtils.java From cxf with Apache License 2.0 | 5 votes |
/** * If the object is an element or an any, return the particle. If it's not a particle, or it's a group, * throw. We're not ready for groups yet. * @param object */ public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName, XmlSchema currentSchema) { if (!(object instanceof XmlSchemaParticle)) { unsupportedConstruct("NON_PARTICLE_CHILD", object.getClass().getSimpleName(), contextName, object); } if (object instanceof XmlSchemaGroupRef) { QName groupName = ((XmlSchemaGroupRef) object).getRefName(); XmlSchemaGroup group = currentSchema.getGroupByName(groupName); if (group == null) { unsupportedConstruct("MISSING_GROUP", groupName.toString(), contextName, null); } XmlSchemaParticle groupParticle = group.getParticle(); if (!(groupParticle instanceof XmlSchemaSequence)) { unsupportedConstruct("GROUP_REF_UNSUPPORTED_TYPE", groupParticle.getClass().getSimpleName(), contextName, groupParticle); } return groupParticle; } if (!(object instanceof XmlSchemaElement) && !(object instanceof XmlSchemaAny) && !(object instanceof XmlSchemaChoice) && !(object instanceof XmlSchemaSequence)) { unsupportedConstruct("GROUP_CHILD", object.getClass().getSimpleName(), contextName, object); } return (XmlSchemaParticle) object; }
Example #5
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 5 votes |
/** * Extract a particle from a complex type * returns null if it can't be extracted. */ private XmlSchemaParticle extractParticleWithRestriction(XmlSchemaComplexType complexType) { XmlSchemaParticle particle = complexType.getParticle(); if (particle == null && complexType.getContentModel() != null && complexType.getContentModel().getContent() != null) { XmlSchemaContent content = complexType.getContentModel().getContent(); if (content instanceof XmlSchemaComplexContentRestriction) { XmlSchemaComplexContentRestriction complexContent = (XmlSchemaComplexContentRestriction) content; particle = complexContent.getParticle(); } } return particle; }
Example #6
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 5 votes |
private XmlSchemaParticle getParticleByType(String name) { XmlSchemaParticle particle = null; for (XmlSchemaComplexType parentComplexType : complexTypes.values()) { if(parentComplexType.getName().equals(name)) { particle = extractParticle(parentComplexType); break; } } return particle; }
Example #7
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 5 votes |
private Long parseParticleForMinOccurs(XmlSchemaParticle particle, String naturalKeyElement) { Long minOccurs = null; if (particle != null) { if (particle instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement) particle; String elementName = element.getName(); if (elementName.equals(naturalKeyElement)) { minOccurs = element.getMinOccurs(); return minOccurs; } } else if (particle instanceof XmlSchemaSequence) { XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle; for (int i = 0; i < schemaSequence.getItems().getCount(); i++) { XmlSchemaObject item = schemaSequence.getItems().getItem(i); if (item instanceof XmlSchemaParticle) { minOccurs = parseParticleForMinOccurs((XmlSchemaParticle) item, naturalKeyElement); if(minOccurs != null) { return minOccurs; } } } } } return minOccurs; }
Example #8
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 5 votes |
private Long parseRefParticleForMinOccurs(XmlSchemaParticle particle, String naturalKeyElement) { Long minOccurs = null; if (particle instanceof XmlSchemaSequence) { XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle; for (int i = 0; i < schemaSequence.getItems().getCount(); i++) { XmlSchemaObject item = schemaSequence.getItems().getItem(i); if (item instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement) item; QName elementType = element.getSchemaTypeName(); if (elementType != null && referenceTypes.containsKey(elementType.getLocalPart())) { //This element is of reference type check the elements of the identity type of this reference XmlSchemaParticle refParticle = getParticleByType(elementType.getLocalPart()); XmlSchemaElement identityTypeElement = parseParticleForIdentityType(refParticle); XmlSchemaParticle identityTypeParticle = getParticleByType(identityTypeElement.getSchemaTypeName().getLocalPart()); minOccurs = parseParticleForMinOccurs(identityTypeParticle, naturalKeyElement); if(minOccurs != null) { return minOccurs; } } } } } return minOccurs; }
Example #9
Source File: XmlSchemaExtractor.java From syndesis with Apache License 2.0 | 4 votes |
private <T extends XmlSchemaParticle> void handleParticle(T particle, Consumer<T> setParticle) throws ParserException { if (particle != null) { setParticle.accept(createXmlSchemaObjectBase(particle)); } }
Example #10
Source File: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 4 votes |
private Struct processComplexContentStructParticle(XmlSchemaParticle extype, QName defaultName, Struct corbaStruct, QName schematypeName, QName extName, List<XmlSchemaAttributeOrGroupRef> list) throws Exception { String uri; if (schematypeName != null) { uri = schematypeName.getNamespaceURI(); } else { uri = defaultName.getNamespaceURI(); } // Add base as a member of this struct MemberType memberType = new MemberType(); memberType.setName(extName.getLocalPart() + "_f"); if ("anyType".equals(extName.getLocalPart())) { memberType.setIdltype(processPrimitiveType(extName).getQName()); } else { memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart())); } corbaStruct.getMember().add(memberType); // process attributes at complexContent level List<MemberType> attlist1 = processAttributesAsMembers(list, uri); for (int i = 0; i < attlist1.size(); i++) { MemberType member = attlist1.get(i); corbaStruct.getMember().add(member); } // Process members of Current Type if (extype instanceof XmlSchemaChoice) { XmlSchemaChoice choice = (XmlSchemaChoice)extype; MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName); choicemem.setAnonschematype(true); corbaStruct.getMember().add(choicemem); } else if (extype instanceof XmlSchemaSequence) { XmlSchemaSequence seq = (XmlSchemaSequence)extype; corbaStruct = processComplexContentStructSequence(corbaStruct, seq, defaultName, schematypeName); } else if (extype instanceof XmlSchemaAll) { XmlSchemaAll all = (XmlSchemaAll)extype; corbaStruct = processComplexContentStructSchemaAll(corbaStruct, all, defaultName, schematypeName); } return corbaStruct; }
Example #11
Source File: ParticleInfo.java From cxf with Apache License 2.0 | 4 votes |
private static void factoryCommon(XmlSchemaParticle particle, XmlSchema currentSchema, SchemaCollection schemaCollection, NamespacePrefixAccumulator prefixAccumulator, ParticleInfo elementInfo) { if (particle instanceof XmlSchemaElement) { XmlSchemaElement element = (XmlSchemaElement)particle; QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, currentSchema); String elementNamespaceURI = elementQName.getNamespaceURI(); boolean elementNoNamespace = "".equals(elementNamespaceURI); XmlSchema elementSchema = null; if (!elementNoNamespace) { elementSchema = schemaCollection.getSchemaByTargetNamespace(elementNamespaceURI); if (elementSchema == null) { throw new RuntimeException("Missing schema " + elementNamespaceURI); } } boolean qualified = !elementNoNamespace && XmlSchemaUtils.isElementQualified(element, true, currentSchema, elementSchema); elementInfo.xmlName = prefixAccumulator.xmlElementString(elementQName, qualified); // we are assuming here that we are not dealing, in close proximity, // with elements with identical local names and different // namespaces. elementInfo.javascriptName = elementQName.getLocalPart(); String schemaDefaultValue = element.getDefaultValue(); /* * Schema default values are carried as strings. * In javascript, for actual strings, we need quotes, but not for * numbers. The following is a trick. */ schemaDefaultValue = protectDefaultValue(schemaDefaultValue); elementInfo.defaultValue = schemaDefaultValue; factorySetupType(element, schemaCollection, elementInfo); elementInfo.isGroup = false; } else if (particle instanceof XmlSchemaChoice) { elementInfo.isGroup = true; } else if (particle instanceof XmlSchemaSequence) { elementInfo.isGroup = true; } else { // any elementInfo.any = true; elementInfo.xmlName = null; // unknown until runtime. // TODO: multiple 'any' elementInfo.javascriptName = "any"; elementInfo.type = null; // runtime for any. elementInfo.isGroup = false; } }
Example #12
Source File: ParticleInfo.java From cxf with Apache License 2.0 | 4 votes |
public XmlSchemaParticle getParticle() { return particle; }
Example #13
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 4 votes |
public static boolean isParticleArray(XmlSchemaParticle particle) { return particle.getMaxOccurs() > 1; }
Example #14
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 4 votes |
public static boolean isParticleOptional(XmlSchemaParticle particle) { return particle.getMinOccurs() == 0 && particle.getMaxOccurs() == 1; }
Example #15
Source File: DidSchemaParser.java From secure-data-service with Apache License 2.0 | 4 votes |
private List<DidNaturalKey> getNaturalKeysForEntity(XmlSchemaComplexType complexType, String keys) { List<DidNaturalKey> naturalKeys = new ArrayList<DidNaturalKey>(); StringTokenizer keysTokenizer = new StringTokenizer(keys, ","); while (keysTokenizer.hasMoreElements()) { String key = (String) keysTokenizer.nextElement(); DidNaturalKey naturalKey = new DidNaturalKey(); naturalKey.setNaturalKeyName(key); if(key.indexOf('.') != -1) { key = key.substring(0, key.indexOf('.')); } XmlSchemaParticle particle = extractParticle(complexType); if(particle == null) { particle = extractParticleWithRestriction(complexType); } Long minOccurs = parseParticleForMinOccurs(particle, key); if(minOccurs == null) { //Check the parent entity for the natural key String parent = complexType.getBaseSchemaTypeName().getLocalPart(); if(!parent.equals("ComplexObjectType")) { XmlSchemaParticle parentParticle = getParticleByType(parent); if(parentParticle != null) { minOccurs = parseParticleForMinOccurs(parentParticle, key); } } } if(minOccurs == null) { //Check the reference types to find this field, should be don only after element comparison fails minOccurs = parseRefParticleForMinOccurs(particle, key); } if(minOccurs != null && minOccurs != 0) { naturalKey.setOptional(false); } else { naturalKey.setOptional(true); } naturalKeys.add(naturalKey); } return naturalKeys; }