You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/05/16 00:18:24 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity XPathMatcher.java Selector.java
neilg 01/05/15 15:18:22
Modified: java/src/org/apache/xerces/validators/common
XMLValidator.java
java/src/org/apache/xerces/validators/schema/identity
XPathMatcher.java Selector.java
Log:
more bugfixes for schema ID constraints.
Revision Changes Path
1.149 +7 -5 xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
Index: XMLValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -r1.148 -r1.149
--- XMLValidator.java 2001/05/15 17:21:05 1.148
+++ XMLValidator.java 2001/05/15 22:18:01 1.149
@@ -124,7 +124,7 @@
/**
* This class is the super all-in-one validator used by the parser.
*
- * @version $Id: XMLValidator.java,v 1.148 2001/05/15 17:21:05 neilg Exp $
+ * @version $Id: XMLValidator.java,v 1.149 2001/05/15 22:18:01 neilg Exp $
*/
public final class XMLValidator
implements DefaultEntityHandler.EventHandler,
@@ -644,7 +644,7 @@
field.setMayMatch(true);
XPathMatcher matcher = field.createMatcher(valueStore);
fMatcherStack.addMatcher(matcher);
- matcher.startDocumentFragment(fStringPool, (SchemaGrammar)fGrammar);
+ matcher.startDocumentFragment(fStringPool);
return matcher;
} // activateField(Field):XPathMatcher
@@ -1171,7 +1171,7 @@
if (DEBUG_IDENTITY_CONSTRAINTS) {
System.out.println("<IC>: "+matcher.toString()+"#startElement("+fStringPool.toString(element.rawname)+")");
}
- matcher.startElement(element, fAttrList, fAttrListHandle, fElementDepth);
+ matcher.startElement(element, fAttrList, fAttrListHandle, fCurrentElementIndex, (SchemaGrammar)fGrammar);
}
}
@@ -1246,12 +1246,14 @@
System.out.println("<IC>: XMLValidator#activateSelectorFor("+selector+')');
}
FieldActivator activator = this;
+ if(selector == null)
+ return;
XPathMatcher matcher = selector.createMatcher(activator);
fMatcherStack.addMatcher(matcher);
if (DEBUG_IDENTITY_CONSTRAINTS) {
System.out.println("<IC>: "+matcher+"#startDocumentFragment()");
}
- matcher.startDocumentFragment(fStringPool, (SchemaGrammar)fGrammar);
+ matcher.startDocumentFragment(fStringPool);
}
private void pushContentLeafStack() throws Exception {
@@ -1375,7 +1377,7 @@
if (DEBUG_IDENTITY_CONSTRAINTS) {
System.out.println("<IC>: "+matcher+"#endElement("+fStringPool.toString(fCurrentElement.rawname)+")");
}
- matcher.endElement(fCurrentElement, fElementDepth);
+ matcher.endElement(fCurrentElement, fCurrentElementIndex, (SchemaGrammar)fGrammar);
}
if (DEBUG_IDENTITY_CONSTRAINTS) {
System.out.println("<IC>: popping context - element: "+fStringPool.toString(fCurrentElement.rawname));
1.14 +17 -19 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java
Index: XPathMatcher.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XPathMatcher.java 2001/05/15 17:21:31 1.13
+++ XPathMatcher.java 2001/05/15 22:18:12 1.14
@@ -80,7 +80,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XPathMatcher.java,v 1.13 2001/05/15 17:21:31 neilg Exp $
+ * @version $Id: XPathMatcher.java,v 1.14 2001/05/15 22:18:12 neilg Exp $
*/
public class XPathMatcher {
@@ -154,9 +154,6 @@
/** String pool. */
protected StringPool fStringPool;
- // the Schema grammar that we're validating against.
- protected SchemaGrammar fGrammar;
-
/** Namespace scope. */
protected NamespacesScope fNamespacesScope;
@@ -257,13 +254,11 @@
*
* @throws SAXException Thrown by handler to signal an error.
*/
- public void startDocumentFragment(StringPool stringPool,
- SchemaGrammar grammar)
+ public void startDocumentFragment(StringPool stringPool)
throws Exception {
if (DEBUG_METHODS) {
System.out.println(toString()+"#startDocumentFragment("+
"stringPool="+stringPool+','+
- "grammar="+fGrammar+
")");
}
@@ -278,7 +273,6 @@
// keep values
fStringPool = stringPool;
- fGrammar = grammar;
} // startDocumentFragment(StringPool,SchemaGrammar)
@@ -289,11 +283,13 @@
*
* @param element The name of the element.
* @param attributes The element attributes.
- * @param scope: the scope of the current element
+ * @param eIndex: the element index of the current element
+ * @param grammar: the currently-active Schema Grammar
*
* @throws SAXException Thrown by handler to signal an error.
*/
- public void startElement(QName element, XMLAttrList attributes, int handle, int scope)
+ public void startElement(QName element, XMLAttrList attributes, int handle,
+ int eIndex, SchemaGrammar grammar)
throws Exception {
if (DEBUG_METHODS2) {
System.out.println(toString()+"#startElement("+
@@ -430,10 +426,9 @@
fMatchedString = fStringPool.toString(avalue);
// now, we have to go on the hunt for
// datatype validator; not an easy or pleasant task...
- int eIndex = fGrammar.getElementDeclIndex(element, scope);
- int attIndex = fGrammar.getAttributeDeclIndex(eIndex, aname);
+ int attIndex = grammar.getAttributeDeclIndex(eIndex, aname);
XMLAttributeDecl tempAttDecl = new XMLAttributeDecl();
- fGrammar.getAttributeDecl(attIndex, tempAttDecl);
+ grammar.getAttributeDecl(attIndex, tempAttDecl);
DatatypeValidator aValidator = tempAttDecl.datatypeValidator;
matched(fMatchedString, aValidator, false);
}
@@ -490,12 +485,12 @@
* The end of an element.
*
* @param element The name of the element.
- * @param scope: the scope of the element. Needed so that we can look
- * up its datatypeValidator.
+ * @param eIndex: the elementDeclIndex of the current element;
+ * needed so that we can look up its datatypeValidator.
*
* @throws SAXException Thrown by handler to signal an error.
*/
- public void endElement(QName element, int scope) throws Exception {
+ public void endElement(QName element, int eIndex, SchemaGrammar grammar) throws Exception {
if (DEBUG_METHODS2) {
System.out.println(toString()+"#endElement("+
"element={"+
@@ -503,6 +498,7 @@
"localpart="+fStringPool.toString(element.localpart)+','+
"rawname="+fStringPool.toString(element.rawname)+','+
"uri="+fStringPool.toString(element.uri)+
+ "ID constraint="+fIDConstraint+
"})");
}
@@ -520,11 +516,13 @@
if (fBufferContent) {
fBufferContent = false;
fMatchedString = fMatchedBuffer.toString();
- int eIndex = fGrammar.getElementDeclIndex(element, scope);
XMLElementDecl temp = new XMLElementDecl();
- fGrammar.getElementDecl(eIndex, temp);
+ grammar.getElementDecl(eIndex, temp);
DatatypeValidator val = temp.datatypeValidator;
- matched(fMatchedString, val, (fGrammar.getElementDeclMiscFlags(eIndex) & SchemaSymbols.NILLABLE) != 0);
+ if(temp != null) {
+ matched(fMatchedString, val, (grammar.getElementDeclMiscFlags(eIndex) & SchemaSymbols.NILLABLE) != 0);
+ } else
+ matched(fMatchedString, null, false);
}
clear();
}
1.11 +12 -10 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java
Index: Selector.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Selector.java 2001/05/08 21:55:51 1.10
+++ Selector.java 2001/05/15 22:18:15 1.11
@@ -69,7 +69,7 @@
* Schema identity constraint selector.
*
* @author Andy Clark, IBM
- * @version $Id: Selector.java,v 1.10 2001/05/08 21:55:51 neilg Exp $
+ * @version $Id: Selector.java,v 1.11 2001/05/15 22:18:15 neilg Exp $
*/
public class Selector {
@@ -132,7 +132,7 @@
* Schema identity constraint selector XPath expression.
*
* @author Andy Clark, IBM
- * @version $Id: Selector.java,v 1.10 2001/05/08 21:55:51 neilg Exp $
+ * @version $Id: Selector.java,v 1.11 2001/05/15 22:18:15 neilg Exp $
*/
public static class XPath
extends org.apache.xerces.validators.schema.identity.XPath {
@@ -200,10 +200,9 @@
// XMLDocumentFragmentHandler methods
//
- public void startDocumentFragment(StringPool stringPool,
- SchemaGrammar grammar)
+ public void startDocumentFragment(StringPool stringPool)
throws Exception {
- super.startDocumentFragment(stringPool,grammar);
+ super.startDocumentFragment(stringPool);
fElementDepth = 0;
fMatchedDepth = -1;
} // startDocumentFragment(StringPool,NamespacesScope)
@@ -215,12 +214,15 @@
*
* @param element The name of the element.
* @param attributes The element attributes.
+ * @param handle: beginning of the attribute list
+ * @param elemIndex: index of the element holding these attributes
+ * @param grammar: the SchemaGrammar that all this is being validated by
*
* @throws SAXException Thrown by handler to signal an error.
*/
public void startElement(QName element, XMLAttrList attributes,
- int handle, int scope) throws Exception {
- super.startElement(element, attributes, handle, scope);
+ int handle, int elemIndex, SchemaGrammar grammar) throws Exception {
+ super.startElement(element, attributes, handle, elemIndex, grammar);
fElementDepth++;
// activate the fields, if selector is matched
@@ -231,14 +233,14 @@
for (int i = 0; i < count; i++) {
Field field = fIdentityConstraint.getFieldAt(i);
XPathMatcher matcher = fFieldActivator.activateField(field);
- matcher.startElement(element, attributes, handle, scope);
+ matcher.startElement(element, attributes, handle, elemIndex, grammar);
}
}
} // startElement(QName,XMLAttrList,int)
- public void endElement(QName element, int scope) throws Exception {
- super.endElement(element, scope);
+ public void endElement(QName element, int elemIndex, SchemaGrammar grammar) throws Exception {
+ super.endElement(element, elemIndex, grammar);
if (fElementDepth-- == fMatchedDepth) {
fMatchedDepth = -1;
fFieldActivator.endValueScopeFor(fIdentityConstraint);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org