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/06/20 22:54:45 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/common AllContentModel.java DFAContentModel.java ElementWildcard.java Grammar.java SimpleContentModel.java XMLContentModel.java XMLValidator.java
neilg 01/06/20 13:54:45
Modified: java/src/org/apache/xerces/validators/common
AllContentModel.java DFAContentModel.java
ElementWildcard.java Grammar.java
SimpleContentModel.java XMLContentModel.java
XMLValidator.java
Log:
remove unnecessary catch blocks.
Revision Changes Path
1.3 +1 -1 xml-xerces/java/src/org/apache/xerces/validators/common/AllContentModel.java
Index: AllContentModel.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/AllContentModel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AllContentModel.java 2001/05/18 20:31:07 1.2
+++ AllContentModel.java 2001/06/20 20:54:35 1.3
@@ -145,7 +145,7 @@
}
// Unique Particle Attribution
- public void checkUniqueParticleAttribution(SchemaGrammar gram) {
+ public void checkUniqueParticleAttribution(SchemaGrammar gram) throws Exception {
// rename back
for (int i = 0; i < fNumElements; i++)
fAllElements[i].uri = gram.getContentSpecOrgUri(fAllElements[i].uri);
1.32 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java
Index: DFAContentModel.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- DFAContentModel.java 2001/06/13 22:40:53 1.31
+++ DFAContentModel.java 2001/06/20 20:54:37 1.32
@@ -70,7 +70,7 @@
* the conversion from the regular expression to the DFA that
* it then uses in its validation algorithm.
*
- * @version $Id: DFAContentModel.java,v 1.31 2001/06/13 22:40:53 sandygao Exp $
+ * @version $Id: DFAContentModel.java,v 1.32 2001/06/20 20:54:37 neilg Exp $
*/
public class DFAContentModel
implements XMLContentModel {
@@ -839,7 +839,7 @@
private byte fConflictTable[][];
// check UPA after build the DFA
- public void checkUniqueParticleAttribution(SchemaGrammar gram) {
+ public void checkUniqueParticleAttribution(SchemaGrammar gram) throws Exception {
// rename back
for (int i = 0; i < fElemMapSize; i++)
fElemMap[i].uri = gram.getContentSpecOrgUri(fElemMap[i].uri);
1.7 +10 -25 xml-xerces/java/src/org/apache/xerces/validators/common/ElementWildcard.java
Index: ElementWildcard.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/ElementWildcard.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElementWildcard.java 2001/06/20 15:08:44 1.6
+++ ElementWildcard.java 2001/06/20 20:54:37 1.7
@@ -71,7 +71,7 @@
private ElementWildcard(){}
private static boolean uriInWildcard(QName qname, int wildcard, int wtype,
- SubstitutionGroupComparator comparator) {
+ SubstitutionGroupComparator comparator) throws Exception {
int type = wtype & 0x0f;
if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
@@ -80,12 +80,8 @@
else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_NS) {
// substitution of "uri" satisfies "wtype:wildcard"
if (comparator != null) {
- try {
- if (comparator.isAllowedByWildcard(qname, wildcard, false))
- return true;
- } catch (Exception e) {
- // error occurs in comparator, do nothing here.
- }
+ if (comparator.isAllowedByWildcard(qname, wildcard, false))
+ return true;
} else {
if (qname.uri == wildcard)
return true;
@@ -94,12 +90,8 @@
else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
// substitution of "uri" satisfies "wtype:wildcard"
if (comparator != null) {
- try {
- if (comparator.isAllowedByWildcard(qname, wildcard, true))
- return true;
- } catch (Exception e) {
- // error occurs in comparator, do nothing here.
- }
+ if (comparator.isAllowedByWildcard(qname, wildcard, true))
+ return true;
} else {
//if (wildcard != uri && uri != StringPool.EMPTY_STRING) // ???
if (wildcard != qname.uri)
@@ -147,7 +139,7 @@
// check whether two elements conflict
private static boolean conflic(int type1, int local1, int uri1,
int type2, int local2, int uri2,
- SubstitutionGroupComparator comparator) {
+ SubstitutionGroupComparator comparator) throws Exception {
QName q1 = new QName(), q2 = new QName();
q1.localpart = local1;
q1.uri = uri1;
@@ -157,13 +149,9 @@
if (type1 == XMLContentSpec.CONTENTSPECNODE_LEAF &&
type2 == XMLContentSpec.CONTENTSPECNODE_LEAF) {
if (comparator != null) {
- try {
- if (comparator.isEquivalentTo(q1, q2) ||
- comparator.isEquivalentTo(q2, q1))
- return true;
- } catch (Exception e) {
- // error occurs in comparator, do nothing here.
- }
+ if (comparator.isEquivalentTo(q1, q2) ||
+ comparator.isEquivalentTo(q2, q1))
+ return true;
} else {
if (q1.localpart == q2.localpart &&
q1.uri == q2.uri)
@@ -185,10 +173,9 @@
public static boolean conflict(int type1, int local1, int uri1,
int type2, int local2, int uri2,
- SubstitutionGroupComparator comparator) {
+ SubstitutionGroupComparator comparator) throws Exception {
boolean ret = conflic(type1, local1, uri1, type2, local2, uri2, comparator);
- try {
if (ret && comparator != null) {
String elements = getString (type1, local1, uri1,
type2, local2, uri2,
@@ -200,8 +187,6 @@
SchemaMessageProvider.MSG_NONE,
new Object[]{elements},
XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
- }
- } catch (Exception e) {
}
return ret;
1.28 +3 -3 xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java
Index: Grammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Grammar.java 2001/06/20 18:37:17 1.27
+++ Grammar.java 2001/06/20 20:54:38 1.28
@@ -72,7 +72,7 @@
/**
- * @version $Id: Grammar.java,v 1.27 2001/06/20 18:37:17 neilg Exp $
+ * @version $Id: Grammar.java,v 1.28 2001/06/20 20:54:38 neilg Exp $
*/
public class Grammar
implements XMLContentSpec.Provider {
@@ -262,7 +262,7 @@
return (fContentSpecValidator[chunk][index] != null);
}
- public XMLContentModel getElementContentModel(int elementDeclIndex, SubstitutionGroupComparator comparator) throws CMException {
+ public XMLContentModel getElementContentModel(int elementDeclIndex, SubstitutionGroupComparator comparator) throws Exception {
if (elementDeclIndex < 0 || elementDeclIndex >= fElementDeclCount)
return null;
@@ -276,7 +276,7 @@
contentType, comparator);
}
- public XMLContentModel getContentModel(int contentSpecIndex, int contentType, SubstitutionGroupComparator comparator) throws CMException {
+ public XMLContentModel getContentModel(int contentSpecIndex, int contentType, SubstitutionGroupComparator comparator) throws Exception {
if (contentSpecIndex < 0 || contentSpecIndex >= fContentSpecCount)
return null;
1.12 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/common/SimpleContentModel.java
Index: SimpleContentModel.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/SimpleContentModel.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SimpleContentModel.java 2001/05/18 20:31:17 1.11
+++ SimpleContentModel.java 2001/06/20 20:54:39 1.12
@@ -84,7 +84,7 @@
* in a simple way without a DFA and without the overhead of setting up a
* DFA for such a simple check.
*
- * @version $Id: SimpleContentModel.java,v 1.11 2001/05/18 20:31:17 neilg Exp $
+ * @version $Id: SimpleContentModel.java,v 1.12 2001/06/20 20:54:39 neilg Exp $
*/
public class SimpleContentModel
implements XMLContentModel {
@@ -167,7 +167,7 @@
}
// Unique Particle Attribution
- public void checkUniqueParticleAttribution(SchemaGrammar gram) {
+ public void checkUniqueParticleAttribution(SchemaGrammar gram) throws Exception {
// rename back
fFirstChild.uri = gram.getContentSpecOrgUri(fFirstChild.uri);
fSecondChild.uri = gram.getContentSpecOrgUri(fSecondChild.uri);
1.8 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/common/XMLContentModel.java
Index: XMLContentModel.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLContentModel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLContentModel.java 2001/05/18 20:31:16 1.7
+++ XMLContentModel.java 2001/06/20 20:54:40 1.8
@@ -79,7 +79,7 @@
* this standard view of the elements to be validated.
*
* @author Dean Roddey, Eric Ye
- * @version $Id: XMLContentModel.java,v 1.7 2001/05/18 20:31:16 neilg Exp $
+ * @version $Id: XMLContentModel.java,v 1.8 2001/06/20 20:54:40 neilg Exp $
*/
public interface XMLContentModel {
@@ -178,5 +178,5 @@
// each kind of content model needs to provide a way to validate
// Unique Particle Attribution
- public void checkUniqueParticleAttribution(SchemaGrammar gram);
+ public void checkUniqueParticleAttribution(SchemaGrammar gram) throws Exception;
} // interface XMLContentModel
1.169 +71 -75 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.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- XMLValidator.java 2001/06/20 19:31:15 1.168
+++ XMLValidator.java 2001/06/20 20:54:40 1.169
@@ -125,7 +125,7 @@
/**
* This class is the super all-in-one validator used by the parser.
*
- * @version $Id: XMLValidator.java,v 1.168 2001/06/20 19:31:15 elena Exp $
+ * @version $Id: XMLValidator.java,v 1.169 2001/06/20 20:54:40 neilg Exp $
*/
public final class XMLValidator
implements DefaultEntityHandler.EventHandler,
@@ -2295,7 +2295,7 @@
// content models
/** Queries the content model for the specified element index. */
- private XMLContentModel getElementContentModel(int elementIndex) throws CMException {
+ private XMLContentModel getElementContentModel(int elementIndex) throws Exception {
XMLContentModel contentModel = null;
if ( elementIndex > -1) {
if ( fGrammar.getElementDecl(elementIndex,fTempElementDecl) ) {
@@ -2723,89 +2723,85 @@
Document document = fSchemaGrammarParser.getDocument(); //Our Grammar
TraverseSchema tst = null;
- try {
- if (DEBUG_SCHEMA_VALIDATION) {
- System.out.println("I am geting the Schema Document");
- }
+ if (DEBUG_SCHEMA_VALIDATION) {
+ System.out.println("I am geting the Schema Document");
+ }
- Element root = null;
- if (document != null) {
- root = document.getDocumentElement();// This is what we pass to TraverserSchema
+ Element root = null;
+ if (document != null) {
+ root = document.getDocumentElement();// This is what we pass to TraverserSchema
+ }
+ if (root == null) {
+ reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR, XMLMessages.SCHEMA_GENERIC_ERROR, "Can't get back Schema document's root element :" + loc);
+ } else {
+ if (uri!=null && !uri.equals(root.getAttribute(SchemaSymbols.ATT_TARGETNAMESPACE)) ) {
+ reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR, XMLMessages.SCHEMA_GENERIC_ERROR, "Schema in " + loc + " has a different target namespace " +
+ "from the one specified in the instance document :" + uri);
}
- if (root == null) {
- reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR, XMLMessages.SCHEMA_GENERIC_ERROR, "Can't get back Schema document's root element :" + loc);
- } else {
- if (uri!=null && !uri.equals(root.getAttribute(SchemaSymbols.ATT_TARGETNAMESPACE)) ) {
- reportRecoverableXMLError(XMLMessages.MSG_GENERIC_SCHEMA_ERROR, XMLMessages.SCHEMA_GENERIC_ERROR, "Schema in " + loc + " has a different target namespace " +
- "from the one specified in the instance document :" + uri);
- }
- grammar = new SchemaGrammar();
- grammar.setGrammarDocument(document);
+ grammar = new SchemaGrammar();
+ grammar.setGrammarDocument(document);
- // Since we've just constructed a schema grammar, we should make sure we know what we've done.
- fGrammarIsSchemaGrammar = true;
- fGrammarIsDTDGrammar = false;
-
- //At this point we should expand the registry table.
- // pass parser's entity resolver (local Resolver), which also has reference to user's
- // entity resolver, and also can fall-back to entityhandler's expandSystemId()
- GeneralAttrCheck generalAttrCheck = new GeneralAttrCheck(fErrorReporter, fDataTypeReg);
- tst = new TraverseSchema( root, fStringPool, (SchemaGrammar)grammar, fGrammarResolver, fErrorReporter, source.getSystemId(), currentER, getSchemaFullCheckingEnabled(), generalAttrCheck);
- generalAttrCheck.checkNonSchemaAttributes(fGrammarResolver);
+ // Since we've just constructed a schema grammar, we should make sure we know what we've done.
+ fGrammarIsSchemaGrammar = true;
+ fGrammarIsDTDGrammar = false;
- //allowing xsi:schemaLocation to appear on any element
+ //At this point we should expand the registry table.
+ // pass parser's entity resolver (local Resolver), which also has reference to user's
+ // entity resolver, and also can fall-back to entityhandler's expandSystemId()
+ GeneralAttrCheck generalAttrCheck = new GeneralAttrCheck(fErrorReporter, fDataTypeReg);
+ tst = new TraverseSchema( root, fStringPool, (SchemaGrammar)grammar, fGrammarResolver, fErrorReporter, source.getSystemId(), currentER, getSchemaFullCheckingEnabled(), generalAttrCheck);
+ generalAttrCheck.checkNonSchemaAttributes(fGrammarResolver);
+
+ //allowing xsi:schemaLocation to appear on any element
- String targetNS = root.getAttribute("targetNamespace");
- fGrammarNameSpaceIndex = fStringPool.addSymbol(targetNS);
- fGrammarResolver.putGrammar(targetNS, grammar);
- fGrammar = (SchemaGrammar)grammar;
-
- // when in full checking, we need to do UPA stuff here
- // by constructing all content models
- if (fSchemaValidationFullChecking) {
- try {
- // get all grammar URIs
- Enumeration grammarURIs = fGrammarResolver.nameSpaceKeys();
- String grammarURI;
- Grammar gGrammar;
- SchemaGrammar sGrammar;
- // for each grammar
- while (grammarURIs.hasMoreElements()) {
- grammarURI = (String)grammarURIs.nextElement();
- gGrammar = fGrammarResolver.getGrammar(grammarURI);
- if (!(gGrammar instanceof SchemaGrammar))
+ String targetNS = root.getAttribute("targetNamespace");
+ fGrammarNameSpaceIndex = fStringPool.addSymbol(targetNS);
+ fGrammarResolver.putGrammar(targetNS, grammar);
+ fGrammar = (SchemaGrammar)grammar;
+
+ // when in full checking, we need to do UPA stuff here
+ // by constructing all content models
+ if (fSchemaValidationFullChecking) {
+ try {
+ // get all grammar URIs
+ Enumeration grammarURIs = fGrammarResolver.nameSpaceKeys();
+ String grammarURI;
+ Grammar gGrammar;
+ SchemaGrammar sGrammar;
+ // for each grammar
+ while (grammarURIs.hasMoreElements()) {
+ grammarURI = (String)grammarURIs.nextElement();
+ gGrammar = fGrammarResolver.getGrammar(grammarURI);
+ if (!(gGrammar instanceof SchemaGrammar))
continue;
- sGrammar = (SchemaGrammar)gGrammar;
+ sGrammar = (SchemaGrammar)gGrammar;
- // get all registered complex type in this grammar
- Hashtable complexTypeRegistry = sGrammar.getComplexTypeRegistry();
- int count = complexTypeRegistry.size();
- Enumeration enum = complexTypeRegistry.elements();
-
- TraverseSchema.ComplexTypeInfo typeInfo;
- while (enum.hasMoreElements ()) {
- typeInfo = (TraverseSchema.ComplexTypeInfo)enum.nextElement();
- // for each type, we construct a corresponding content model
- sGrammar.getContentModel(typeInfo.contentSpecHandle,
- typeInfo.contentType,
- fSGComparator);
- }
- }
- } catch (CMException excToCatch) {
- // REVISIT - Translate caught error to the protected error handler interface
- int majorCode = excToCatch.getErrorCode();
- fErrorReporter.reportError(fErrorReporter.getLocator(),
- ImplementationMessages.XERCES_IMPLEMENTATION_DOMAIN,
- majorCode,
- 0,
- null,
- XMLErrorReporter.ERRORTYPE_FATAL_ERROR);
- }
+ // get all registered complex type in this grammar
+ Hashtable complexTypeRegistry = sGrammar.getComplexTypeRegistry();
+ int count = complexTypeRegistry.size();
+ Enumeration enum = complexTypeRegistry.elements();
+
+ TraverseSchema.ComplexTypeInfo typeInfo;
+ while (enum.hasMoreElements ()) {
+ typeInfo = (TraverseSchema.ComplexTypeInfo)enum.nextElement();
+ // for each type, we construct a corresponding content model
+ sGrammar.getContentModel(typeInfo.contentSpecHandle,
+ typeInfo.contentType,
+ fSGComparator);
+ }
+ }
+ } catch (CMException excToCatch) {
+ // REVISIT - Translate caught error to the protected error handler interface
+ int majorCode = excToCatch.getErrorCode();
+ fErrorReporter.reportError(fErrorReporter.getLocator(),
+ ImplementationMessages.XERCES_IMPLEMENTATION_DOMAIN,
+ majorCode,
+ 0,
+ null,
+ XMLErrorReporter.ERRORTYPE_FATAL_ERROR);
}
}
- } catch (Exception e) {
- e.printStackTrace(System.err);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org