You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2010/08/28 06:04:21 UTC
svn commit: r990318 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/
xs/ xs/assertion/ xs/traversers/
Author: mukulg
Date: Sat Aug 28 04:04:20 2010
New Revision: 990318
URL: http://svn.apache.org/viewvc?rev=990318&view=rev
Log:
committing few fixes for assertions processing for XML Schema simpleType on XML attributes, related to varieties list and union.
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/XMLAssertPsychopathImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.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=990318&r1=990317&r2=990318&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 Sat Aug 28 04:04:20 2010
@@ -106,7 +106,8 @@
cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' is a simple type, so it must have no element information item [children].
cvc-type.3.1.3 = cvc-type.3.1.3: The value ''{1}'' of element ''{0}'' is not valid.
cvc-assertion.3.13.4.1 = cvc-assertion.3.13.4.1: Assertion evaluation (''{1}'') for element ''{0}'' with type ''{2}'' did not succeed. {3}
- cvc-assertion.union.3.13.4.1 = cvc-assertion.union.3.13.4.1: Element ''{0}'' with value ''{1}'' is not locally valid. One or more of the assertion facets on an element''s type, with variety 'union', have failed.
+ cvc-assertion.union.3.13.4.1 = cvc-assertion.union.3.13.4.1: Element ''{0}'' with value ''{1}'' is not locally valid. One or more of the assertion facets on an element''s type, with variety 'union', have failed.
+ cvc-assertion.attr.union.3.13.4.1 = cvc-assertion.attr.union.3.13.4.1: An attribute ''{1}'' (Element -> ''{0}'') with value ''{2}'' is not locally valid. One or more of the assertion facets on an attribute''s type, with variety 'union', have failed.
cvc-assertion.4.3.15.3 = cvc-assertion.4.3.15.3: Assertion evaluation (''{1}'') for element ''{0}'' with type ''{2}'' did not succeed (undefined context). {3}
cvc-assertion.failure = cvc-assertion.failure: {0} {1}
cvc-xpath.3.13.4.2 = cvc-xpath.3.13.4.2: Assertion XPath expression, (''{0}'') on the Schema type ''{1}'' couldn''t compile successfully.
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java?rev=990318&r1=990317&r2=990318&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java Sat Aug 28 04:04:20 2010
@@ -69,56 +69,58 @@ public class XMLAssertPsychopathImpl ext
// class variable declarations
DynamicContext fDynamicContext;
XSModel fSchema = null;
- AbstractPsychoPathImpl abstrPsychopathImpl = null;
+ AbstractPsychoPathImpl fAbstrPsychopathImpl = null;
// the DOM root of assertions tree
- Document assertDocument = null;
+ Document fAssertDocument = null;
// an element to track construction of assertion DOM tree. This object
// changes as per the XNI document events.
- Element currentAssertDomNode = null;
+ Element fCurrentAssertDomNode = null;
// a stack holding the DOM roots for assertions evaluation
- Stack assertRootStack = null;
+ Stack fAssertRootStack = null;
// a stack parallel to 'assertRootStack' storing all assertions for a
// single XDM tree.
- Stack assertListStack = null;
+ Stack fAssertListStack = null;
// XMLSchemaValidator reference. set from the XMLSchemaValidator object
// itself.
- XMLSchemaValidator validator = null;
+ XMLSchemaValidator fValidator = null;
// parameters to pass to PsychoPath engine (like, the namespace bindings)
- Map assertParams = null;
+ Map fAssertParams = null;
+
+ String fAttrName = null;
/*
- * Class constructor
+ * Class constructor.
*/
public XMLAssertPsychopathImpl(Map assertParams) {
// initializing the class variables.
// we use a PSVI enabled DOM implementation, to be able to have typed
// XDM nodes.
- this.assertDocument = new PSVIDocumentImpl();
- this.assertRootStack = new Stack();
- this.assertListStack = new Stack();
- this.assertParams = assertParams;
+ this.fAssertDocument = new PSVIDocumentImpl();
+ this.fAssertRootStack = new Stack();
+ this.fAssertListStack = new Stack();
+ this.fAssertParams = assertParams;
}
/*
- * Initialize the PsychoPath XPath processor
+ * Initialize the PsychoPath XPath processor.
*/
private void initXPathProcessor() throws Exception {
- validator = (XMLSchemaValidator) getProperty
+ fValidator = (XMLSchemaValidator) getProperty
("http://apache.org/xml/properties/assert/validator");
- abstrPsychopathImpl = new AbstractPsychoPathImpl();
- fDynamicContext = abstrPsychopathImpl.initDynamicContext(
+ fAbstrPsychopathImpl = new AbstractPsychoPathImpl();
+ fDynamicContext = fAbstrPsychopathImpl.initDynamicContext(
fSchema,
- assertDocument,
- assertParams);
+ fAssertDocument,
+ fAssertParams);
} // initXPathProcessor
@@ -131,15 +133,15 @@ public class XMLAssertPsychopathImpl ext
public void startElement(QName element, XMLAttributes attributes,
Augmentations augs) {
- if (currentAssertDomNode == null) {
- currentAssertDomNode = new PSVIElementNSImpl((CoreDocumentImpl)
- assertDocument, element.uri, element.rawname);
- assertDocument.appendChild(currentAssertDomNode);
+ if (fCurrentAssertDomNode == null) {
+ fCurrentAssertDomNode = new PSVIElementNSImpl((CoreDocumentImpl)
+ fAssertDocument, element.uri, element.rawname);
+ fAssertDocument.appendChild(fCurrentAssertDomNode);
} else {
Element elem = new PSVIElementNSImpl((CoreDocumentImpl)
- assertDocument, element.uri, element.rawname);
- currentAssertDomNode.appendChild(elem);
- currentAssertDomNode = elem;
+ fAssertDocument, element.uri, element.rawname);
+ fCurrentAssertDomNode.appendChild(elem);
+ fCurrentAssertDomNode = elem;
}
// add attributes to the element
@@ -149,7 +151,7 @@ public class XMLAssertPsychopathImpl ext
String attValue = attributes.getValue(attIndex);
PSVIAttrNSImpl attrNode = new PSVIAttrNSImpl((PSVIDocumentImpl)
- assertDocument, attrUri, attQName);
+ fAssertDocument, attrUri, attQName);
attrNode.setNodeValue(attValue);
// set PSVI information for the attribute
@@ -158,15 +160,15 @@ public class XMLAssertPsychopathImpl ext
getItem(Constants.ATTRIBUTE_PSVI);
attrNode.setPSVI(attrPSVI);
- currentAssertDomNode.setAttributeNode(attrNode);
+ fCurrentAssertDomNode.setAttributeNode(attrNode);
}
List assertionList = (List) augs.getItem("ASSERT");
// if we have assertions applicable to this element, store the element
// reference and the assertions on it, on the runtime stacks.
if (assertionList != null) {
- assertRootStack.push(currentAssertDomNode);
- assertListStack.push(assertionList);
+ fAssertRootStack.push(fCurrentAssertDomNode);
+ fAssertListStack.push(assertionList);
}
} // startElement
@@ -177,13 +179,14 @@ public class XMLAssertPsychopathImpl ext
* @see org.apache.xerces.xni.parser.XMLAssertAdapter#endElement(org.apache.xerces.xni.QName,
* org.apache.xerces.xni.Augmentations)
*/
- public void endElement(QName element, Augmentations augs) throws Exception {
+ public void endElement(QName element, Augmentations augs) throws
+ Exception {
- if (currentAssertDomNode != null) {
+ if (fCurrentAssertDomNode != null) {
// set PSVI information on the element
ElementPSVI elemPSVI = (ElementPSVI) augs.getItem(
Constants.ELEMENT_PSVI);
- ((PSVIElementNSImpl)currentAssertDomNode).setPSVI(elemPSVI);
+ ((PSVIElementNSImpl) fCurrentAssertDomNode).setPSVI(elemPSVI);
// itemType for xs:list
XSSimpleTypeDefinition itemType = null;
@@ -201,16 +204,16 @@ public class XMLAssertPsychopathImpl ext
}
}
- if (!assertRootStack.empty() && (currentAssertDomNode ==
- assertRootStack.peek())) {
+ if (!fAssertRootStack.empty() && (fCurrentAssertDomNode ==
+ fAssertRootStack.peek())) {
// get XSModel
- fSchema = ((PSVIElementNSImpl) currentAssertDomNode).
+ fSchema = ((PSVIElementNSImpl) fCurrentAssertDomNode).
getSchemaInformation();
// pop the stack, to go one level up
- assertRootStack.pop();
- // get assertions, and go one level up
- List assertions = (List) assertListStack.pop();
+ fAssertRootStack.pop();
+ // get assertions, and go one level up on the stack
+ List assertions = (List) fAssertListStack.pop();
Boolean atomicValueValidity = (Boolean) augs.getItem
("ATOMIC_VALUE_VALIDITY");
if (atomicValueValidity.booleanValue()) {
@@ -221,8 +224,8 @@ public class XMLAssertPsychopathImpl ext
}
}
- if (currentAssertDomNode.getParentNode() instanceof Element) {
- currentAssertDomNode = (Element)currentAssertDomNode.
+ if (fCurrentAssertDomNode.getParentNode() instanceof Element) {
+ fCurrentAssertDomNode = (Element)fCurrentAssertDomNode.
getParentNode();
}
}
@@ -245,7 +248,7 @@ public class XMLAssertPsychopathImpl ext
// determine value of variable, $value
String value = "";
- NodeList childList = currentAssertDomNode.getChildNodes();
+ NodeList childList = fCurrentAssertDomNode.getChildNodes();
int textChildCount = 0;
// there could be adjacent text nodes. merge them to get the value.
for (int childNodeIndex = 0; childNodeIndex < childList.getLength();
@@ -272,30 +275,86 @@ public class XMLAssertPsychopathImpl ext
// $value should be, the XPath2 "empty sequence" ... TO DO
}
XSObjectList assertList = (XSObjectList) assertions;
+ XSObjectList attrMemberTypes = null;
for (int i = 0; i < assertList.size(); i++) {
- XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);
- boolean xpathContextExists = false;
- if (assertImpl.getType() == XSConstants.ASSERTION) {
- // not an assertion facet
- xpathContextExists = true;
- }
- // check if this is an assertion, from the attribute
- if (assertImpl.getAttrValue() != null) {
- // reassign value (the attribute's value) to variable
- // $value.
- value = assertImpl.getAttrValue();
- setValueOf$value(value, null,
- assertImpl.getTypeDefinition());
- }
-
- AssertionError assertError = evaluateAssertion(element,
- assertImpl, value,
- xpathContextExists,
- false);
- if (assertError != null) {
- reportError(assertError);
- }
+ XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);
+ boolean xpathContextExists = false;
+ if (assertImpl.getType() == XSConstants.ASSERTION) {
+ // not an assertion facet
+ xpathContextExists = true;
+ }
+ // check if this is an assertion, from the attribute
+ if (assertImpl.getAttrName() != null) {
+ value = assertImpl.getAttrValue();
+
+ XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) assertImpl.
+ getTypeDefinition();
+ attrMemberTypes = attrType.getMemberTypes();
+ if (assertImpl.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) {
+ // this assertion belongs to a type, that is an item type
+ // of a simpleType -> list.
+ // tokenize the list value by the longest sequence of
+ // white-spaces.
+ String[] values = value.split("\\s+");
+ // evaluate assertion on all of list items
+ for (int valIdx = 0; valIdx < values.length; valIdx++) {
+ setValueOf$value(values[valIdx], attrType, null);
+ AssertionError assertError = evaluateAssertion(element,
+ assertImpl,
+ values[valIdx],
+ xpathContextExists,
+ true);
+ if (assertError != null) {
+ reportError(assertError);
+ }
+ }
+ }
+ else if (assertImpl.getVariety() == XSSimpleTypeDefinition.
+ VARIETY_ATOMIC) {
+ // evaluating assertions for simpleType -> restriction
+ setValueOf$value(value, null, attrType);
+ AssertionError assertError = evaluateAssertion(element,
+ assertImpl, value,
+ xpathContextExists,
+ false);
+ if (assertError != null) {
+ reportError(assertError);
+ }
+ }
+ }
+ else {
+ AssertionError assertError = evaluateAssertion(element,
+ assertImpl, value,
+ xpathContextExists,
+ false);
+ if (assertError != null) {
+ reportError(assertError);
+ }
+ }
}
+
+ // evaluate assertions on simpleType -> union on an attribute
+ if (attrMemberTypes != null && attrMemberTypes.getLength() > 0) {
+ boolean isValidationFailedForUnion =
+ isValidationFailedForUnion
+ (attrMemberTypes,
+ element,
+ value, true);
+
+ if (isValidationFailedForUnion) {
+ // none of the member types of union (the assertions in
+ // them) can successfully validate an atomic value. this
+ // results in an overall validation failure. report an
+ // error message.
+ fValidator.reportSchemaError("cvc-assertion.attr.union." +
+ "3.13.4.1",
+ new Object[] { element.rawname, fAttrName,
+ value } );
+ }
+
+ fAttrName = null;
+ }
+
}
else if (assertions instanceof Vector) {
// assertions from a simple type definition
@@ -304,20 +363,18 @@ public class XMLAssertPsychopathImpl ext
for (int i = 0; i < assertList.size(); i++) {
XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(i);
if (itemType != null) {
- // evaluating assertions for simpleType -> list
-
+ // evaluating assertions for simpleType -> list.
// tokenize the list value by the longest sequence of
// white-spaces.
- String[] values = value.split("\\s+");
-
- // evaluate assertion on all list items
+ String[] values = value.split("\\s+");
+ // evaluate assertion on all of list items
for (int valIdx = 0; valIdx < values.length; valIdx++) {
setValueOf$value(values[valIdx], itemType, null);
AssertionError assertError = evaluateAssertion(element,
- assertImpl,
- values[valIdx],
- false,
- true);
+ assertImpl,
+ values[valIdx],
+ false,
+ true);
if (assertError != null) {
reportError(assertError);
}
@@ -336,24 +393,16 @@ public class XMLAssertPsychopathImpl ext
}
}
}
-
- // check for assertions on union member types.
- // (there's a special handling for union types for assertions,
- // since validation success on any one of the union member types,
- // results in the overall validity of the value in the context)
+
if (memberTypes != null && memberTypes.getLength() > 0) {
boolean isValidationFailedForUnion =
isValidationFailedForUnion
(memberTypes,
element,
- value);
+ value, false);
if (isValidationFailedForUnion) {
- // none of the member types of union (the assertions in
- // them) can successfully validate an atomic value. this
- // results in an overall validation failure. report an
- // error message.
- validator.reportSchemaError("cvc-assertion.union.3.13.4.1",
+ fValidator.reportSchemaError("cvc-assertion.union.3.13.4.1",
new Object[] { element.rawname, value } );
}
}
@@ -367,8 +416,9 @@ public class XMLAssertPsychopathImpl ext
* 'simpleType -> union' member types.
*/
private boolean isValidationFailedForUnion(XSObjectList memberTypes,
- QName element,
- String value) {
+ QName element,
+ String value,
+ boolean isAttribute) {
boolean validationFailedForUnion = true;
@@ -399,16 +449,16 @@ public class XMLAssertPsychopathImpl ext
if (assertError == null) {
assertsSucceeded++;
}
+ else if (isAttribute && fAttrName == null) {
+ fAttrName = assertImpl.getAttrName();
+ }
}
catch(Exception ex) {
// An exception may occur if for example, a typed
// value cannot be constructed by PsychoPath engine
// for a given string value (say a value '5' was
- // attempted to be formed as a typed value xs:date).
- // This is a known scenario for an exception here.
- // Exceptions may occur due to other un-observed
- // scenarios.
-
+ // attempted to be formed as a typed value xs:date).
+
// it's useful to report warning ... TO DO
}
}
@@ -462,8 +512,8 @@ public class XMLAssertPsychopathImpl ext
public void characters(XMLString text) {
// add a child text node to the assertions, DOM tree
- if (currentAssertDomNode != null) {
- currentAssertDomNode.appendChild(assertDocument.createTextNode(new
+ if (fCurrentAssertDomNode != null) {
+ fCurrentAssertDomNode.appendChild(fAssertDocument.createTextNode(new
String(text.ch, text.offset, text.length)));
}
@@ -487,13 +537,13 @@ public class XMLAssertPsychopathImpl ext
boolean result;
if ((value == null) ||
(xPathContextExists == true)) {
- result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp,
+ result = fAbstrPsychopathImpl.evaluatePsychoPathExpr(xp,
assertImpl.getXPathDefaultNamespace(),
- currentAssertDomNode);
+ fCurrentAssertDomNode);
}
else {
// XPath context is "undefined"
- result = abstrPsychopathImpl.evaluatePsychoPathExpr(xp,
+ result = fAbstrPsychopathImpl.evaluatePsychoPathExpr(xp,
assertImpl.getXPathDefaultNamespace(),
null);
}
@@ -555,7 +605,7 @@ public class XMLAssertPsychopathImpl ext
else {
// is "simple type" value of an element
PSVIElementNSImpl currentAssertPSVINode = (PSVIElementNSImpl)
- currentAssertDomNode;
+ fCurrentAssertDomNode;
XSTypeDefinition typeDef = currentAssertPSVINode.getTypeDefinition();
if (typeDef instanceof XSComplexTypeDefinition) {
XSComplexTypeDefinition cmplxTypeDef = (XSComplexTypeDefinition)
@@ -645,11 +695,11 @@ public class XMLAssertPsychopathImpl ext
else {
message = "Assertion failure. " + message;
}
- validator.reportSchemaError("cvc-assertion.failure",
+ fValidator.reportSchemaError("cvc-assertion.failure",
new Object[] { message, listAssertErrMessage } );
}
else {
- validator.reportSchemaError(key, new Object[] { elemErrorAnnotation,
+ fValidator.reportSchemaError(key, new Object[] { elemErrorAnnotation,
assertImpl.getTest().getXPath().toString(),
typeString, listAssertErrMessage} );
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java?rev=990318&r1=990317&r2=990318&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java Sat Aug 28 04:04:20 2010
@@ -23,7 +23,6 @@ import java.util.Map;
import java.util.Vector;
import org.apache.xerces.impl.Constants;
-import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.assertion.XMLAssertHandler;
import org.apache.xerces.impl.xs.assertion.XSAssert;
import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
@@ -213,22 +212,70 @@ public class XSDAssertionValidator {
XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition)attrPSVI.
getTypeDefinition();
if (attrType != null) {
- XSObjectList facets = attrType.getMultiValueFacets();
- for (int i = 0; i < facets.getLength(); i++) {
+ // this accumulates assertions only for simpleType ->
+ // restriction.
+ XSObjectList facets = attrType.getMultiValueFacets();
+
+ // variety is 'unknown/absent' at the moment
+ short attrTypeVariety = XSSimpleTypeDefinition.
+ VARIETY_ABSENT;
+
+ if (facets.getLength() == 0 && attrType.getItemType() !=
+ null) {
+ // facets for simpleType -> list
+ attrTypeVariety = XSSimpleTypeDefinition.VARIETY_LIST;
+ facets = (XSObjectListImpl) attrType.getItemType().
+ getMultiValueFacets();
+ }
+ else if (attrType.getVariety() == XSSimpleTypeDefinition.
+ VARIETY_UNION) {
+ attrTypeVariety = XSSimpleTypeDefinition.VARIETY_UNION;
+
+ // Assertions on a simpleType with variety union, are
+ // handled in a special way. These are not accumulated
+ // here. Create a dummy assertions list (so that a non-null
+ // assertions context is pushed on to a run-time assertions
+ // stack).
+ XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(
+ attrType.getMemberTypes());
+ if (assertImpl != null) {
+ // This is done to construct a correct schema
+ // NamespaceContext for 'simpleType -> union' assertions
+ // evaluation. Since NamespaceContext is available in an
+ // assertions object, therefore we utilize the 1st
+ // assertion of an union for this need.
+ // An assertion object here is not actually evaluated, to
+ // check an XML instance validity.
+ // For union types, assertions are later again determined
+ // in XMLAssertPsychopathImpl.
+ assertImpl.setTypeDefinition(attrType);
+ assertImpl.setVariety(attrTypeVariety);
+ assertImpl.setAttrName(attributes.getLocalName
+ (attrIndx));
+ assertImpl.setAttrValue(attributes.getValue
+ (attrIndx));
+ assertions.addXSObject(assertImpl);
+ }
+ }
+
+ for (int facetIdx = 0; facetIdx < facets.getLength();
+ facetIdx++) {
XSMultiValueFacet facet = (XSMultiValueFacet)
- facets.item(i);
+ facets.item(facetIdx);
if (facet.getFacetKind() == XSSimpleTypeDefinition.
- FACET_ASSERT) {
+ FACET_ASSERT) {
Vector attrAsserts = facet.getAsserts();
for (int j = 0; j < attrAsserts.size(); j++) {
XSAssertImpl attrAssert = (XSAssertImpl)
- attrAsserts.elementAt(j);
+ attrAsserts.elementAt(j);
attrAssert.setAttrName(attributes.getLocalName
(attrIndx));
attrAssert.setAttrValue(attributes.getValue
(attrIndx));
+ attrAssert.setVariety(attrTypeVariety);
assertions.addXSObject(attrAssert);
- }
+ }
+ // break from the for loop
break;
}
}
@@ -249,30 +296,19 @@ public class XSDAssertionValidator {
if (facets.getLength() == 0 && simpleTypeDef.getItemType() !=
null) {
- // facets for list -> simpleType
+ // facets for simpleType -> list
facets = (XSObjectListImpl) simpleTypeDef.getItemType().
getMultiValueFacets();
}
- else if (simpleTypeDef.getVariety() == XSSimpleType.
+ else if (simpleTypeDef.getVariety() == XSSimpleTypeDefinition.
VARIETY_UNION) {
- // assertions on a simpleType with variety union, are
- // handled in a special way.
- // NOTE: assertions on simpleType -> union are not
- // accumulated here.
- // create a dummy assertions list (so that a non-null
- // assertions context is pushed on to a run-time assertions
- // stack).
+ // Special handling for assertions on simpleType -> union
+ // cases. Adding an assertion here, for determining the
+ // NamespaceContext.
+ // An assertion object here is not actually evaluated.
XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(
simpleTypeDef.getMemberTypes());
if (assertImpl != null) {
- // this is done to pass a correct schema NamespaceContext
- // for union assertions evaluation. since NamespaceContext
- // is available in an assertions object, therefore we
- // utilize the 1st assertions on a union for this need.
-
- // REVISIT: if we can store the schema namespace context
- // in a global store, then we can avoid storing it in
- // every assertions object.
assertionList = new Vector();
assertionList.add(assertImpl);
}
@@ -311,16 +347,17 @@ public class XSDAssertionValidator {
for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength();
memberTypeIdx++) {
XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition)
- memberTypes.item(memberTypeIdx);
- if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())
- ) {
+ memberTypes.item(memberTypeIdx);
+ if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.
+ getNamespace())) {
XSObjectList memberTypeFacets = memType.getMultiValueFacets();
for (int memberTypeFacetIdx = 0; memberTypeFacetIdx <
memberTypeFacets.getLength();
memberTypeFacetIdx++) {
- XSMultiValueFacet facet = (XSMultiValueFacet) memberTypeFacets.
- item(memberTypeFacetIdx);
- if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
+ XSMultiValueFacet facet = (XSMultiValueFacet)
+ memberTypeFacets.item(memberTypeFacetIdx);
+ if (facet.getFacetKind() == XSSimpleTypeDefinition.
+ FACET_ASSERT) {
Vector assertFacets = facet.getAsserts();
assertImpl = (XSAssertImpl) assertFacets.get(0);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java?rev=990318&r1=990317&r2=990318&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertImpl.java Sat Aug 28 04:04:20 2010
@@ -37,7 +37,7 @@ import org.eclipse.wst.xml.xpath2.proces
*/
public class XSAssertImpl extends AbstractPsychoPathImpl implements XSAssert {
- protected short assertType = XSConstants.ASSERTION;
+ protected short assertKind = XSConstants.ASSERTION;
/** The type definition associated with the assertion component */
protected XSTypeDefinition fTypeDefinition;
@@ -72,6 +72,9 @@ public class XSAssertImpl extends Abstra
// user-defined message, to display, during assertion failures
protected String message = null;
+
+ // if assertion belongs to a simpleType, the type's variety
+ protected short fVariety = 0;
/** Constructor */
public XSAssertImpl(XSTypeDefinition type,
@@ -108,10 +111,14 @@ public class XSAssertImpl extends Abstra
}
/**
- * Sets the type of the object
+ * Sets the kind of assertion this is. This could be one of the following:
+ * -> an assertion from a complexType (XSConstants.ASSERTION)
+ * -> an assertion facet from a complexType -> simpleContent
+ * (XSConstants.ASSERTION_FACET)
+ * -> an assertion facet from a simpleType (XSConstants.ASSERTION_FACET)
*/
- public void setType(short assertType) {
- this.assertType = assertType;
+ public void setAssertKind(short assertKind) {
+ this.assertKind = assertKind;
}
/**
@@ -149,6 +156,10 @@ public class XSAssertImpl extends Abstra
return fTypeDefinition;
}
+ public void setTypeDefinition(XSTypeDefinition typeDefn) {
+ fTypeDefinition = typeDefn;
+ }
+
public String getXPathDefaultNamespace() {
return fXPathDefaultNamespace;
}
@@ -178,7 +189,7 @@ public class XSAssertImpl extends Abstra
* Get the type of the object
*/
public short getType() {
- return assertType;
+ return assertKind;
}
/**
@@ -222,14 +233,32 @@ public class XSAssertImpl extends Abstra
}
/*
- * Set error message, for assertions failures
+ * Set error message, for assertions failures.
*/
public void setMessage(String message) {
this.message = message;
}
- // Get the error message string
+ /*
+ * Get the error message string.
+ */
public String getMessage() {
return message;
}
+
+ /*
+ * If the assertion belongs to a simpleType, set the variety
+ * of the type.
+ */
+ public void setVariety(short variety) {
+ fVariety = variety;
+ }
+
+
+ /*
+ * Get the value of simpleType's variety.
+ */
+ public short getVariety() {
+ return fVariety;
+ }
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=990318&r1=990317&r2=990318&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java Sat Aug 28 04:04:20 2010
@@ -511,7 +511,7 @@ abstract class XSDAbstractTraverser {
fSchemaHandler);
Test testExpr = new Test(new XPath20Assert(test, fSymbolTable,
schemaDoc.fNamespaceSupport), assertImpl);
- assertImpl.setType(XSConstants.ASSERTION_FACET);
+ assertImpl.setAssertKind(XSConstants.ASSERTION_FACET);
assertImpl.setTest(testExpr);
assertImpl.setXPathDefaultNamespace(xpathDefaultNamespace);
assertImpl.setXPath2NamespaceContext(schemaDoc.fNamespaceSupport);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org