/** * Return the simple type for schema type. If the schema type is already * simple, just return it. If it is a complex type with simple content, * return the simple type it extends. */ static SchemaType getSimpleType(SchemaType st) { assert st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT : st + " does not have simple content."; while (! st.isSimpleType() ) st = st.getBaseType(); return st; }
static boolean hasSimpleContent(SchemaType st) { return st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT; }
public final boolean uses_invalidate_value() { SchemaType type = schemaType(); return type.isSimpleType() || type.getContentType() == SchemaType.SIMPLE_CONTENT; }
static boolean xmlTypeForPropertyIsUnion(SchemaProperty sProp) { SchemaType sType = sProp.javaBasedOnType(); return (sType.isSimpleType() && sType.getSimpleVariety() == SchemaType.UNION); }
private final boolean comparable_value_spaces(SchemaType t1, SchemaType t2) { assert(t1.getSimpleVariety() != SchemaType.UNION && t2.getSimpleVariety() != SchemaType.UNION); if (!t1.isSimpleType() && !t2.isSimpleType()) return (t1.getContentType() == t2.getContentType()); if (!t1.isSimpleType() || !t2.isSimpleType()) return false; if (t1.getSimpleVariety() == SchemaType.LIST && t2.getSimpleVariety() == SchemaType.LIST) return true; if (t1.getSimpleVariety() == SchemaType.LIST || t2.getSimpleVariety() == SchemaType.LIST) return false; return (t1.getPrimitiveType().equals(t2.getPrimitiveType())); }
static void addAnonymousTypesFromRedefinition(SchemaType sType, List result) { while (((SchemaTypeImpl)sType).isRedefinition() && (sType.getDerivationType() == SchemaType.DT_EXTENSION || sType.isSimpleType())) { sType = sType.getBaseType(); SchemaType[] newAnonTypes = sType.getAnonymousTypes(); if (newAnonTypes.length > 0) result.addAll(Arrays.asList(newAnonTypes)); } } }
return (XmlObject)ctr.newInstance(new Object[] { sType, sType.isSimpleType() ? Boolean.FALSE : Boolean.TRUE });
private boolean validateSimpleType ( SchemaType type, String value, Event event ) { if (!type.isSimpleType() && type.getContentType() != SchemaType.SIMPLE_CONTENT) { assert false; throw new RuntimeException( "Not a simple type" ); } int retState = _errorState; switch ( type.getSimpleVariety() ) { case SchemaType.ATOMIC : validateAtomicType( type, value, event );break; case SchemaType.UNION : validateUnionType( type, value, event );break; case SchemaType.LIST : validateListType( type, value, event );break; default : throw new RuntimeException( "Unexpected simple variety" ); } return retState == _errorState; }
private static String notes(SchemaType sType) { if (sType.isBuiltinType()) return " (builtin)"; if (sType.isSimpleType()) { switch (sType.getSimpleVariety()) { case SchemaType.LIST: return " (list)"; case SchemaType.UNION: return " (union)"; default: if (sType.getEnumerationValues() != null) return " (enumeration)"; return ""; } } switch (sType.getContentType()) { case SchemaType.MIXED_CONTENT: return " (mixed)"; case SchemaType.SIMPLE_CONTENT: return " (complex)"; default: return ""; } }
public static boolean validateSimpleType ( SchemaType type, String value, Collection errors, PrefixResolver prefixResolver ) { if (!type.isSimpleType() && type.getContentType() != SchemaType.SIMPLE_CONTENT) { assert false; throw new RuntimeException( "Not a simple type" ); } Validator validator = new Validator( type, null, type.getTypeSystem(), null, errors); //make only one event at the beginning and than reuse it EventImpl ev = new EventImpl(prefixResolver, value); validator.nextEvent(ValidatorListener.BEGIN, ev); validator.nextEvent(ValidatorListener.TEXT, ev); validator.nextEvent(ValidatorListener.END, ev); return validator.isValid(); }
state._isNil = isNil; if (type.isSimpleType())
return 2; if (!type1.isSimpleType() || type1.isURType()) return 2; if (!type2.isSimpleType() || type2.isURType()) return 2;
void printNestedTypeImpls(SchemaType sType, SchemaTypeSystem system) throws IOException { boolean redefinition = sType.getName() != null && sType.getName().equals(sType.getBaseType().getName()); while (sType != null) { SchemaType[] anonTypes = sType.getAnonymousTypes(); for (int i = 0; i < anonTypes.length; i++) { if (anonTypes[i].isSkippedAnonymousType()) printNestedTypeImpls(anonTypes[i], system); else printInnerTypeImpl(anonTypes[i], system, true); } // For redefinition by extension, go ahead and print the anonymous // types in the base if (!redefinition || (sType.getDerivationType() != SchemaType.DT_EXTENSION && !sType.isSimpleType())) break; sType = sType.getBaseType(); } } }
void printNestedInnerTypes(SchemaType sType, SchemaTypeSystem system) throws IOException { boolean redefinition = sType.getName() != null && sType.getName().equals(sType.getBaseType().getName()); while (sType != null) { SchemaType[] anonTypes = sType.getAnonymousTypes(); for (int i = 0; i < anonTypes.length; i++) { if (anonTypes[i].isSkippedAnonymousType()) printNestedInnerTypes(anonTypes[i], system); else printInnerType(anonTypes[i], system); } // For redefinition other than by extension for complex types, go ahead and print // the anonymous types in the base if (!redefinition || (sType.getDerivationType() != SchemaType.DT_EXTENSION && !sType.isSimpleType())) break; sType = sType.getBaseType(); } }
if (stype.isSimpleType() || stype.isURType())
void printConstructor(SchemaType sType, String shortName) throws IOException { emit(""); emit("public " + shortName + "(org.apache.xmlbeans.SchemaType sType)"); startBlock(); emit("super(sType" + (sType.getSimpleVariety() == SchemaType.NOT_SIMPLE ? "": ", " + !sType.isSimpleType()) + ");"); endBlock(); if (sType.getSimpleVariety() != SchemaType.NOT_SIMPLE) { emit(""); emit("protected " + shortName + "(org.apache.xmlbeans.SchemaType sType, boolean b)"); startBlock(); emit("super(sType, b);"); endBlock(); } }
private boolean validate_immutable(XmlOptions options) { Collection errorListener = options == null ? null : (Collection)options.get(XmlOptions.ERROR_LISTENER); XmlErrorWatcher watcher = new XmlErrorWatcher(errorListener); if (!(schemaType().isSimpleType() || options != null && options.hasOption(XmlOptions.VALIDATE_TEXT_ONLY))) { // cannot have any required attributes or elements SchemaProperty[] properties = schemaType().getProperties(); for (int i = 0; i < properties.length; i++) { if (properties[i].getMinOccurs().signum() > 0) { // KHK: error code? if (properties[i].isAttribute()) watcher.add(XmlError.forObject(XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$MISSING_REQUIRED_ATTRIBUTE, new Object[]{QNameHelper.pretty(properties[i].getName()), }, this)); else watcher.add(XmlError.forObject(XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$MISSING_ELEMENT, new Object[]{properties[i].getMinOccurs(), QNameHelper.pretty(properties[i].getName()), }, this)); } } if (schemaType().getContentType() != SchemaType.SIMPLE_CONTENT) return !watcher.hasError(); // don't validate non-simple-content } String text = (String)_textsource; if (text == null) text = ""; validate_simpleval(text, new ImmutableValueValidationContext(watcher, this)); return !watcher.hasError(); }
boolean emptyContent, boolean canApplyDefault ) if (!type.isSimpleType() && type.getContentType() != SchemaType.SIMPLE_CONTENT) else if (type.isSimpleType()) errorCode = XmlErrorCodes.ELEM_LOCALLY_VALID$FIXED_VALID_SIMPLE_TYPE; else
if (!baseType.isSimpleType() && baseType.getContentType() != SchemaType.SIMPLE_CONTENT)
if (sType.isSimpleType())