@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); } }
private boolean isEnumeration(XmlSchemaSimpleTypeRestriction restriction) { if ((restriction == null) || (restriction.getFacets().isEmpty()) || (restriction.getBaseTypeName() == null)) { return false; } for (XmlSchemaFacet facet : restriction.getFacets()) { if (facet instanceof XmlSchemaEnumerationFacet) { return true; } } return false; }
/** * 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; }
.getContent(); QName baseName = checkPrefix(restrictionType.getBaseTypeName()); for (XmlSchemaFacet val : restrictionType.getFacets()) { if (val instanceof XmlSchemaMaxLengthFacet) { maxLength = val.getValue().toString(); corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName); } else { if (restrictionType.getBaseType() != null) { corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false); } else {
XmlSchema.SCHEMA_NS, "restriction")) != null) { XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setAnnotation(restAnnotation);
if (restriction.getBaseType() == null) { typeName = restriction.getBaseTypeName(); if (typeName != null) { if (XsdConstants.XSD_NS.equals(typeName return getPrimitiveType(schema, restriction.getBaseType());
XmlSchemaSimpleTypeContent content = stype.getContent(); if (content instanceof XmlSchemaSimpleTypeRestriction) { QName tname = ((XmlSchemaSimpleTypeRestriction)content).getBaseTypeName(); if (SCHEMA_NAMESPACE.equals(tname.getNamespaceURI())) { format = (FormatElement)simpleTypeMap.get(tname);
/** * 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; }
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) xsdSimpleType .getContent(); if (restriction.getFacets() != null) { XmlSchemaObjectCollection collection = restriction.getFacets(); for (Iterator < XmlSchemaObject > i = collection.getIterator(); i .hasNext();) { if (restriction.getBaseType() == null) { QName typeName = restriction.getBaseTypeName(); if (typeName != null && !XsdConstants.XSD_NS.equals(typeName getFacets(schema, restriction.getBaseType(), facets);
XmlSchema.SCHEMA_NS, "restriction")) != null) { XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setAnnotation(restAnnotation);
XmlSchemaSimpleTypeContent content = stype.getContent(); if (content instanceof XmlSchemaSimpleTypeRestriction) { QName tname = ((XmlSchemaSimpleTypeRestriction)content).getBaseTypeName(); if (SCHEMA_NAMESPACE.equals(tname.getNamespaceURI())) { format = (FormatElement)simpleTypeMap.get(tname);
@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); } }
} else if (content instanceof XmlSchemaSimpleTypeRestriction) { final XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; typeInfo.simpleBaseType = restriction.getBaseTypeName(); for (final Iterator iterator = restriction.getFacets().getIterator(); iterator.hasNext(); ) { if (iterator.next() instanceof XmlSchemaEnumerationFacet) { typeInfo.enumType = true;
/** * 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; }
new XmlSchemaSimpleTypeRestriction(); XmlSchemaAnnotation restAnnotation = handleAnnotation(restAnnotationEl); restriction.setAnnotation(restAnnotation);
@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; }
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) xsdSimpleType .getContent(); if (restriction != null && restriction.getBaseTypeName() != null) { QName xsdTypeName = restriction.getBaseTypeName(); List < XmlSchemaFacet > facets = restriction.getFacets(); if (xsdTypeName.equals(Constants.XSD_STRING)) { return getCobolAlphanumType(facets);
/** * 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; }
@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; }
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) xsdType .getContent(); if (restriction != null && restriction.getBaseTypeName() != null) { QName xsdTypeName = restriction.getBaseTypeName(); if (restriction.getFacets() == null) { throw new Xsd2AvroTranslatorException( "Binary type without facets in " + avroFieldName); avroType.put("type", "fixed"); avroType.put("name", StringUtils.capitalize(avroFieldName)); for (XmlSchemaObject facet : restriction.getFacets()) { if (facet instanceof XmlSchemaMaxLengthFacet) { XmlSchemaMaxLengthFacet xsef = (XmlSchemaMaxLengthFacet) facet; if (restriction.getFacets() == null) { throw new Xsd2AvroTranslatorException( "Decimal type without facets in " + avroFieldName); avroType.put("type", "bytes"); avroType.put("logicalType", "decimal"); for (XmlSchemaFacet facet : restriction.getFacets()) { if (facet instanceof XmlSchemaTotalDigitsFacet) { avroType.put("precision",