You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by kk...@apache.org on 2005/03/01 23:31:05 UTC
svn commit: r155831 - in xmlbeans/trunk/src:
typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
xmlpublic/org/apache/xmlbeans/message.properties
Author: kkrouse
Date: Tue Mar 1 14:31:04 2005
New Revision: 155831
URL: http://svn.apache.org/viewcvs?view=rev&rev=155831
Log:
- check enumeration value is valid
- fixed some facet error messages
Modified:
xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties
Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java?view=diff&r1=155830&r2=155831
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java Tue Mar 1 14:31:04 2005
@@ -22,6 +22,7 @@
import javax.xml.namespace.QName;
import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
import org.apache.xmlbeans.impl.regex.RegularExpression;
+import org.apache.xmlbeans.impl.regex.ParseException;
import org.apache.xmlbeans.impl.common.QNameHelper;
import org.apache.xmlbeans.XmlErrorCodes;
import org.apache.xmlbeans.XmlObject;
@@ -684,7 +685,9 @@
XmlCursor cur = restriction.newCursor();
for (boolean more = cur.toFirstChild(); more; more = cur.toNextSibling())
{
- int code = translateFacetCode(cur.getName());
+ QName facetQName = cur.getName();
+ String facetName = facetQName.getLocalPart();
+ int code = translateFacetCode(facetQName);
if (code == -1)
continue;
@@ -693,7 +696,7 @@
if (!facetAppliesToType(code, baseImpl))
{
state.error(XmlErrorCodes.FACETS_APPLICABLE,
- new Object[] { facet.newCursor().getName().getLocalPart(), QNameHelper.pretty(baseImpl.getName()) }, facet);
+ new Object[] { facetName, QNameHelper.pretty(baseImpl.getName()) }, facet);
continue;
}
if (seenFacet[code] && !isMultipleFacet(code))
@@ -715,13 +718,12 @@
XmlInteger len = StscTranslator.buildNnInteger(facet.getValue());
if (len == null)
{
- // KHK: s4s
state.error("Must be a nonnegative integer", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
continue;
}
if (fixedFacets[code] && !myFacets[code].valueEquals(len))
{
- state.error(XmlErrorCodes.FACET_FIXED, null, facet);
+ state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
continue;
}
myFacets[code] = len;
@@ -742,7 +744,7 @@
}
if (fixedFacets[code] && !myFacets[code].valueEquals(mlen))
{
- state.error(XmlErrorCodes.FACET_FIXED, null, facet);
+ state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
continue;
}
if (myFacets[SchemaType.FACET_MAX_LENGTH] != null)
@@ -773,7 +775,7 @@
}
if (fixedFacets[code] && !myFacets[code].valueEquals(dig))
{
- state.error(XmlErrorCodes.FACET_FIXED, null, facet);
+ state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
continue;
}
if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
@@ -793,7 +795,7 @@
}
if (fixedFacets[code] && !myFacets[code].valueEquals(fdig))
{
- state.error(XmlErrorCodes.FACET_FIXED, null, facet);
+ state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
continue;
}
if (myFacets[SchemaType.FACET_FRACTION_DIGITS] != null)
@@ -801,6 +803,11 @@
if (fdig.compareValue(myFacets[SchemaType.FACET_FRACTION_DIGITS]) > 0)
state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_RESTRICTION, null, facet);
}
+ if (myFacets[SchemaType.FACET_TOTAL_DIGITS] != null)
+ {
+ if (fdig.compareValue(myFacets[SchemaType.FACET_TOTAL_DIGITS]) > 0)
+ state.error(XmlErrorCodes.DATATYPE_FRACTION_DIGITS_LE_TOTAL_DIGITS, null, facet);
+ }
myFacets[code] = fdig;
break;
@@ -820,13 +827,13 @@
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", XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
+ state.error("Must be valid value in base type: " + e.getMessage(), XmlErrorCodes.FACET_VALUE_MALFORMED, facet);
// BUGBUG: if there are actual schemas that redefine min/maxExclusive,
// they will need this rule relaxed for them!!
@@ -834,7 +841,7 @@
}
if (fixedFacets[code] && !myFacets[code].valueEquals(limit))
{
- state.error(XmlErrorCodes.FACET_FIXED, null, facet);
+ state.error(XmlErrorCodes.FACET_FIXED, new Object[] { facetName }, facet);
continue;
}
if (myFacets[code] != null)
@@ -872,13 +879,13 @@
XmlObject enumval;
try
{
- enumval = baseImpl.newValue(facet.getValue());
+ enumval = baseImpl.newValue(facet.getValue(), true);
// enumval.set(facet.getValue());
// ((XmlObjectBase)enumval).setImmutable();
}
catch (XmlValueOutOfRangeException e)
{
- state.error(XmlErrorCodes.DATATYPE_ENUM_RESTRICTION, null, facet);
+ state.error(XmlErrorCodes.DATATYPE_ENUM_RESTRICTION, new Object[] { facet.getValue().getStringValue(), e.getMessage() }, facet);
continue;
}
if (enumeratedValues == null)
@@ -889,7 +896,7 @@
case SchemaType.FACET_PATTERN:
RegularExpression p;
try { p = new RegularExpression(facet.getValue().getStringValue(), "X"); }
- catch (org.apache.xmlbeans.impl.regex.ParseException e)
+ catch (ParseException e)
{
state.error(XmlErrorCodes.PATTERN_REGEX, new Object[] { facet.getValue().getStringValue(), e.getMessage() }, facet);
continue;
Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties?view=diff&r1=155830&r2=155831
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties Tue Mar 1 14:31:04 2005
@@ -113,10 +113,10 @@
Datatype Valid
cvc-datatype-valid.1.1 = \
-{0} value ''{1}'' does not match pattern for ''{2}''
+{0} value ''{1}'' does not match pattern for {2}
cvc-datatype-valid.1.1b = \
-{0} value does not match pattern for ''{1}''
+{0} value does not match pattern for {1}
cvc-datatype-valid.1.2.3 = \
union value ''{0}'' does not match any members of ''{1}''
@@ -166,16 +166,16 @@
#The value ''{0}'' does not equal the fixed value ''{1}'' of ''{2}''
cvc-enumeration-valid = \
-{0} value ''{1}'' is not a valid enumeration value for ''{2}''
+{0} value ''{1}'' is not a valid enumeration value for {2}
cvc-enumeration-valid.b = \
-{0} value is not a valid enumeration value for ''{1}''
+{0} value is not a valid enumeration value for {1}
cvc-facet-valid = \
Facet Valid
cvc-fractionDigits-valid = \
-Decimal fractional digits ({0}) of value ''{1}'' does not match fractionDigits facet ({2}) for ''{3}''
+Decimal fractional digits ({0}) of value ''{1}'' does not match fractionDigits facet ({2}) for {3}
cvc-id.2 = \
Duplicate ID value ''{0}''
@@ -193,49 +193,49 @@
Length Valid
cvc-length-valid.1.1 = \
-{0} length ({1}) does not match length facet ({2}) for ''{3}''
+{0} length ({1}) does not match length facet ({2}) for {3}
cvc-length-valid.1.2 = \
-{0} encoded data has {1} bytes but requires {2} bytes required by length facet for ''{3}''
+{0} encoded data has {1} bytes but requires {2} bytes required by length facet for {3}
cvc-length-valid.2 = \
-List value ''{0}'' has {1} items but requires {2} items per length facet for ''{3}''
+List value ''{0}'' has {1} items but requires {2} items per length facet for {3}
cvc-maxExclusive-valid = \
-{0} value ({1}) is greater than or equal to maxExclusive facet ({2}) for ''{3}''
+{0} value ({1}) is greater than or equal to maxExclusive facet ({2}) for {3}
cvc-maxInclusive-valid = \
-{0} value ({1}) is greater than maxInclusive facet ({2}) for ''{3}''
+{0} value ({1}) is greater than maxInclusive facet ({2}) for {3}
cvc-maxLength-valid = \
maxLength Valid
cvc-maxLength-valid.1.1 = \
-{0} length ({0}) is greater than maxLength facet ({1}) for ''{2}''
+{0} length ({0}) is greater than maxLength facet ({1}) for {2}
cvc-maxLength-valid.1.2 = \
-{0} encoded data has only {1} bytes, more than maxLength facet ({2}) for ''{3}''
+{0} encoded data has only {1} bytes, more than maxLength facet ({2}) for {3}
cvc-maxLength-valid.2 = \
-List value ''{0}'' has {1} items, more than maxLength facet ({2}) for ''{3}''
+List value ''{0}'' has {1} items, more than maxLength facet ({2}) for {3}
cvc-minExclusive-valid = \
-{0} value ({1}) is less than or equal to minExclusive facet ({2}) for ''{3}''
+{0} value ({1}) is less than or equal to minExclusive facet ({2}) for {3}
cvc-minInclusive-valid = \
-{0} value ({1}) is less than minInclusive facet ({2}) for ''{3}''
+{0} value ({1}) is less than minInclusive facet ({2}) for {3}
cvc-minLength-valid = \
minLength Valid
cvc-minLength-valid.1.1 = \
-{0} length ({0}) is less than minLength facet ({1}) for ''{2}''
+{0} length ({0}) is less than minLength facet ({1}) for {2}
cvc-minLength-valid.1.2 = \
-{0} encoded data has only {1} bytes, fewer than minLength facet ({2}) for ''{3}''
+{0} encoded data has only {1} bytes, fewer than minLength facet ({2}) for {3}
cvc-minLength-valid.2 = \
-List value ''{0}'' has only {1} items, fewer than minLength facet ({2}) for ''{3}''
+List value ''{0}'' has only {1} items, fewer than minLength facet ({2}) for {3}
cvc-model-group = \
Element Sequence Valid
@@ -259,7 +259,7 @@
String Valid
cvc-totalDigits-valid = \
-The total digits ({0}) of value ''{1}'' is greater than the totalDigits facet ({2}) for ''{3}''
+The total digits ({0}) of value ''{1}'' is greater than the totalDigits facet ({2}) for {3}
cvc-type = \
Element Locally Valid (Type)
@@ -629,10 +629,10 @@
enumeration facet value required for NOTATION
enumeration-valid-restriction = \
-Enumerated value invalid in base type.
+Enumerated value ''{0}'' invalid: {1}
fractionDigits-totalDigits = \
-fractionDigits less than or equal to totalDigits
+fractionDigits must be less than or equal to totalDigits
fractionDigits-valid-restriction = \
Larger than prior fractionDigits.
@@ -901,7 +901,7 @@
Attribute is prohibited: {0}
facet-fixed = \
-This facet is fixed and cannot be overridden.
+The facet ''{0}'' is fixed and cannot be overridden.
pattern-regex = \
The regular expression ''{0}'' is malformed: {1}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org