You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/10/19 18:43:40 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 SchemaValidator.java SubstitutionGroupHandler.java XSDElementTraverser.java XSParticleDecl.java
sandygao 01/10/19 09:43:40
Modified: java/src/org/apache/xerces/impl XMLNamespaceBinder.java
java/src/org/apache/xerces/impl/v2 SchemaValidator.java
SubstitutionGroupHandler.java
XSDElementTraverser.java XSParticleDecl.java
Log:
various bug fixes.
Revision Changes Path
1.9 +50 -48 xml-xerces/java/src/org/apache/xerces/impl/XMLNamespaceBinder.java
Index: XMLNamespaceBinder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLNamespaceBinder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XMLNamespaceBinder.java 2001/10/18 04:48:49 1.8
+++ XMLNamespaceBinder.java 2001/10/19 16:43:40 1.9
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000,2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -93,9 +93,9 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XMLNamespaceBinder.java,v 1.8 2001/10/18 04:48:49 andyc Exp $
+ * @version $Id: XMLNamespaceBinder.java,v 1.9 2001/10/19 16:43:40 sandygao Exp $
*/
-public class XMLNamespaceBinder
+public class XMLNamespaceBinder
implements XMLComponent, XMLDocumentFilter {
//
@@ -113,7 +113,7 @@
/** Property identifier: symbol table. */
protected static final String SYMBOL_TABLE =
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
-
+
/** Property identifier: error reporter. */
protected static final String ERROR_REPORTER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
@@ -127,7 +127,7 @@
/** Recognized properties. */
protected static final String[] RECOGNIZED_PROPERTIES = {
- SYMBOL_TABLE,
+ SYMBOL_TABLE,
ERROR_REPORTER,
};
@@ -147,7 +147,7 @@
/** Error reporter. */
protected XMLErrorReporter fErrorReporter;
-
+
// handlers
/** Document handler. */
@@ -193,7 +193,7 @@
this(null);
} // <init>()
- /**
+ /**
* Constructs a namespace binder that shares the specified namespace
* context during each parse.
*
@@ -202,7 +202,7 @@
public XMLNamespaceBinder(NamespaceContext namespaceContext) {
fNamespaceContext = namespaceContext;
} // <init>(NamespaceContext)
-
+
//
// Public methods
@@ -217,7 +217,7 @@
/**
* Sets whether the namespace binder only passes the prefix mapping
- * events to the registered document handler or passes all document
+ * events to the registered document handler or passes all document
* events.
*
* @param onlyPassPrefixMappingEvents True to pass only the prefix
@@ -228,7 +228,7 @@
fOnlyPassPrefixMappingEvents = onlyPassPrefixMappingEvents;
} // setOnlyPassPrefixMappingEvents(boolean)
- /**
+ /**
* Returns true if the namespace binder only passes the prefix mapping
* events to the registered document handler; false if the namespace
* binder passes all document events.
@@ -245,13 +245,13 @@
* Resets the component. The component can query the component manager
* about any features and properties that affect the operation of the
* component.
- *
+ *
* @param componentManager The component manager.
*
* @throws SAXException Thrown by component on initialization error.
* For example, if a feature or property is
* required for the operation of the component, the
- * component manager may throw a
+ * component manager may throw a
* SAXNotRecognizedException or a
* SAXNotSupportedException.
*/
@@ -277,7 +277,7 @@
fEmptySymbol = fSymbolTable.addSymbol("");
fXmlSymbol = fSymbolTable.addSymbol("xml");
fXmlnsSymbol = fSymbolTable.addSymbol("xmlns");
-
+
// use shared context
NamespaceContext context = fNamespaceContext;
while (context != null) {
@@ -305,11 +305,11 @@
/**
* Sets the state of a feature. This method is called by the component
- * manager any time after reset when a feature changes state.
+ * manager any time after reset when a feature changes state.
* <p>
* <strong>Note:</strong> Components should silently ignore features
* that do not affect the operation of the component.
- *
+ *
* @param featureId The feature identifier.
* @param state The state of the feature.
*
@@ -333,13 +333,13 @@
/**
* Sets the value of a property during parsing.
- *
- * @param propertyId
- * @param value
+ *
+ * @param propertyId
+ * @param value
*/
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {
-
+
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
String property =
@@ -361,7 +361,7 @@
/**
* Sets the document handler to receive information about the document.
- *
+ *
* @param documentHandler The document handler.
*/
public void setDocumentHandler(XMLDocumentHandler documentHandler) {
@@ -378,7 +378,7 @@
* <p>
* <strong>Note:</strong> This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @param name The name of the entity.
* @param publicId The public identifier of the entity if the entity
* is external, null otherwise.
@@ -394,12 +394,12 @@
*
* @throws XNIException Thrown by handler to signal an error.
*/
- public void startEntity(String name,
+ public void startEntity(String name,
String publicId, String systemId,
String baseSystemId,
String encoding) throws XNIException {
if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
- fDocumentHandler.startEntity(name, publicId, systemId,
+ fDocumentHandler.startEntity(name, publicId, systemId,
baseSystemId, encoding);
}
} // startEntity(String,String,String,String,String)
@@ -414,13 +414,13 @@
* <p>
* <strong>Note:</strong> This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @param version The XML version, or null if not specified.
* @param encoding The IANA encoding name of the entity.
*
* @throws XNIException Thrown by handler to signal an error.
*/
- public void textDecl(String version, String encoding)
+ public void textDecl(String version, String encoding)
throws XNIException {
if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
fDocumentHandler.textDecl(version, encoding);
@@ -432,7 +432,7 @@
*
* @throws XNIException Thrown by handler to signal an error.
*/
- public void startDocument(XMLLocator locator, String encoding)
+ public void startDocument(XMLLocator locator, String encoding)
throws XNIException {
if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
fDocumentHandler.startDocument(locator, encoding);
@@ -443,7 +443,7 @@
* Notifies of the presence of an XMLDecl line in the document. If
* present, this method will be called immediately following the
* startDocument call.
- *
+ *
* @param version The XML version.
* @param encoding The IANA encoding name of the document, or null if
* not specified.
@@ -460,7 +460,7 @@
/**
* Notifies of the presence of the DOCTYPE line in the document.
- *
+ *
* @param rootElement The name of the root element.
* @param publicId The public identifier if an external DTD or null
* if the external DTD is specified using SYSTEM.
@@ -469,7 +469,7 @@
*
* @throws XNIException Thrown by handler to signal an error.
*/
- public void doctypeDecl(String rootElement,
+ public void doctypeDecl(String rootElement,
String publicId, String systemId)
throws XNIException {
if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
@@ -479,7 +479,7 @@
/**
* A comment.
- *
+ *
* @param text The text in the comment.
*
* @throws XNIException Thrown by application to signal an error.
@@ -500,7 +500,7 @@
* element attributes but are <strong>not</strong> parsed or presented
* to the application as anything other than text. The application is
* responsible for parsing the data.
- *
+ *
* @param target The target.
* @param data The data or null if none specified.
*
@@ -516,7 +516,7 @@
/**
* The start of a namespace prefix mapping. This method will only be
* called when namespace processing is enabled.
- *
+ *
* @param prefix The namespace prefix.
* @param uri The URI bound to the prefix.
*
@@ -543,7 +543,7 @@
* fAttributeQName variable. Any contents of the variable will
* be destroyed. Caller should copy the values out of this
* temporary variable before calling this method.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
*
@@ -563,7 +563,7 @@
/**
* An empty element.
- *
+ *
* @param element The name of the element.
* @param attributes The element attributes.
*
@@ -584,7 +584,7 @@
/**
* Character content.
- *
+ *
* @param text The content.
*
* @throws XNIException Thrown by handler to signal an error.
@@ -602,7 +602,7 @@
* example, the validator can determine if a length of whitespace
* characters in the document are ignorable based on the element
* content model.
- *
+ *
* @param text The ignorable whitespace.
*
* @throws XNIException Thrown by handler to signal an error.
@@ -615,7 +615,7 @@
/**
* The end of an element.
- *
+ *
* @param element The name of the element.
*
* @throws XNIException Thrown by handler to signal an error.
@@ -634,7 +634,7 @@
/**
* The end of a namespace prefix mapping. This method will only be
* called when namespace processing is enabled.
- *
+ *
* @param prefix The namespace prefix.
*
* @throws XNIException Thrown by handler to signal an error.
@@ -651,8 +651,8 @@
} // endPrefixMapping(String)
- /**
- * The start of a CDATA section.
+ /**
+ * The start of a CDATA section.
*
* @throws XNIException Thrown by handler to signal an error.
*/
@@ -663,7 +663,7 @@
} // startCDATA()
/**
- * The end of a CDATA section.
+ * The end of a CDATA section.
*
* @throws XNIException Thrown by handler to signal an error.
*/
@@ -690,7 +690,7 @@
* <p>
* <strong>Note:</strong> This method is not called for entity references
* appearing as part of attribute values.
- *
+ *
* @param name The name of the entity.
*
* @throws XNIException Thrown by handler to signal an error.
@@ -724,7 +724,9 @@
uri = fSymbolTable.addSymbol(uri);
// http://www.w3.org/TR/1999/REC-xml-names-19990114/#dt-prefix
- if (uri == fEmptySymbol) {
+ // We should only report an error if there is a prefix,
+ // that is, the local part is not "xmlns". -SG
+ if (uri == fEmptySymbol && localpart != fXmlnsSymbol) {
fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
"EmptyPrefixedAttName",
new Object[]{element.rawname},
@@ -759,7 +761,7 @@
// bind the attributes
for (int i = 0; i < length; i++) {
attributes.getName(i, fAttributeQName);
- String aprefix = fAttributeQName.prefix != null
+ String aprefix = fAttributeQName.prefix != null
? fAttributeQName.prefix : fEmptySymbol;
String arawname = fAttributeQName.rawname;
if (aprefix == fXmlSymbol) {
@@ -820,7 +822,7 @@
if (element.uri != null) {
element.prefix = eprefix;
}
-
+
// call handlers
if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
if (!isEmpty) {
1.34 +14 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java
Index: SchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- SchemaValidator.java 2001/10/18 21:13:42 1.33
+++ SchemaValidator.java 2001/10/19 16:43:40 1.34
@@ -115,7 +115,7 @@
* @author Andy Clark, IBM
* @author Jeffrey Rodriguez IBM
*
- * @version $Id: SchemaValidator.java,v 1.33 2001/10/18 21:13:42 elena Exp $
+ * @version $Id: SchemaValidator.java,v 1.34 2001/10/19 16:43:40 sandygao Exp $
*/
public class SchemaValidator
implements XMLComponent, XMLDocumentFilter,
@@ -208,7 +208,7 @@
// XMLComponent methods
//
-
+
/**
* Returns a list of feature identifiers that are recognized by
* this component. This method may return null if no features
@@ -827,8 +827,8 @@
fSchemaHandler = new XSDHandler(fGrammarResolver, fSubGroupHandler);
} // <init>()
+
-
/*
* Resets the component. The component can query the component manager
* about any features and properties that affect the operation of the
@@ -848,7 +848,7 @@
// get error reporter
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
-
+
// get symbol table. if it's a new one, add symbols to it.
SymbolTable symbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
if (symbolTable != fSymbolTable) {
@@ -909,27 +909,31 @@
if (fElementDepth == fElemDeclStack.length) {
int newSize = fElementDepth + INC_STACK_SIZE;
int[] newArrayI = new int[newSize];
- System.arraycopy(fChildCountStack, 0, newArrayI, 0, newSize);
+ System.arraycopy(fChildCountStack, 0, newArrayI, 0, fElementDepth);
fChildCountStack = newArrayI;
XSElementDecl[] newArrayE = new XSElementDecl[newSize];
- System.arraycopy(fElemDeclStack, 0, newArrayE, 0, newSize);
+ System.arraycopy(fElemDeclStack, 0, newArrayE, 0, fElementDepth);
fElemDeclStack = newArrayE;
+ boolean[] newArrayB = new boolean[newSize];
+ System.arraycopy(fNilStack, 0, newArrayB, 0, fElementDepth);
+ fNilStack = newArrayB;
+
XSTypeDecl[] newArrayT = new XSTypeDecl[newSize];
- System.arraycopy(fTypeStack, 0, newArrayT, 0, newSize);
+ System.arraycopy(fTypeStack, 0, newArrayT, 0, fElementDepth);
fTypeStack = newArrayT;
XSCMValidator[] newArrayC = new XSCMValidator[newSize];
- System.arraycopy(fCMStack, 0, newArrayC, 0, newSize);
+ System.arraycopy(fCMStack, 0, newArrayC, 0, fElementDepth);
fCMStack = newArrayC;
boolean[] newArrayD = new boolean[newSize];
- System.arraycopy(fStringContent, 0, newArrayD, 0, newSize);
+ System.arraycopy(fStringContent, 0, newArrayD, 0, fElementDepth);
fStringContent = newArrayD;
int[][] newArrayIA = new int[newSize][];
- System.arraycopy(fCMStateStack, 0, newArrayIA, 0, newSize);
+ System.arraycopy(fCMStateStack, 0, newArrayIA, 0, fElementDepth);
fCMStateStack = newArrayIA;
}
1.6 +9 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/SubstitutionGroupHandler.java
Index: SubstitutionGroupHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SubstitutionGroupHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SubstitutionGroupHandler.java 2001/10/17 21:46:09 1.5
+++ SubstitutionGroupHandler.java 2001/10/19 16:43:40 1.6
@@ -64,7 +64,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: SubstitutionGroupHandler.java,v 1.5 2001/10/17 21:46:09 sandygao Exp $
+ * @version $Id: SubstitutionGroupHandler.java,v 1.6 2001/10/19 16:43:40 sandygao Exp $
*/
class SubstitutionGroupHandler {
@@ -101,15 +101,6 @@
return null;
}
- /**
- * check whether an element with the given type can have the other element
- * as its {substitution group affiliation}.
- */
- static boolean checkSubstitutionGroupOK(XSElementDecl element) {
- // REVISIT: to implement
- return true;
- }
-
// 3.9.4 Element Sequence Locally Valid (Particle) 2.3.3
// check whether one element decl matches an element with the given qname
XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
@@ -163,6 +154,14 @@
if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE)
blockConstraint |= ((XSComplexTypeDecl)type).fBlock;
+ // REVISIT: there is a potential infinite loop introcuded by
+ // circular substitutionGroup. if A sub B, B sub C, and C
+ // sub B again. Then we can't check whether A sub D, because
+ // we'll get an infinite loop when trying to get A's
+ // {substitution group affiliation} recursively.
+ // To solve it, we need to keep track of all element decls
+ // in the chain, and if we see the same decl again, just
+ // stop the loop, and return false. -SG
// 2 There is a chain of {substitution group affiliation}s from D to C, that is, either D's {substitution group affiliation} is C, or D's {substitution group affiliation}'s {substitution group affiliation} is C, or . . .
XSElementDecl subGroup = element.fSubGroup;
while (subGroup != null && subGroup != exemplar) {
1.26 +8 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- XSDElementTraverser.java 2001/10/18 18:41:18 1.25
+++ XSDElementTraverser.java 2001/10/19 16:43:40 1.26
@@ -89,7 +89,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDElementTraverser.java,v 1.25 2001/10/18 18:41:18 sandygao Exp $
+ * @version $Id: XSDElementTraverser.java,v 1.26 2001/10/19 16:43:40 sandygao Exp $
*/
class XSDElementTraverser extends XSDAbstractTraverser {
@@ -179,17 +179,16 @@
element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, false);
}
+ particle.fMinOccurs = minAtt.intValue();
+ particle.fMaxOccurs = maxAtt.intValue();
if (element != null) {
particle.fType = XSParticleDecl.PARTICLE_ELEMENT;
particle.fValue = element;
- particle.fMinOccurs = minAtt.intValue();
- particle.fMaxOccurs = maxAtt.intValue();
-
- Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
- checkOccurrences(particle, SchemaSymbols.ELT_ELEMENT,
- (Element)elmDecl.getParentNode(), allContextFlags,
- defaultVals.longValue());
}
+ Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
+ checkOccurrences(particle, SchemaSymbols.ELT_ELEMENT,
+ (Element)elmDecl.getParentNode(), allContextFlags,
+ defaultVals.longValue());
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
}
@@ -418,7 +417,7 @@
// 3 If there is an {substitution group affiliation}, the {type definition} of the element declaration must be validly derived from the {type definition} of the {substitution group affiliation}, given the value of the {substitution group exclusions} of the {substitution group affiliation}, as defined in Type Derivation OK (Complex) (�3.4.6) (if the {type definition} is complex) or as defined in Type Derivation OK (Simple) (�3.14.6) (if the {type definition} is simple).
if (element.fSubGroup != null) {
- if (!fSubGroupHandler.checkSubstitutionGroupOK(element)) {
+ if (!XSConstraints.checkTypeDerivationOk(element.fType, element.fSubGroup.fType, element.fSubGroup.fFinal)) {
reportSchemaError ("e-props-correct.3", new Object[]{nameAtt, subGroupAtt.prefix+":"+subGroupAtt.localpart});
}
}
@@ -433,7 +432,6 @@
}
// Step 6: add substitutionGroup information to the handler
-
if (element.fSubGroup != null) {
fSubGroupHandler.addSubstitutionGroup(element);
}
1.19 +1 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/XSParticleDecl.java
Index: XSParticleDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSParticleDecl.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XSParticleDecl.java 2001/10/18 21:54:35 1.18
+++ XSParticleDecl.java 2001/10/19 16:43:40 1.19
@@ -62,7 +62,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSParticleDecl.java,v 1.18 2001/10/18 21:54:35 sandygao Exp $
+ * @version $Id: XSParticleDecl.java,v 1.19 2001/10/19 16:43:40 sandygao Exp $
*/
public class XSParticleDecl {
@@ -109,8 +109,6 @@
*/
public int minEffectiveTotalRange() {
switch (fType) {
- case PARTICLE_EMPTY:
- return 0;
case PARTICLE_ALL:
case PARTICLE_SEQUENCE:
return minEffectiveTotalRangeAllSeq();
@@ -140,8 +138,6 @@
public int maxEffectiveTotalRange() {
switch (fType) {
- case PARTICLE_EMPTY:
- return 0;
case PARTICLE_ALL:
case PARTICLE_SEQUENCE:
return maxEffectiveTotalRangeAllSeq();
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org