Author: mukulg
Date: Wed May 4 13:45:45 2011
New Revision: 1099444
URL: http://svn.apache.org/viewvc?rev=1099444&view=rev
Log:
further to implementation of error code st-props-correct.1 (for reporting
errors on use of special simple types in xs:list & xs:union) in an previous
commit, i'm refining that logic a bit with more context information in related
error messages. also doing little bit of refactoring.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1099444&r1=1099443&r2=1099444&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
Wed May 4 13:45:45 2011
@@ -308,7 +308,7 @@
# We're using sch-props-correct.2 instead of the old src-redefine.1
# src-redefine.1 = src-redefine.1: The component ''{0}'' is begin
redefined, but its corresponding component isn't in the schema document being
redefined (with namespace ''{2}''), but in a different document, with namespace
''{1}''.
sch-props-correct.2 = sch-props-correct.2: A schema cannot contain two
global components with the same name; this schema contains two occurrences of
''{0}''.
- st-props-correct.1 = st-props-correct.1: ''itemType'' of xs:list and
''memberTypes'' of xs:union cannot refer to special types, xs:anyAtomicType or
xs:anySimpleType.
+ st-props-correct.1 = st-props-correct.1: ''itemType'' of xs:list and
''memberTypes'' of xs:union cannot refer to special types, xs:anyAtomicType or
xs:anySimpleType. The simpleType ancestor ''{0}'' of this ''{1}'' violates this
constraint.
st-props-correct.2 = st-props-correct.2: Circular definitions have
been detected for simple type ''{0}''. This means that ''{0}'' is contained in
its own type hierarchy, which is an error.
st-props-correct.3 = st-props-correct.3: Error for type ''{0}''. The
value of '{'final'}' of the '{'base type definition'}', ''{1}'', forbids
derivation by restriction.
totalDigits-valid-restriction = totalDigits-valid-restriction: In the
definition of {2}, the value ''{0}'' for the facet ''totalDigits'' is invalid,
because it must be <= the value for ''totalDigits'' which was set to ''{1}'' in
one of the ancestor types.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java?rev=1099444&r1=1099443&r2=1099444&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Wed May 4 13:45:45 2011
@@ -29,6 +29,7 @@ import org.apache.xerces.impl.xs.SchemaS
import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.impl.xs.util.XSTypeHelper;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xs.XSConstants;
@@ -303,26 +304,22 @@ class XSDSimpleTypeTraverser extends XSD
}
}
- if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
list && baseValidator != null && isSpecialSimpleType(baseValidator)) {
- reportSchemaError("st-props-correct.1", new Object[0], child);
- }
-
// get types from "memberTypes" attribute
ArrayList dTValidators = null;
XSSimpleType dv = null;
+ XSSimpleType[] memberTypeDvList = null;
XSObjectList dvs;
if (union && memberTypes != null && memberTypes.size() > 0) {
int size = memberTypes.size();
+ memberTypeDvList = new XSSimpleType[size];
dTValidators = new ArrayList(size);
// for each qname in the list
for (int i = 0; i < size; i++) {
// get the type decl
dv = findDTValidator(child, name,
(QName)memberTypes.elementAt(i),
XSConstants.DERIVATION_UNION, schemaDoc);
+ memberTypeDvList[i] = dv;
if (dv != null) {
- if (fSchemaHandler.fSchemaVersion ==
Constants.SCHEMA_VERSION_1_1 && isSpecialSimpleType(dv)) {
- reportSchemaError("st-props-correct.1", new Object[0],
child);
- }
// if it's a union, expand it
// In XML Schema 1.1, we do not expand
if (dv.getVariety() == XSSimpleType.VARIETY_UNION &&
@@ -454,6 +451,19 @@ class XSDSimpleTypeTraverser extends XSD
}
}
+ if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ if (list && baseValidator != null &&
XSTypeHelper.isSpecialSimpleType(baseValidator)) {
+ reportSchemaError("st-props-correct.1", new Object[]
{((XSSimpleTypeDecl)newDecl).getTypeName(), "xs:list"}, child);
+ }
+ if (union && memberTypeDvList != null) {
+ for (int memTypeIdx = 0; memTypeIdx < memberTypeDvList.length;
memTypeIdx++) {
+ if
(XSTypeHelper.isSpecialSimpleType(memberTypeDvList[memTypeIdx])) {
+ reportSchemaError("st-props-correct.1", new Object[]
{((XSSimpleTypeDecl)newDecl).getTypeName(), "xs:union"}, child);
+ }
+ }
+ }
+ }
+
// XML Schema 1.1
// Set context information
final int localValidatorsSize = localValidators.size();
@@ -584,15 +594,4 @@ class XSDSimpleTypeTraverser extends XSD
return null;
}
- /*
- * Check if a simpleType definition is one of special types (i.e
xs:anyAtomicType or xs:anySimpleType).
- */
- private boolean isSpecialSimpleType(XSSimpleType simpleType) {
- boolean isSpecialSimpleType = false;
- if (Constants.NS_XMLSCHEMA.equals(simpleType.getNamespace()) &&
(SchemaSymbols.ATTVAL_ANYATOMICTYPE.equals(simpleType.getName()) ||
SchemaSymbols.ATTVAL_ANYSIMPLETYPE.equals(simpleType.getName()))) {
- isSpecialSimpleType = true;
- }
- return isSpecialSimpleType;
- } // isSpecialSimpleType
-
}//class XSDSimpleTypeTraverser
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java?rev=1099444&r1=1099443&r2=1099444&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
Wed May 4 13:45:45 2011
@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Vector;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidatedInfo;
@@ -265,6 +266,18 @@ public class XSTypeHelper {
/*
+ * Check if a simpleType definition is one of special types (i.e
xs:anyAtomicType or xs:anySimpleType).
+ */
+ public static boolean isSpecialSimpleType(XSSimpleType simpleType) {
+ boolean isSpecialSimpleType = false;
+ if (Constants.NS_XMLSCHEMA.equals(simpleType.getNamespace()) &&
(SchemaSymbols.ATTVAL_ANYATOMICTYPE.equals(simpleType.getName()) ||
SchemaSymbols.ATTVAL_ANYSIMPLETYPE.equals(simpleType.getName()))) {
+ isSpecialSimpleType = true;
+ }
+ return isSpecialSimpleType;
+ } // isSpecialSimpleType
+
+
+ /*
* Construct an PsychoPath XPath2 "result sequence" given a list of XDM
items as input.
*/
public static ResultSequence getXPath2ResultSequence(List xdmItems) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]