Skip to content
Browse files

Integrate r155974 and r155831 in the V1 branch.

git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/branches/1.x@160953 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 5906dd0 commit bb6956125e254b84f87bdd5c4833c85d09ddeb9b Radu Preotiuc committed
View
6 bin/validate
@@ -4,7 +4,7 @@
#
# Validates an instance against a schema.
-CP=
+cp=
if [ -e $XMLBEANS_HOME/build/ar/xbean.jar ]; then
cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar;
@@ -14,8 +14,8 @@ fi
case "`uname`" in
CYGWIN*)
- CP=`cygpath -w -p $CP`
+ cp=`cygpath -w -p $cp`
;;
esac
-java -classpath $CP org.apache.xmlbeans.impl.tool.InstanceValidator $*
+java -classpath $cp org.apache.xmlbeans.impl.tool.InstanceValidator $*
View
9 src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
@@ -742,6 +742,11 @@ static void resolveFacets(SchemaTypeImpl sImpl, XmlObject restriction, SchemaTyp
if (fdig.compareValue(myFacets[SchemaType.FACET_FRACTION_DIGITS]) > 0)
state.error("Larger than prior fractionDigits", XmlErrorContext.FACET_VALUE_MALFORMED, facet);
}
+ if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
+ {
+ if (fdig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
+ state.error("Larget than prior totalDigits", XmlErrorContext.FACET_VALUE_MALFORMED, facet);
+ }
myFacets[code] = fdig;
break;
@@ -761,13 +766,13 @@ static void resolveFacets(SchemaTypeImpl sImpl, XmlObject restriction, SchemaTyp
XmlAnySimpleType limit;
try
{
- limit = baseImpl.newValue(facet.getValue());
+ limit = baseImpl.newValue(facet.getValue(), true);
}
catch (XmlValueOutOfRangeException e)
{
// note: this guarantees that the limit is a valid number in the
// base data type!!
- state.error("Must be valid value in base type", XmlErrorContext.FACET_VALUE_MALFORMED, facet);
+ state.error("Must be valid value in base type" + e.getMessage(), XmlErrorContext.FACET_VALUE_MALFORMED, facet);
// BUGBUG: if there are actual schemas that redefine min/maxExclusive,
// they will need this rule relaxed for them!!
View
11 src/typeimpl/org/apache/xmlbeans/impl/values/JavaStringEnumerationHolderEx.java
@@ -44,17 +44,6 @@ protected void set_text(String s)
public static void validateLexical(String v, SchemaType sType, ValidationContext context)
{
JavaStringHolderEx.validateLexical(v, sType, context);
-
- if (sType.hasStringEnumValues())
- {
- if (sType.enumForString(v) == null)
- {
- if (context != null)
- {
- context.invalid("String '" + v + "' is not a valid enumerated value for " + QNameHelper.readable(sType));
- }
- }
- }
}
protected void set_nil()
View
18 src/typeimpl/org/apache/xmlbeans/impl/values/JavaStringHolderEx.java
@@ -17,6 +17,7 @@
import org.apache.xmlbeans.SchemaType;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlAnySimpleType;
import org.apache.xmlbeans.impl.common.ValidationContext;
import org.apache.xmlbeans.impl.common.QNameHelper;
@@ -103,6 +104,23 @@ public static void validateLexical(String v, SchemaType sType, ValidationContext
return;
}
}
+
+ // enumeration
+ // NOTE: can't use .hasStringEnumValues() or .enumForString()
+ // here since we may be validating against a string enum value
+ // during StscSimpleTypeResolver.resolveFacets() and the string
+ // enum table hasn't been constructed yet.
+ XmlAnySimpleType[] vals = sType.getEnumerationValues();
+ if (vals != null)
+ {
+ for (int i = 0; i < vals.length; i++)
+ {
+ if (v.equals(vals[i].getStringValue()))
+ return;
+ }
+ context.invalid("String value '" + v + "' is not a valid enumeration " +
+ "value for " + QNameHelper.readable(sType));
+ }
}
protected void validate_simpleval(String lexical, ValidationContext ctx)

0 comments on commit bb69561

Please sign in to comment.
Something went wrong with that request. Please try again.