/** * Return true if a simple type is a straightforward XML Schema representation of an enumeration. * If we discover schemas that are 'enum-like' with more complex structures, we might * make this deal with them. * @param type Simple type, possible an enumeration. * @return true for an enumeration. */ public static boolean isEumeration(XmlSchemaSimpleType type) { XmlSchemaSimpleTypeContent content = type.getContent(); if (!(content instanceof XmlSchemaSimpleTypeRestriction)) { return false; } XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; List<XmlSchemaFacet> facets = restriction.getFacets(); for (XmlSchemaFacet facet : facets) { if (!(facet instanceof XmlSchemaEnumerationFacet)) { return false; } } return true; }
+ xsdSimpleType.getName()); QName typeName = xsdSimpleType.getQName(); if (typeName != null && XsdConstants.XSD_NS.equals(typeName.getNamespaceURI())) { if (_log.isDebugEnabled()) { _log.debug("getPrimitiveType ended for type = " + xsdSimpleType.getName()); _log.debug(" PrimitiveType = " + typeName); if (xsdSimpleType.getContent() != null) { if (xsdSimpleType.getContent() instanceof XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) xsdSimpleType .getContent(); if (_log.isDebugEnabled()) { _log.debug("getPrimitiveType ended for type = " + xsdSimpleType.getName()); _log.debug(" PrimitiveType = " + typeName); } else if (xsdSimpleType.getContent() instanceof XmlSchemaSimpleTypeList) { .getContent(); return getPrimitiveType(schema, listType.getItemType()); } else if (xsdSimpleType.getContent() instanceof XmlSchemaSimpleTypeUnion) { _log.warn(xsdSimpleType.getName() + " is a union. Processing first type in the union."); XmlSchemaSimpleTypeUnion simpleUnion = (XmlSchemaSimpleTypeUnion) xsdSimpleType
private XmlSchemaSimpleType duplicateXmlSchemaSimpleType(Scope newScope) { XmlSchemaSimpleType oldSimpleType = (XmlSchemaSimpleType) getSchemaType(); XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, oldSimpleType.isTopLevel()); simpleType.setContent(oldSimpleType.getContent()); simpleType.setName(newScope.toString()); return simpleType; }
private void addSimpleType(XmlSchema schema,String typeName){ XmlSchemaSimpleType type; type = new XmlSchemaSimpleType(schema); type.setName(typeName); schema.addType(type); } public XmlSchema read(Reader r, ValidationEventHandler veh) {
/** * @param simpleType * @param typeMap * @param metainf * @return Returns String. * @throws SchemaCompilationException */ public String write(XmlSchemaSimpleType simpleType, Map<QName,String> typeMap, Map<QName,String> groupTypeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException { try { QName qName = simpleType.getQName(); if (qName == null) { qName = (QName) simpleType.getMetaInfoMap().get(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME); } metainf.addtStatus(qName, SchemaConstants.SIMPLE_TYPE_OR_CONTENT); return process(qName, metainf, typeMap, groupTypeMap, true, false); } catch (Exception e) { throw new SchemaCompilationException(e); } }
private void visitAnonBoundedString() { XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true); simpleType.setName(stringScopedName.toString()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); maxLengthFacet.setValue(boundNode.toString()); restriction.getFacets().add(maxLengthFacet); simpleType.setContent(restriction); anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); anonstring.setBound(Long.parseLong(boundNode.toString())); anonstring.setType(simpleType.getQName()); anonwstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); anonwstring.setBound(Long.parseLong(boundNode.toString())); anonwstring.setType(simpleType.getQName());
private static void processXmlSchemaSimpleType(XmlSchemaSimpleType xmlSchema, JavaMethod jm, JavaParameter parameter, MessagePartInfo part) { if (xmlSchema.getContent() instanceof XmlSchemaSimpleTypeList && (!part.isElement() || !jm.isWrapperStyle())) { parameter.annotate(new XmlListAnotator(jm.getInterface())); } if (Constants.XSD_HEXBIN.equals(xmlSchema.getQName()) && (!part.isElement() || !jm.isWrapperStyle())) { parameter.annotate(new XmlJavaTypeAdapterAnnotator(jm.getInterface(), HexBinaryAdapter.class)); } }
@Override public void writeSchema(XmlSchema root) { XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true); simple.setName(getSchemaType().getLocalPart()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); simple.setContent(restriction); Object[] constants = getTypeClass().getEnumConstants(); List<XmlSchemaFacet> facets = restriction.getFacets(); for (Object constant : constants) { XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet(); f.setValue(getValue(constant)); facets.add(f); } }
XmlSchemaSimpleTypeContent content = simpleType.getContent(); QName parentSimpleTypeQname = simpleType.getQName(); if (parentSimpleTypeQname == null) { parentSimpleTypeQname = (QName) simpleType.getMetaInfoMap(). get(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME); i++; XmlSchemaSimpleType unionSimpleType = xmlSchemaObject; childQname = unionSimpleType.getQName(); if (childQname == null) { itemTypeQName = listSimpleType.getQName(); if (itemTypeQName == null) {
+ xsdSimpleType.getName()); _log.debug(" XmlSchemaType QName = " + xsdSimpleType.getQName()); _log.debug(" XmlSchemaType BaseSchemaType = " + xsdSimpleType.getBaseSchemaType()); _log.debug(" XmlSchemaType DataType = " + xsdSimpleType.getDataType()); _log.debug(" XmlSchemaType DeriveBy = " + xsdSimpleType.getDeriveBy()); if (cobolType == null) { throw new XsdMappingException("Unsupported XML Schema type " + xsdSimpleType.getQName()); if (xsdSimpleType.getContent() instanceof XmlSchemaSimpleTypeList) { elc.setAttribute(CobolMarkup.MIN_OCCURS, "1"); elc.setAttribute(CobolMarkup.MAX_OCCURS, + xsdSimpleType.getName());
QName schematypeName = null; if (stype.getQName() == null) { schematypeName = defaultName; name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type"); } else { schematypeName = checkPrefix(stype.getQName()); if (schematypeName == null) { schematypeName = stype.getQName(); if (stype.getParent().getTargetNamespace().equals(W3CConstants.NU_SCHEMA_XSD)) { QName stypeName = createQNameXmlSchemaNamespace(stype.getName()); corbaTypeImpl = getLocalType(stypeName); } else if (stype.getContent() instanceof XmlSchemaSimpleTypeRestriction) { corbaTypeImpl = processSimpleRestrictionType(stype, name, schematypeName, anonymous); } else if (stype.getContent() instanceof XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList ltype = (XmlSchemaSimpleTypeList)stype.getContent(); CorbaType itemType = null; if (ltype.getItemType() != null) { itemType.getQName(), null, 0, false); } else if (stype.getContent() == null) { QName stypeName = createQNameXmlSchemaNamespace(stype.getName()); corbaTypeImpl = getLocalType(stypeName); } else {
+ xsdSimpleType.getName()); if (xsdSimpleType.getName() != null) { return; XmlSchemaSimpleTypeContent content = xsdSimpleType.getContent(); if (content == null || !(content instanceof XmlSchemaSimpleTypeRestriction)) { + xsdSimpleType.getName());
/** * Writes a complex type * * @param simpleType * @param metaInfHolder * @throws SchemaCompilationException */ private void writeSimpleType(XmlSchemaSimpleType simpleType, BeanWriterMetaInfoHolder metaInfHolder) throws SchemaCompilationException { writer.write(simpleType, processedTypemap, processedGroupTypeMap, metaInfHolder); processedTypeMetaInfoMap.put(simpleType.getQName(), metaInfHolder); }
if (simpleType.getQName() != null) { if (processedTypemap.containsKey(simpleType.getQName()) || baseSchemaTypeMap.containsKey(simpleType.getQName())) { return; fullyQualifiedClassName = writer.makeFullyQualifiedClassName(simpleType.getQName()); processedTypemap.put(simpleType.getQName(), fullyQualifiedClassName); } else { simpleType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME, fakeQname); simpleType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, fullyQualifiedClassName); if (simpleType.getQName() == null) { this.processedAnonymousComplexTypesMap.put(xsElt, metaInfHolder); QName fakeQname; } else { fakeQname = qname; simpleType.setName(fakeQname.getLocalPart()); changedSimpleTypeSet.add(simpleType); simpleType.setSourceURI(fakeQname.getNamespaceURI()); metaInfHolder.setOwnQname(simpleType.getQName()); if (fullyQualifiedClassName != null) { metaInfHolder.setOwnClassName(fullyQualifiedClassName);
@Nonnull protected XmlSchemaType createNumberSchemaType(NumberResolvedType numberTypeDefinition, QName baseType) { final XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, false); final XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction(); content.setBaseTypeName(baseType); if (numberTypeDefinition.getMinimum() != null) { final XmlSchemaMinInclusiveFacet minLength = new XmlSchemaMinInclusiveFacet(); minLength.setValue(numberTypeDefinition.getMinimum()); content.getFacets().add(minLength); } if (numberTypeDefinition.getMaximum() != null) { final XmlSchemaMaxInclusiveFacet maxLength = new XmlSchemaMaxInclusiveFacet(); maxLength.setValue(numberTypeDefinition.getMaximum()); content.getFacets().add(maxLength); } simpleType.setContent(content); return simpleType; }
XmlSchemaType type = schemas.getTypeByQName(typeName); if (isList && type instanceof XmlSchemaSimpleType) { XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(type.getParent(), false); XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList(); XmlSchemaSimpleType stype = (XmlSchemaSimpleType)type; list.setItemTypeName(stype.getQName()); simpleType.setContent(list); part.setXmlSchema(simpleType); if (part.getConcreteName() == null) {
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema); if (simpleEl.hasAttribute("name")) { simpleType.name = simpleEl.getAttribute("name"); | finalstr.equalsIgnoreCase("#all")) simpleType.setFinal(new XmlSchemaDerivationMethod( Constants.BlockConstants.ALL)); else simpleType.setFinal(new XmlSchemaDerivationMethod(finalstr)); XmlSchemaAnnotation simpleTypeAnnotation = handleAnnotation(simpleTypeAnnotationEl); simpleType.setAnnotation(simpleTypeAnnotation);
wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas); XmlSchemaType objectType = new XmlSchemaSimpleType(wsaSchema, true); objectType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME); setSchemaType(objectType);
/** * Completes the schema compilation process by writing the * mappers and the classes in a batch if needed * * @throws SchemaCompilationException */ private void finalizeSchemaCompilation() throws SchemaCompilationException { //write the extension mapping class writer.writeExtensionMapper( processedTypeMetaInfoMap.values().toArray( new BeanWriterMetaInfoHolder[processedTypeMetaInfoMap.size()])); if (options.isWrapClasses()) { writer.writeBatch(); } // resets the changed types for (XmlSchemaComplexType xmlSchemaComplexType : changedComplexTypeSet) { xmlSchemaComplexType.setName(null); } for (XmlSchemaSimpleType xmlSchemaSimpleType : changedSimpleTypeSet) { xmlSchemaSimpleType.setName(null); } for (XmlSchemaElement xmlSchemaElement : changedElementSet) { xmlSchemaElement.setSchemaTypeName(null); } }
private void visitBoundedString() { XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true); simpleType.setName(stringScopedName.toString()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); maxLengthFacet.setValue(boundNode.toString()); restriction.getFacets().add(maxLengthFacet); simpleType.setContent(restriction); anonstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName)); anonstring.setBound(Long.parseLong(boundNode.toString())); anonstring.setType(simpleType.getQName()); anonwstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName)); anonwstring.setBound(Long.valueOf(boundNode.toString())); anonwstring.setType(simpleType.getQName()); alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); alias.setBasetype(anon.getQName()); alias.setType(simpleType.getQName()); alias.setRepositoryID(stringScopedName.toIDLRepositoryID());