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 2002/03/16 00:01:58 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSAttributeChecker.java XSDAbstractTraverser.java XSDElementTraverser.java XSDHandler.java XSDSimpleTypeTraverser.java XSDocumentInfo.java
sandygao 02/03/15 15:01:58
Modified: java/src/org/apache/xerces/impl/xs ElementPSVImpl.java
SchemaGrammar.java XMLSchemaValidator.java
XSAttributeGroupDecl.java XSComplexTypeDecl.java
XSDDescription.java XSParticleDecl.java
XSWildcardDecl.java
java/src/org/apache/xerces/impl/xs/models CMBuilder.java
XSAllCM.java XSDFACM.java
java/src/org/apache/xerces/impl/xs/traversers
XSAttributeChecker.java XSDAbstractTraverser.java
XSDElementTraverser.java XSDHandler.java
XSDSimpleTypeTraverser.java XSDocumentInfo.java
Log:
1. Added setter methods on XSDDescription
2. Pass XSDDescription as the parameter to XSDHandler#parseSchema()
3. Pass XSDDescription as the parameter to XMLEntityManager#resolveEntity()
4. Cleaned some "REVISIT"s.
Revision Changes Path
1.10 +5 -0 xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
Index: ElementPSVImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElementPSVImpl.java 29 Jan 2002 01:15:14 -0000 1.9
+++ ElementPSVImpl.java 15 Mar 2002 23:01:57 -0000 1.10
@@ -296,6 +296,11 @@
* @see <a href="http://www.w3.org/TR/xmlschema-1/#nsi-schema_namespace>XML Schema Part 1: Structures [schema namespace]</a>
* @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_information>XML Schema Part 1: Structures [schema information]</a>
* @return A namespace name or absent.
+ *
+ * REVISIT: this mehtod is wrongfully designed.
+ * The PSVI item for the validation root has a [schema information] property,
+ * which has a list of [namespace schema information], which in turn has
+ * properties [schema namespace/components/documents].
*/
public String getSchemaNamespace() {
// REVISIT: should we create component for schema-information item?
1.14 +4 -8 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SchemaGrammar.java 5 Mar 2002 23:02:59 -0000 1.13
+++ SchemaGrammar.java 15 Mar 2002 23:01:57 -0000 1.14
@@ -81,14 +81,11 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.13 2002/03/05 23:02:59 sandygao Exp $
+ * @version $Id: SchemaGrammar.java,v 1.14 2002/03/15 23:01:57 sandygao Exp $
*/
public class SchemaGrammar implements Grammar {
- /** Symbol table. */
- private SymbolTable fSymbolTable;
-
// the target namespace of grammar
public String fTargetNamespace;
@@ -99,7 +96,6 @@
SymbolHash fGlobalGroupDecls;
SymbolHash fGlobalNotationDecls;
SymbolHash fGlobalIDConstraintDecls;
- //REVISIT: still need to decide on it.
Hashtable fGlobalTypeDecls;
// the XMLGrammarDescription member
@@ -119,7 +115,6 @@
*/
public SchemaGrammar(SymbolTable symbolTable, String targetNamespace,
XSDDescription grammarDesc) {
- fSymbolTable = symbolTable;
fTargetNamespace = targetNamespace;
fGrammarDescription = grammarDesc;
@@ -147,10 +142,11 @@
* @param fullSet
*/
protected SchemaGrammar(SymbolTable symbolTable) {
- fSymbolTable = symbolTable;
fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
- //REVISIT: will we ever need non-null values in this XSDDescription object?
+
fGrammarDescription = new XSDDescription();
+ fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
+ fGrammarDescription.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
fGlobalAttrDecls = new SymbolHash(1);
fGlobalAttrGrpDecls = new SymbolHash(1);
1.49 +61 -123 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Index: XMLSchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- XMLSchemaValidator.java 6 Mar 2002 15:45:28 -0000 1.48
+++ XMLSchemaValidator.java 15 Mar 2002 23:01:57 -0000 1.49
@@ -143,7 +143,7 @@
* @author Elena Litani IBM
* @author Andy Clark IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
- * @version $Id: XMLSchemaValidator.java,v 1.48 2002/03/06 15:45:28 sandygao Exp $
+ * @version $Id: XMLSchemaValidator.java,v 1.49 2002/03/15 23:01:57 sandygao Exp $
*/
public class XMLSchemaValidator
implements XMLComponent, XMLDocumentFilter, FieldActivator {
@@ -731,7 +731,6 @@
*/
public void startCDATA(Augmentations augs) throws XNIException {
-
// REVISIT: what should we do here if schema normalization is on??
fInCDATA = true;
// call handlers
@@ -1184,7 +1183,7 @@
// get JAXP schema source property
fJaxpSchemaSource = componentManager.getProperty(JAXP_SCHEMA_SOURCE);
- fResourceIdentifier.clear();
+ fResourceIdentifier.clear();
// clear grammars, and put the one for schema namespace there
fGrammarBucket.reset();
@@ -1204,9 +1203,11 @@
// clear things in substitution group handler
fSubGroupHandler.reset();
- //REVISIT: we are passing externalSchema and noNamespaceExternalSchema locations to XSDHandler , where
- //it stores namespace and location values.. now we are doing the same in XMLSchemaValidator,
- //we can pass the refernce of fLocationPairs and noNamespaceLocationPairs -nb
+ //REVISIT: we are passing externalSchema and noNamespaceExternalSchema locations to XSDHandler , where
+ //it stores namespace and location values.. now we are doing the same in XMLSchemaValidator,
+ //we can pass the refernce of fLocationPairs and noNamespaceLocationPairs -nb
+ // REVISIT: should we process these two properties here? why not just
+ // them on to xsdhandler.
// reset schema handler and all traversal objects
fSchemaHandler.reset(fXSIErrorReporter.fErrorReporter,
@@ -1614,22 +1615,16 @@
// thus we will not validate in the case dynamic feature is on or we found dtd grammar
fDoValidation = fValidation && !(fValidationManager.isGrammarFound() || fDynamicValidation);
-
//store the external schema locations, these locations will be set at root element, so any other
// schemaLocation declaration for the same namespace will be effectively ignored.. becuase we
// choose to take first location hint available for a particular namespace.
-
storeLocations(fExternalSchemas, fExternalNoNamespaceSchema) ;
//REVISIT: this JAXP processing shouldn't be done
//in XMLSchemaValidator but in a separate component responsible for pre-parsing grammars
// and SchemaValidator should be given these preParsed grammars before this component
//attempts to validate -nb.
-
processJAXPSchemaSource( fJaxpSchemaSource , fEntityResolver );
-
- // parse schemas specified via schema location properties
- //parseSchemas(fExternalSchemas, fExternalNoNamespaceSchema);
}
fCurrentPSVI = (ElementPSVImpl)augs.getItem(Constants.ELEMENT_PSVI);
@@ -1651,7 +1646,6 @@
//REVISIT: We should do the same in XSDHandler also... we should not
//load the actual grammar (eg. import) unless there is reference to it.
- //parseSchemas(sLocation, nsLocation);
// REVISIT: we should not rely on presence of
// schemaLocation or noNamespaceSchemaLocation
@@ -2079,12 +2073,12 @@
String [] temp = new String[newLength] ;
System.arraycopy(locations, 0, temp, 0, Math.min(oldLength, newLength));
locations = temp ;
- length = oldLength ;
+ length = Math.min(oldLength, newLength);
}
public void setLocation(String location){
if(length >= locations.length ){
- resize(length, length*2);
+ resize(length, Math.max(1, length*2));
}
locations[length++] = location;
}//setLocation()
@@ -2149,136 +2143,72 @@
SchemaGrammar grammar = null ;
//get the grammar from local pool...
grammar = fGrammarBucket.getGrammar(namespace);
- if( grammar == null){
- // give a chance to application to be able to retreive the grammar.
- grammar = getSchemaGrammarFromAppl( contextType , namespace , enclosingElement , triggeringComponet , attributes);
- if(grammar == null){
- // try to parse the grammar using location hints from that namespace..
- grammar = parseSchema(namespace , contextType);
- }
- else{
- return grammar ;
+ if (grammar == null){
+ fXSDDescription.reset();
+ fXSDDescription.fContextType = contextType ;
+ fXSDDescription.fTargetNamespace = namespace ;
+ fXSDDescription.fEnclosedElementName = enclosingElement ;
+ fXSDDescription.fTriggeringComponent = triggeringComponet ;
+ fXSDDescription.fAttributes = attributes ;
+
+ Object locationArray = null ;
+ if( namespace != null){
+ locationArray = fLocationPairs.get(namespace) ;
+ if(locationArray != null){
+ String [] temp = ((LocationArray)locationArray).getLocationArray() ;
+ fXSDDescription.fLocationHints = new String [temp.length] ;
+ System.arraycopy(temp, 0 , fXSDDescription.fLocationHints, 0, temp.length );
+ }
+ }else{
+ String [] temp = fNoNamespaceLocationArray.getLocationArray() ;
+ fXSDDescription.fLocationHints = new String [temp.length] ;
+ System.arraycopy(temp, 0 , fXSDDescription.fLocationHints, 0, temp.length );
}
- }
- else{
- return grammar ;
- }
- return grammar ;
-
- }//findSchemaGrammar
-
- // give a chance to application to be able to retreive the grammar.
- SchemaGrammar getSchemaGrammarFromAppl(short contextType , String namespace , QName enclosingElement, QName triggeringComponet, XMLAttributes attribute ){
+ // give a chance to application to be able to retreive the grammar.
//REVISIT: construct empty pool... we dont have to check for the null condition
//give a chance to application to be able to retreive the grammar.
- if(fGrammarPool != null){
-
- fXSDDescription.reset() ;
- fXSDDescription.fContextType = contextType ;
- fXSDDescription.fTargetNamespace = namespace ;
- fXSDDescription.fEnclosedElementName = enclosingElement ;
- fXSDDescription.fTriggeringComponent = triggeringComponet ;
- fXSDDescription.fAttributes = attribute ;
-
- Object locationArray = null ;
- if( namespace != null){
- locationArray = fLocationPairs.get(namespace) ;
- if(locationArray != null){
- String [] temp = ((LocationArray)locationArray).getLocationArray() ;
- fXSDDescription.fLocationHints = new String [temp.length] ;
- System.arraycopy(temp, 0 , fXSDDescription.fLocationHints, 0, temp.length );
- }
- }else{
-
- String [] temp = fNoNamespaceLocationArray.getLocationArray() ;
- fXSDDescription.fLocationHints = new String [temp.length] ;
- System.arraycopy(temp, 0 , fXSDDescription.fLocationHints, 0, temp.length );
+ if (fGrammarPool != null){
+ grammar = (SchemaGrammar)fGrammarPool.retrieveGrammar(fXSDDescription);
+ if (grammar != null) {
+ fGrammarBucket.putGrammar(grammar);
}
-
- return (SchemaGrammar)fGrammarPool.retrieveGrammar(fXSDDescription);
-
}
- else{
- return (SchemaGrammar)null ;
+ if (grammar == null) {
+ // try to parse the grammar using location hints from that namespace..
+ grammar = fSchemaHandler.parseSchema(fXSDDescription);
}
-
- }//getGrammarFromAppl
-
- //this function will search for the first location hint available with the parser for given namespace
- //and tries to parse the grammar using that location hint
-
- SchemaGrammar parseSchema(String namespace, short reference){
-
- String locationHint = null ;
- LocationArray locationArray = null ;
- SchemaGrammar grammar = null ;
-
- if(namespace != null){
- locationArray = (LocationArray)fLocationPairs.get(namespace) ;
- if(locationArray != null){
- locationHint = locationArray.getFirstLocation() ;
- }
- }else{
- locationHint = fNoNamespaceLocationArray.getFirstLocation() ;
}
-
- // REVISIT: we should pass a XSDGrammarDescription to this method
- if(!(namespace == null && locationHint == null)){
- grammar = fSchemaHandler.parseSchema(namespace, locationHint , reference);
- }
-
+
return grammar ;
- } //parseSchema
-
- void parseSchemas(String sLocation, String nsLocation) {
- if (sLocation != null) {
- StringTokenizer t = new StringTokenizer(sLocation, " \n\t\r");
- String namespace, location;
- while (t.hasMoreTokens()) {
- namespace = fSymbolTable.addSymbol(t.nextToken ());
- if (!t.hasMoreTokens()) {
- fXSIErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
- "SchemaLocation",
- new Object[]{sLocation},
- XMLErrorReporter.SEVERITY_WARNING);
- break;
- }
- location = t.nextToken();
-
- if (fGrammarBucket.getGrammar(namespace) == null) {
- fSchemaHandler.parseSchema(namespace, location,
- XSDDescription.CONTEXT_INSTANCE);
- }
- }
- }
- if (nsLocation != null) {
- if (fGrammarBucket.getGrammar(null) == null){
- fSchemaHandler.parseSchema(null, nsLocation, XSDDescription.CONTEXT_INSTANCE);
-
- }
- }
-
- }//parseSchemas(String,String)
-
+ }//findSchemaGrammar
/**
* Translate the various JAXP SchemaSource property types to XNI
* XMLInputSource. Valid types are: String, org.xml.sax.InputSource,
* InputStream, File, or Object[] of any of previous types.
*/
-
private void processJAXPSchemaSource(Object val, XMLEntityResolver xer) {
if (val == null) {
return;
}
Class componentType = val.getClass().getComponentType();
+ XMLInputSource xis = null;
+ String sid = null;
if (componentType == null) {
// Not an array
- fSchemaHandler.parseSchema(null, XSD2XMLInputSource(val, xer),
- XSDDescription.CONTEXT_PREPARSE);
+ xis = XSD2XMLInputSource(val, xer);
+ sid = xis.getSystemId();
+ fXSDDescription.reset();
+ fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
+ if (sid != null) {
+ fXSDDescription.setLiteralSystemId(sid);
+ fXSDDescription.setExpandedSystemId(sid);
+ fXSDDescription.fLocationHints = new String[]{sid};
+ }
+ fSchemaHandler.parseSchema(xis, fXSDDescription);
return ;
} else if (componentType != Object.class) {
// Not an Object[]
@@ -2288,8 +2218,16 @@
Object[] objArr = (Object[]) val;
for (int i = 0; i < objArr.length; i++) {
- fSchemaHandler.parseSchema(null, XSD2XMLInputSource(objArr[i], xer),
- XSDDescription.CONTEXT_PREPARSE);
+ xis = XSD2XMLInputSource(objArr[i], xer);
+ sid = xis.getSystemId();
+ fXSDDescription.reset();
+ fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
+ if (sid != null) {
+ fXSDDescription.setLiteralSystemId(sid);
+ fXSDDescription.setExpandedSystemId(sid);
+ fXSDDescription.fLocationHints = new String[]{sid};
+ }
+ fSchemaHandler.parseSchema(xis, fXSDDescription);
}
}
1.6 +14 -15 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
Index: XSAttributeGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSAttributeGroupDecl.java 29 Jan 2002 01:15:14 -0000 1.5
+++ XSAttributeGroupDecl.java 15 Mar 2002 23:01:57 -0000 1.6
@@ -66,7 +66,7 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSAttributeGroupDecl.java,v 1.5 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: XSAttributeGroupDecl.java,v 1.6 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSAttributeGroupDecl {
@@ -215,20 +215,19 @@
if (baseConsType == XSAttributeDecl.FIXED_VALUE) {
- if (thisConstType != XSAttributeDecl.FIXED_VALUE) {
- errorCode="derivation-ok-restriction.2.1.3";
- return errorCode;
- }
- else {
- // check the values are the same. NB - this should not be a string
- // comparison REVISIT when we have new datatype design!
- ValidatedInfo baseFixedValue=(baseAttrUse.fDefault!=null ?
- baseAttrUse.fDefault: baseAttrDecl.fDefault);
- ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ?
- attrUse.fDefault: attrDecl.fDefault);
- if (!baseFixedValue.normalizedValue.equals(thisFixedValue.normalizedValue)) {
- errorCode="derivation-ok-restriction.2.1.3";
- return errorCode;
+ if (thisConstType != XSAttributeDecl.FIXED_VALUE) {
+ errorCode="derivation-ok-restriction.2.1.3";
+ return errorCode;
+ }
+ else {
+ // check the values are the same.
+ ValidatedInfo baseFixedValue=(baseAttrUse.fDefault!=null ?
+ baseAttrUse.fDefault: baseAttrDecl.fDefault);
+ ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ?
+ attrUse.fDefault: attrDecl.fDefault);
+ if (!baseAttrDecl.fType.isEqual(baseFixedValue.actualValue,thisFixedValue.actualValue)) {
+ errorCode="derivation-ok-restriction.2.1.3";
+ return errorCode;
}
}
1.5 +1 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
Index: XSComplexTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSComplexTypeDecl.java 29 Jan 2002 01:15:14 -0000 1.4
+++ XSComplexTypeDecl.java 15 Mar 2002 23:01:57 -0000 1.5
@@ -67,7 +67,7 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSComplexTypeDecl.java,v 1.4 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: XSComplexTypeDecl.java,v 1.5 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSComplexTypeDecl implements XSTypeDecl {
@@ -114,12 +114,10 @@
// if there is a particle, the content model corresponding to that particle
public XSCMValidator fCMValidator = null;
- // REVISIT: when XSTypeDecl becomes a class, remove this method
public short getXSType () {
return COMPLEX_TYPE;
}
- // REVISIT: when XSTypeDecl becomes a class, remove this method
public String getTypeName() {
return fName;
}
1.5 +61 -13 xml-xerces/java/src/org/apache/xerces/impl/xs/XSDDescription.java
Index: XSDDescription.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSDDescription.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSDDescription.java 27 Feb 2002 17:47:35 -0000 1.4
+++ XSDDescription.java 15 Mar 2002 23:01:57 -0000 1.5
@@ -68,10 +68,10 @@
* @author Neil Graham, IBM
* @author Neeraj Bajaj, SUN Microsystems.
*
- * @version $Id: XSDDescription.java,v 1.4 2002/02/27 17:47:35 neeraj Exp $
+ * @version $Id: XSDDescription.java,v 1.5 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSDDescription extends XMLResourceIdentifierImpl
- implements XMLGrammarDescription {
+ implements XMLGrammarDescription {
// used to indicate what triggered the call
/**
* Indicate that the current schema document is <include>d by another
@@ -131,7 +131,6 @@
protected QName fTriggeringComponent;
protected QName fEnclosedElementName;
protected XMLAttributes fAttributes;
-
/**
* the type of the grammar (e.g., DTD or XSD);
@@ -206,6 +205,13 @@
return fAttributes;
}
+ public boolean fromInstance() {
+ return fContextType == CONTEXT_ATTRIBUTE ||
+ fContextType == CONTEXT_ELEMENT ||
+ fContextType == CONTEXT_INSTANCE ||
+ fContextType == CONTEXT_XSITYPE;
+ }
+
/**
* Compares this grammar with the given grammar. Currently, we compare
* the target namespaces.
@@ -215,15 +221,15 @@
*/
public boolean equals(XMLGrammarDescription desc) {
if (!getGrammarType().equals(desc.getGrammarType())) {
- return false;
- }
- if (fTargetNamespace != null && fTargetNamespace.equals(((XSDDescription)desc).getTargetNamespace())) {
- return true;
- }
- else if (fTargetNamespace == null && ((XSDDescription)desc).getTargetNamespace() == null) {
- return true;
- }
- return false;
+ return false;
+ }
+ if (fTargetNamespace != null && fTargetNamespace.equals(((XSDDescription)desc).getTargetNamespace())) {
+ return true;
+ }
+ else if (fTargetNamespace == null && ((XSDDescription)desc).getTargetNamespace() == null) {
+ return true;
+ }
+ return false;
}
/**
@@ -235,16 +241,58 @@
return (fTargetNamespace == null) ? 0 : fTargetNamespace.hashCode();
}
+ public void setContextType(short contextType){
+ fContextType = contextType ;
+ }
+
+ public void setTargetNamespace(String targetNamespace){
+ fTargetNamespace = targetNamespace ;
+ }
+
+ public void setLocationHints(String [] locationHints){
+ int length = locationHints.length ;
+ fLocationHints = new String[length];
+ System.arraycopy(locationHints, 0, fLocationHints, 0, length);
+ //fLocationHints = locationHints ;
+ }
+
+ public void setTriggeringComponent(QName triggeringComponent){
+ fTriggeringComponent = triggeringComponent ;
+ }
+
+ public void setEnclosingElementName(QName enclosedElementName){
+ fEnclosedElementName = enclosedElementName ;
+ }
+
+ public void setAttributes(XMLAttributes attributes){
+ fAttributes = attributes ;
+ }
+
/**
* resets all the fields
*/
- protected void reset(){
+ public void reset(){
fContextType = 0 ;
fTargetNamespace = null ;
fLocationHints = null ;
fTriggeringComponent = null ;
fEnclosedElementName = null ;
fAttributes = null ;
+ }
+
+ public XSDDescription makeClone() {
+ XSDDescription desc = new XSDDescription();
+ desc.fAttributes = this.fAttributes;
+ desc.fBaseSystemId = this.fBaseSystemId;
+ desc.fContextType = this.fContextType;
+ desc.fEnclosedElementName = this.fEnclosedElementName;
+ desc.fExpandedSystemId = this.fExpandedSystemId;
+ desc.fLiteralSystemId = this.fLiteralSystemId;
+ desc.fLocationHints = this.fLocationHints;
+ desc.fPublicId = this.fPublicId;
+ desc.fTargetNamespace = this.fTargetNamespace;
+ desc.fTriggeringComponent = this.fTriggeringComponent;
+ return desc;
}
} // XSDDescription
1.4 +42 -10 xml-xerces/java/src/org/apache/xerces/impl/xs/XSParticleDecl.java
Index: XSParticleDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSParticleDecl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSParticleDecl.java 29 Jan 2002 01:15:14 -0000 1.3
+++ XSParticleDecl.java 15 Mar 2002 23:01:57 -0000 1.4
@@ -2,22 +2,22 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
- * RedifBufferibution and use in source and binary forms, with or without
+ * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1. RedifBuffeributions of source code must retain the above copyright
+ * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
- * 2. RedifBuffeributions in binary form must reproduce the above copyright
+ * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
- * difBufferibution.
+ * distribution.
*
- * 3. The end-user documentation included with the redifBufferibution,
+ * 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
@@ -49,7 +49,7 @@
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
+ * originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
@@ -62,7 +62,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSParticleDecl.java,v 1.3 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: XSParticleDecl.java,v 1.4 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSParticleDecl {
@@ -92,6 +92,40 @@
// maximum occurrence of this particle
public int fMaxOccurs = 1;
+ // clone this decl
+ public XSParticleDecl clone(boolean deep) {
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fType = fType;
+ particle.fMinOccurs = fMinOccurs;
+ particle.fMaxOccurs = fMaxOccurs;
+ particle.fDescription = fDescription;
+ // if it's not a deep clone, or it's a leaf particle
+ // just copy value and other value
+ if (!deep ||
+ fType == PARTICLE_EMPTY ||
+ fType == PARTICLE_ELEMENT ||
+ fType == PARTICLE_WILDCARD) {
+ particle.fValue = fValue;
+ particle.fOtherValue = fOtherValue;
+ }
+ // otherwise, we have to make clones of value and other value
+ else {
+ if (fValue != null) {
+ particle.fValue = ((XSParticleDecl)fValue).clone(deep);
+ }
+ else {
+ particle.fValue = null;
+ }
+ if (fOtherValue != null) {
+ particle.fOtherValue = ((XSParticleDecl)fOtherValue).clone(deep);
+ }
+ else {
+ particle.fOtherValue = null;
+ }
+ }
+ return particle;
+ }
+
/**
* 3.9.6 Schema Component Constraint: Particle Emptiable
* whether this particle is emptible
@@ -203,8 +237,6 @@
if (fDescription == null) {
StringBuffer buffer = new StringBuffer();
appendParticle(buffer);
- // REVISIT: what would be the best form?
- // how to output "unbounded"?
if (!(fMinOccurs == 0 && fMaxOccurs == 0 ||
fMinOccurs == 1 && fMaxOccurs == 1)) {
buffer.append("{" + fMinOccurs);
1.6 +1 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java
Index: XSWildcardDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSWildcardDecl.java 29 Jan 2002 01:15:14 -0000 1.5
+++ XSWildcardDecl.java 15 Mar 2002 23:01:57 -0000 1.6
@@ -68,11 +68,10 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSWildcardDecl.java,v 1.5 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: XSWildcardDecl.java,v 1.6 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSWildcardDecl {
- //REVISIT: Should this be here. Is this required at all.
public static final String ABSENT = null;
// types of wildcard
1.6 +6 -15 xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java
Index: CMBuilder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CMBuilder.java 29 Jan 2002 01:15:16 -0000 1.5
+++ CMBuilder.java 15 Mar 2002 23:01:57 -0000 1.6
@@ -70,7 +70,7 @@
* This class constructs content models for a given grammar.
*
* @author Elena Litani, IBM
- * @version $Id: CMBuilder.java,v 1.5 2002/01/29 01:15:16 lehors Exp $
+ * @version $Id: CMBuilder.java,v 1.6 2002/03/15 23:01:57 sandygao Exp $
*/
public class CMBuilder {
@@ -96,8 +96,6 @@
*/
public XSCMValidator getContentModel(XSComplexTypeDecl typeDecl) {
- // REVISIT: can we assume that this method never called for elements of simpleType
- // content?
short contentType = typeDecl.fContentType;
if (contentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE ||
contentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
@@ -116,9 +114,6 @@
if (particle != null)
particle = expandParticleTree( (XSParticleDecl)particle);
- // REVISIT: should we expand?? or throw away the expanded tree??
- //typeDecl.fParticle
-
// And create the content model according to the spec type
if (particle == null) {
@@ -154,15 +149,16 @@
// We may want to consider trying to combine this with buildSyntaxTree at some
// point (if possible)
- //REVISIT: need access to grammar object
- //if (!grammar.fDeferParticleExpantion) {
- // return particle;
- //}
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
+ // Make a clone of the leaf particle, so that if there are two
+ // references to the same group, we have two different leaf
+ // particles for the same element or wildcard decl.
+ // This is useful for checking UPA.
+ //return expandContentModel(particle.clone(false), minOccurs, maxOccurs);
return expandContentModel(particle, minOccurs, maxOccurs);
}
else if (type == XSParticleDecl.PARTICLE_CHOICE ||
@@ -360,11 +356,6 @@
return createParticle (XSParticleDecl.PARTICLE_ONE_OR_MORE, particle, null);
}
else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
- // REVISIT: should we handle (maxOccurs - minOccurs) = {1,2} as
- // separate case?
- if (minOccurs<2) {
- }
-
// => a,a,..,a+
particle = createParticle (XSParticleDecl.PARTICLE_ONE_OR_MORE,
particle, null);
1.4 +1 -11 xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSAllCM.java
Index: XSAllCM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSAllCM.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSAllCM.java 29 Jan 2002 01:15:16 -0000 1.3
+++ XSAllCM.java 15 Mar 2002 23:01:57 -0000 1.4
@@ -67,7 +67,7 @@
* XSAllCM implements XSCMValidator and handles <all>
*
* @author Pavani Mukthipudi, Sun Microsystems Inc.
- * @version $Id: XSAllCM.java,v 1.3 2002/01/29 01:15:16 lehors Exp $
+ * @version $Id: XSAllCM.java,v 1.4 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSAllCM implements XSCMValidator {
@@ -100,12 +100,6 @@
fHasOptionalContent = hasOptionalContent;
}
- // REVISIT : do we need this ?
- // public XSAllCM (boolean hasOptionalContent, boolean isMixed) {
- // this(hasOptionalContent);
- // fIsMixed = isMixed;
- // }
-
public void addElement (XSElementDecl element, boolean isOptional) {
// resize arrays if necessary
@@ -133,10 +127,6 @@
}
}
-
-
- // REVISIT : to implement Unique Particle Attribution
- // public void checkUniqueParticleAttribution()
//
1.4 +6 -8 xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSDFACM.java
Index: XSDFACM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSDFACM.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSDFACM.java 29 Jan 2002 01:15:16 -0000 1.3
+++ XSDFACM.java 15 Mar 2002 23:01:57 -0000 1.4
@@ -75,7 +75,7 @@
* it then uses in its validation algorithm.
*
* @author Neil Graham, IBM
- * @version $Id: XSDFACM.java,v 1.3 2002/01/29 01:15:16 lehors Exp $
+ * @version $Id: XSDFACM.java,v 1.4 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSDFACM
implements XSCMValidator {
@@ -316,22 +316,20 @@
Object matchingDecl = null;
for (; elemIndex < fElemMapSize; elemIndex++) {
+ nextState = fTransTable[curState][elemIndex];
+ if (nextState == -1)
+ continue;
int type = fElemMapType[elemIndex] ;
if (type == XSParticleDecl.PARTICLE_ELEMENT) {
matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex].fValue);
-
if (matchingDecl != null) {
- nextState = fTransTable[curState][elemIndex];
- if (nextState != -1)
- break;
+ break;
}
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
if(((XSWildcardDecl)fElemMap[elemIndex].fValue).allowNamespace(curElem.uri)) {
matchingDecl = fElemMap[elemIndex].fValue;
- nextState = fTransTable[curState][elemIndex];
- if (nextState != -1)
- break;
+ break;
}
}
}
1.11 +5 -10 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
Index: XSAttributeChecker.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSAttributeChecker.java 15 Feb 2002 22:08:48 -0000 1.10
+++ XSAttributeChecker.java 15 Mar 2002 23:01:57 -0000 1.11
@@ -93,14 +93,12 @@
*
* Things need revisiting:
* - Whether to return non-schema attributes/values
- * - We need NamespaceScope to generate QName
* - Do we need to update NamespaceScope and ErrorReporter when reset()?
* - Should have the datatype validators return compiled value
- * - Should return compiled form for wildcard namespace
* - use symbol table instead of many hashtables
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.10 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.11 2002/03/15 23:01:57 sandygao Exp $
*/
public class XSAttributeChecker {
@@ -108,7 +106,7 @@
// REVISIT: only local element and attribute are different from others.
// it's possible to have either name or ref. all the others
// are only allowed to have one of name or ref, or neither of them.
- // we'd better remove such checking to the traverser.
+ // we'd better move such checking to the traverser.
private static final String ELEMENT_N = "element_n";
private static final String ELEMENT_R = "element_r";
private static final String ATTRIBUTE_N = "attribute_n";
@@ -1033,7 +1031,7 @@
// REVISIT: only local element and attribute are different from others.
// it's possible to have either name or ref. all the others
// are only allowed to have one of name or ref, or neither of them.
- // we'd better remove such checking to the traverser.
+ // we'd better move such checking to the traverser.
if (!isGlobal) {
eleAttrsMap = fEleAttrsMapL;
if (elName.equals(SchemaSymbols.ELT_ELEMENT)) {
@@ -1169,9 +1167,6 @@
for (int i = 0; i < reqAttrs.length; i++) {
OneAttr oneAttr = reqAttrs[i];
- // REVISIT: throw an error on required attribute that does not
- // appear test case schema_invalid/S3_14/ibm3_14si12.xml
-
// if the attribute didn't apprear, and
// if the attribute is optional with default value, apply it
if (oneAttr.dfltValue != null &&
@@ -1648,7 +1643,8 @@
// return an array back to the pool
public void returnAttrArray(Object[] attrArray, XSDocumentInfo schemaDoc) {
// pop the namespace context
- schemaDoc.fNamespaceSupport.popContext();
+ if (schemaDoc != null)
+ schemaDoc.fNamespaceSupport.popContext();
// if 1. the pool is full; 2. the array is null;
// 3. the array is of wrong size; 4. the array is already returned
@@ -1685,7 +1681,6 @@
prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
if (prefix != null) {
uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
- // REVISIT: copied from namespce binder
nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
}
}
1.12 +1 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XSDAbstractTraverser.java 15 Feb 2002 22:08:48 -0000 1.11
+++ XSDAbstractTraverser.java 15 Mar 2002 23:01:58 -0000 1.12
@@ -92,7 +92,7 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Neeraj Bajaj, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.11 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.12 2002/03/15 23:01:58 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -350,7 +350,6 @@
}
}
}
- // REVISIT: when to return the array
fAttrChecker.returnAttrArray (attrs, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
1.14 +1 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSDElementTraverser.java 15 Feb 2002 22:08:48 -0000 1.13
+++ XSDElementTraverser.java 15 Mar 2002 23:01:58 -0000 1.14
@@ -97,7 +97,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDElementTraverser.java,v 1.13 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSDElementTraverser.java,v 1.14 2002/03/15 23:01:58 sandygao Exp $
*/
class XSDElementTraverser extends XSDAbstractTraverser {
@@ -296,9 +296,6 @@
}
// get 'substitutionGroup affiliation'
- // REVISIT: allow mutual-substitution
- // we need to back-patch both fSubGroup and fType
- // if there is no type attribute and no anonymous type
if (subGroupAtt != null) {
element.fSubGroup = (XSElementDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ELEMENT_TYPE, subGroupAtt, elmDecl);
}
1.32 +104 -167 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XSDHandler.java 3 Mar 2002 13:33:57 -0000 1.31
+++ XSDHandler.java 15 Mar 2002 23:01:58 -0000 1.32
@@ -117,7 +117,7 @@
*
* @author Neil Graham, IBM
* @author Pavani Mukthipudi, Sun Microsystems
- * @version $Id: XSDHandler.java,v 1.31 2002/03/03 13:33:57 neeraj Exp $
+ * @version $Id: XSDHandler.java,v 1.32 2002/03/15 23:01:58 sandygao Exp $
*/
public class XSDHandler {
@@ -219,9 +219,6 @@
// processed (by getSchema) was a duplicate.
private boolean fLastSchemaWasDuplicate;
- // object for use in calling XMLEntityResolver (perhaps later XMLGrammarPool...
- private XMLResourceIdentifierImpl fResourceIdentifier = new XMLResourceIdentifierImpl();
-
// the XMLErrorReporter
private XMLErrorReporter fErrorReporter;
@@ -261,14 +258,16 @@
}
}
- public XMLInputSource resolveEntity(String namespace, String location, String base, boolean useProperties) throws IOException {
+ public XMLInputSource resolveEntity(XSDDescription desc) throws IOException {
if (fExternalResolver == null)
return null;
String loc = null;
// we consider the schema location properties for import
- if (useProperties) {
+ if (desc.getContextType() == XSDDescription.CONTEXT_IMPORT ||
+ desc.fromInstance()) {
// use empty string as the key for absent namespace
+ String namespace = desc.getTargetNamespace();
String ns = namespace == null ? EMPTY_STRING : namespace;
// get the location hint for that namespace
loc = (String)fLocationPairs.get(ns);
@@ -276,15 +275,16 @@
// if it's not import, or if the target namespace is not set
// in the schema location properties, use location hint
- if (loc == null)
- loc = location;
+ if (loc == null) {
+ String[] hints = desc.getLocationHints();
+ if (hints != null && hints.length > 0)
+ loc = hints[0];
+ }
- // REVISIT: resolve the entity. passing null as public id, instead
- // of passing namespace value. -SG
- // REVISIT: shouldn't we expand the literal systemId (location hint) first? - neilg
- String expandedLoc = XMLEntityManager.expandSystemId(loc, base);
- fResourceIdentifier.setValues(null, loc, base, expandedLoc);
- return fExternalResolver.resolveEntity(fResourceIdentifier);
+ String expandedLoc = XMLEntityManager.expandSystemId(loc, desc.getBaseSystemId());
+ desc.setLiteralSystemId(loc);
+ desc.setExpandedSystemId(expandedLoc);
+ return fExternalResolver.resolveEntity(desc);
}
}
@@ -298,7 +298,7 @@
private XSGrammarBucket fGrammarBucket;
// the Grammar description
- private SchemaGrammarDescription fSchemaGrammarDescription;
+ private XSDDescription fSchemaGrammarDescription;
// the Grammar Pool
private XMLGrammarPool fGrammarPool;
@@ -354,11 +354,11 @@
public XSDHandler (XSGrammarBucket gBucket) {
fGrammarBucket = gBucket;
- // REVISIT: don't use SchemaConfiguration internally
- // we will get stack overflaw because
- // XMLSchemaValidator will be instantiating XSDHandler...
+ // Note: don't use SchemaConfiguration internally
+ // we will get stack overflaw because
+ // XMLSchemaValidator will be instantiating XSDHandler...
fSchemaParser = new DOMParser();
- fSchemaGrammarDescription = new SchemaGrammarDescription();
+ fSchemaGrammarDescription = new XSDDescription();
createTraversers();
} // end constructor
@@ -369,21 +369,28 @@
// in case. An ErrorHandler, EntityResolver, XSGrammarBucket and SymbolTable must
// already have been set; the last thing this method does is reset
// this object (i.e., clean the registries, etc.).
- public SchemaGrammar parseSchema(String schemaNamespace,
- String schemaHint, short referType) {
+ public SchemaGrammar parseSchema(XSDDescription desc) {
XMLInputSource schemaSource=null;
try {
- schemaSource = fLocationResolver.resolveEntity(schemaNamespace, schemaHint, null, true);
+ schemaSource = fLocationResolver.resolveEntity(desc);
}
catch (IOException ex) {
- reportSchemaError(DOC_ERROR_CODES[referType], new Object[]{schemaHint}, null);
+ reportSchemaError(DOC_ERROR_CODES[desc.getContextType()],
+ new Object[]{desc.getLocationHints()[0]},
+ null);
}
- return parseSchema(schemaNamespace, schemaSource, referType);
+ return parseSchema(schemaSource, desc);
} // end parseSchema
- public SchemaGrammar parseSchema(String schemaNamespace,
- XMLInputSource is, short referType) {
-
+ public SchemaGrammar parseSchema(XMLInputSource is, XSDDescription desc) {
+
+ String schemaNamespace = desc.getTargetNamespace();
+ // handle empty string URI as null
+ if (schemaNamespace != null) {
+ schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
+ }
+ short referType = desc.getContextType();
+
// before parsing a schema, need to reset all traversers and
// clear all registries
prepare();
@@ -396,11 +403,7 @@
// something went wrong right off the hop
return null;
}
- // handle empty string URI as null
- if (schemaNamespace != null) {
- schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
- }
- fRoot = constructTrees(schemaRoot, is.getSystemId(), schemaNamespace, referType);
+ fRoot = constructTrees(schemaRoot, is.getSystemId(), desc);
if (fRoot == null) {
return fGrammarBucket.getGrammar(schemaNamespace);
}
@@ -454,8 +457,11 @@
// depends on.
// It also makes sure the targetNamespace of the schema it was
// called to parse is correct.
- protected XSDocumentInfo constructTrees(Document schemaRoot, String locationHint, String callerTNS, short referType) {
+ protected XSDocumentInfo constructTrees(Document schemaRoot, String locationHint, XSDDescription desc) {
if (schemaRoot == null) return null;
+ String callerTNS = desc.getTargetNamespace();
+ short referType = desc.getContextType();
+
XSDocumentInfo currSchemaInfo = null;
try {
currSchemaInfo = new XSDocumentInfo(schemaRoot, fAttributeChecker, fSymbolTable);
@@ -505,14 +511,19 @@
}
// now there is no caller/expected NS, it's an error for the referred
// document to have a target namespace, unless we are preparsing a schema
- else if (currSchemaInfo.fTargetNamespace != null &&
- referType != XSDDescription.CONTEXT_PREPARSE) {
- // the second index to the NS_ERROR_CODES array
- // if the caller/expected NS is absent, we use the second column
- int secondIdx = 1;
- reportSchemaError(NS_ERROR_CODES[referType][secondIdx],
- new Object [] {callerTNS, currSchemaInfo.fTargetNamespace},
- DOMUtil.getRoot(schemaRoot));
+ else if (currSchemaInfo.fTargetNamespace != null) {
+ // set the target namespace of the description
+ if (referType == XSDDescription.CONTEXT_PREPARSE) {
+ desc.setTargetNamespace(currSchemaInfo.fTargetNamespace);
+ }
+ else {
+ // the second index to the NS_ERROR_CODES array
+ // if the caller/expected NS is absent, we use the second column
+ int secondIdx = 1;
+ reportSchemaError(NS_ERROR_CODES[referType][secondIdx],
+ new Object [] {callerTNS, currSchemaInfo.fTargetNamespace},
+ DOMUtil.getRoot(schemaRoot));
+ }
}
// the other cases (callerTNS == currSchemaInfo.fTargetNamespce == null)
// are valid
@@ -521,28 +532,19 @@
currSchemaInfo.addAllowedNS(currSchemaInfo.fTargetNamespace);
SchemaGrammar sg = null;
- SchemaGrammarDescription grammarDescription = null;
// In the case of preparse, if the grammar is not available in the bucket we ask the pool
// If the context is instance, the validator would have already consulted the pool
if ((sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace)) == null && referType == XSDDescription.CONTEXT_PREPARSE) {
if (fGrammarPool != null) {
- fSchemaGrammarDescription.reset();
- fSchemaGrammarDescription.setContextType(referType);
- fSchemaGrammarDescription.setTargetNamespace(currSchemaInfo.fTargetNamespace);
- fSchemaGrammarDescription.setLocationHints(new String[] {locationHint});
- sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(fSchemaGrammarDescription);
+ sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(desc);
if (sg != null) {
fGrammarBucket.putGrammar(sg);
}
}
}
if (sg == null) {
- grammarDescription = new SchemaGrammarDescription();
- grammarDescription.setContextType(referType);
- grammarDescription.setTargetNamespace(currSchemaInfo.fTargetNamespace);
- grammarDescription.setLocationHints(new String[] {locationHint});
- sg = new SchemaGrammar(fSymbolTable, currSchemaInfo.fTargetNamespace, grammarDescription);
+ sg = new SchemaGrammar(fSymbolTable, currSchemaInfo.fTargetNamespace, desc.makeClone());
fGrammarBucket.putGrammar(sg);
}
// we got a grammar of the same namespace in the bucket, should ignore this one
@@ -584,31 +586,12 @@
// a schema document can access it's imported namespaces
currSchemaInfo.addAllowedNS(schemaNamespace);
- // We first ask the GrammarBucket, then the GrammarPool and only then the EntityResolver is consulted
-
fSchemaGrammarDescription.reset();
fSchemaGrammarDescription.setContextType(XSDDescription.CONTEXT_IMPORT);
+ fSchemaGrammarDescription.setBaseSystemId((String)fDoc2SystemId.get(schemaRoot));
+ fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
fSchemaGrammarDescription.setTargetNamespace(schemaNamespace);
- fSchemaGrammarDescription.setLocationHints(new String[] {schemaHint});
- if (fGrammarBucket.getGrammar(schemaNamespace) != null) {
- continue;
- }
- else {
- if (fGrammarPool != null) {
- sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(fSchemaGrammarDescription);
- if (sg != null) {
- fGrammarBucket.putGrammar(sg);
- continue;
- }
- }
- }
- grammarDescription = new SchemaGrammarDescription();
- grammarDescription.setContextType(XSDDescription.CONTEXT_IMPORT);
- grammarDescription.setTargetNamespace(schemaNamespace);
- grammarDescription.setLocationHints(new String[] {schemaHint});
- sg = new SchemaGrammar(fSymbolTable, schemaNamespace, grammarDescription);
- fGrammarBucket.putGrammar(sg);
- newSchemaRoot = getSchema(schemaNamespace, schemaHint, (String)fDoc2SystemId.get(schemaRoot), false, XSDDescription.CONTEXT_IMPORT, child);
+ newSchemaRoot = getSchema(fSchemaGrammarDescription, false, child);
}
else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
(localName.equals(SchemaSymbols.ELT_REDEFINE))) {
@@ -630,7 +613,12 @@
mustResolve = nonAnnotationContent(child);
refType = XSDDescription.CONTEXT_REDEFINE;
}
- newSchemaRoot = getSchema(null, schemaHint, (String)fDoc2SystemId.get(schemaRoot), mustResolve, refType, child);
+ fSchemaGrammarDescription.reset();
+ fSchemaGrammarDescription.setContextType(refType);
+ fSchemaGrammarDescription.setBaseSystemId((String)fDoc2SystemId.get(schemaRoot));
+ fSchemaGrammarDescription.setLocationHints(new String[]{schemaHint});
+ fSchemaGrammarDescription.setTargetNamespace(callerTNS);
+ newSchemaRoot = getSchema(fSchemaGrammarDescription, mustResolve, child);
schemaNamespace = currSchemaInfo.fTargetNamespace;
}
else {
@@ -642,16 +630,12 @@
// If the schema is duplicate, we needn't call constructTrees() again.
// To handle mutual <include>s
- // REVISIT: this creates a bug if the same document is both
- // imported and included. then only the first one takes
- // effect.
-
XSDocumentInfo newSchemaInfo = null;
if (fLastSchemaWasDuplicate) {
newSchemaInfo = (XSDocumentInfo)fDoc2XSDocumentMap.get(newSchemaRoot);
}
else {
- newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, schemaNamespace, refType);
+ newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription);
}
if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
newSchemaInfo != null) {
@@ -1216,41 +1200,40 @@
// if this is the first time it's seen this document, false
// otherwise. schemaDoc is null if and only if no schema document
// was resolved to.
- private Document getSchema(String schemaNamespace, String schemaHint,
- String baseSystemId, boolean mustResolve,
- short referType, Element referElement) {
+ private Document getSchema(XSDDescription desc,
+ boolean mustResolve, Element referElement) {
XMLInputSource schemaSource=null;
try {
- schemaSource = fLocationResolver.resolveEntity(schemaNamespace, schemaHint, baseSystemId,
- referType == XSDDescription.CONTEXT_INSTANCE ||
- referType == XSDDescription.CONTEXT_IMPORT);
+ schemaSource = fLocationResolver.resolveEntity(desc);
}
catch (IOException ex) {
if (mustResolve) {
- reportSchemaError(DOC_ERROR_CODES[referType],
- new Object[]{schemaHint},
+ reportSchemaError(DOC_ERROR_CODES[desc.getContextType()],
+ new Object[]{desc.getLocationHints()[0]},
referElement);
}
else {
- reportSchemaWarning(DOC_ERROR_CODES[referType],
- new Object[]{schemaHint},
+ reportSchemaWarning(DOC_ERROR_CODES[desc.getContextType()],
+ new Object[]{desc.getLocationHints()[0]},
referElement);
}
}
- return getSchema(schemaNamespace, schemaSource, mustResolve, referType, referElement);
+ return getSchema(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
} // getSchema(String, String, String, boolean, short): Document
private Document getSchema(String schemaNamespace, XMLInputSource schemaSource,
boolean mustResolve, short referType, Element referElement) {
+
+ boolean hasInput = true;
// contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
Document schemaDoc = null;
try {
- // REVISIT: when the system id and byte stream and character stream
- // of the input source are all null, it's
- // impossible to find the schema document. so we skip in
- // this case. otherwise we'll receive some NPE or
- // file not found errors. but schemaHint=="" is perfectly
- // legal for import.
+ // when the system id and byte stream and character stream
+ // of the input source are all null, it's
+ // impossible to find the schema document. so we skip in
+ // this case. otherwise we'll receive some NPE or
+ // file not found errors. but schemaHint=="" is perfectly
+ // legal for import.
if (schemaSource != null &&
(schemaSource.getSystemId() != null ||
schemaSource.getByteStream() != null ||
@@ -1283,6 +1266,9 @@
fLastSchemaWasDuplicate = false;
return schemaDoc;
}
+ else {
+ hasInput = false;
+ }
}
catch (IOException ex) {
}
@@ -1294,7 +1280,7 @@
new Object[]{schemaSource.getSystemId()},
referElement);
}
- else {
+ else if (hasInput) {
reportSchemaWarning(DOC_ERROR_CODES[referType],
new Object[]{schemaSource.getSystemId()},
referElement);
@@ -1340,7 +1326,6 @@
fDoc2SystemId.clear();
fDoc2XSDocumentMap.clear();
fRedefine2XSDMap.clear();
- fResourceIdentifier.clear();
fRoot = null;
fLastSchemaWasDuplicate = false;
@@ -1389,7 +1374,6 @@
fErrorReporter = errorReporter;
fSymbolTable = symbolTable;
fGrammarPool = grammarPool;
- fSchemaGrammarDescription.reset();
EMPTY_STRING = fSymbolTable.addSymbol(SchemaSymbols.EMPTY_STRING);
@@ -1400,8 +1384,8 @@
}
catch (Exception e) {
}
-
- //now this part is done in XMLSchemaValidator
+
+ //now this part is done in XMLSchemaValidator
//processJAXPSchemaSource(jaxpSchemaSource, entityResolver);
} // reset(ErrorReporter, EntityResolver, SymbolTable)
@@ -1507,12 +1491,13 @@
checkForDuplicateNames(currSchema.fTargetNamespace+","+newName, registry, currComp, currSchema);
}
else {
- // REVISIT: error that redefined element in wrong schema
+ // error that redefined element in wrong schema
reportSchemaError("src-redefine.1", new Object [] {qName}, currComp);
}
}
}
- else { // we've just got a flat-out collision
+ else {
+ // we've just got a flat-out collision
reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp);
}
}
@@ -1530,8 +1515,6 @@
SchemaNamespaceSupport currNSMap = currSchema.fNamespaceSupport;
if (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
- String processedTypeName = currSchema.fTargetNamespace == null?
- ","+oldName:currSchema.fTargetNamespace+","+oldName;
Element grandKid = DOMUtil.getFirstChildElement(child);
if (grandKid == null) {
reportSchemaError("src-redefine.5", null, child);
@@ -1549,27 +1532,27 @@
reportSchemaError("src-redefine.5", null, child);
}
else {
- String derivedBase = grandKid.getAttribute( SchemaSymbols.ATT_BASE );
- String processedDerivedBase = findQName(derivedBase, currSchema);
- if (!processedTypeName.equals(processedDerivedBase)) {
+ Object[] attrs = fAttributeChecker.checkAttributes(grandKid, false, currSchema);
+ QName derivedBase = (QName)attrs[XSAttributeChecker.ATTIDX_BASE];
+ if (derivedBase == null ||
+ derivedBase.uri != currSchema.fTargetNamespace ||
+ !derivedBase.localpart.equals(oldName)) {
reportSchemaError("src-redefine.5", null, child);
}
else {
// now we have to do the renaming...
- int colonptr = derivedBase.indexOf(":");
- if (colonptr > 0)
+ if (derivedBase.prefix != null && derivedBase.prefix.length() > 0)
grandKid.setAttribute( SchemaSymbols.ATT_BASE,
- derivedBase.substring(0,colonptr) + ":" + newName );
+ derivedBase.prefix + ":" + newName );
else
grandKid.setAttribute( SchemaSymbols.ATT_BASE, newName );
// return true;
}
+ fAttributeChecker.returnAttrArray(attrs, currSchema);
}
}
}
else if (componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
- String processedTypeName = currSchema.fTargetNamespace == null?
- ","+oldName:currSchema.fTargetNamespace+","+oldName;
Element grandKid = DOMUtil.getFirstChildElement(child);
if (grandKid == null) {
reportSchemaError("src-redefine.5", null, child);
@@ -1601,17 +1584,18 @@
reportSchemaError("src-redefine.5", null, greatGrandKid);
}
else {
- String derivedBase = greatGrandKid.getAttribute( SchemaSymbols.ATT_BASE );
- String processedDerivedBase = findQName(derivedBase, currSchema);
- if (!processedTypeName.equals(processedDerivedBase)) {
+ Object[] attrs = fAttributeChecker.checkAttributes(greatGrandKid, false, currSchema);
+ QName derivedBase = (QName)attrs[XSAttributeChecker.ATTIDX_BASE];
+ if (derivedBase == null ||
+ derivedBase.uri != currSchema.fTargetNamespace ||
+ !derivedBase.localpart.equals(oldName)) {
reportSchemaError("src-redefine.5", null, greatGrandKid);
}
else {
// now we have to do the renaming...
- int colonptr = derivedBase.indexOf(":");
- if (colonptr > 0)
+ if (derivedBase.prefix != null && derivedBase.prefix.length() > 0)
greatGrandKid.setAttribute( SchemaSymbols.ATT_BASE,
- derivedBase.substring(0,colonptr) + ":" + newName );
+ derivedBase.prefix + ":" + newName );
else
greatGrandKid.setAttribute( SchemaSymbols.ATT_BASE,
newName );
@@ -1888,51 +1872,4 @@
}
}
- /**
- * This inner class extends XSDDescription and provides set methods for setting the
- * protected fields of XSDDescription. It is declared private, so as, not to expose set*
- * methods outside this class. XSDDescription is for providing the read only information
- * to the application about Schema Grammar required by the parser. Application uses this info
- * in making decisions about caching/retrieving appropriate grammar. XSDHanlder will make use
- * of this class to provide information and give a chance to application to supply
- * SchemaGrammar required by parser.
- *
- * @author Neeraj Bajaj SUN Microsystems.
- *
- */
- private class SchemaGrammarDescription extends XSDDescription {
-
-
- public void setContextType(short contextType){
- fContextType = contextType ;
- }
-
- public void setTargetNamespace(String targetNamespace){
- fTargetNamespace = targetNamespace ;
- }
-
- public void setLocationHints(String [] locationHints){
- int length = locationHints.length ;
- fLocationHints = new String[length];
- System.arraycopy(locationHints, 0, fLocationHints, 0, length);
- //fLocationHints = locationHints ;
- }
-
- public void setTriggeringComponent(QName triggeringComponent){
- fTriggeringComponent = triggeringComponent ;
- }
-
- public void setEnclosingElementName(QName enclosedElementName){
- fEnclosedElementName = enclosedElementName ;
- }
-
- public void setAttributes(XMLAttributes attributes){
- fAttributes = attributes ;
- }
-
- public void reset(){
- super.reset();
- }
-
- }//SchemaGrammarDescription
} // XSDHandler
1.13 +3 -12 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSDSimpleTypeTraverser.java 15 Feb 2002 22:08:48 -0000 1.12
+++ XSDSimpleTypeTraverser.java 15 Mar 2002 23:01:58 -0000 1.13
@@ -115,7 +115,7 @@
*
* @author Elena Litani, IBM
* @author Neeraj Bajaj, Sun Microsystems, Inc.
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.12 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.13 2002/03/15 23:01:58 sandygao Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -172,22 +172,13 @@
qualifiedName = schemaDoc.fTargetNamespace == null?
",#s#"+(fSimpleTypeAnonCount++):
schemaDoc.fTargetNamespace+",#S#"+(fSimpleTypeAnonCount++);
- //REVISIT:
- // add to symbol table?
}
else {
qualifiedName = schemaDoc.fTargetNamespace == null?
","+nameProperty:
schemaDoc.fTargetNamespace+","+nameProperty;
- //REVISIT:
- // add to symbol table?
-
}
- //----------------------------------------------------------
- // REVISIT!
- // update _final_ registry
- //----------------------------------------------------------
XInt finalAttr = (XInt)attrValues[XSAttributeChecker.ATTIDX_FINAL];
int finalProperty = finalAttr == null ? schemaDoc.fFinalDefault : finalAttr.intValue();
@@ -210,8 +201,6 @@
// General Attribute Checking
Object[] contentAttrs = fAttrChecker.checkAttributes(content, false, schemaDoc);
- // REVISIT: when to return the array
- fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
//----------------------------------------------------------------------
//use content.getLocalName for the cases there "xsd:" is a prefix, ei. "xsd:list"
@@ -258,6 +247,8 @@
Object[] args = { varietyProperty};
reportSchemaError("dt-unsupported-derivation", args, content);
}
+ fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
+
if (DOMUtil.getNextSiblingElement(content) != null) {
reportSchemaError("dt-simpleType", new Object[]{SchemaSymbols.ELT_SIMPLETYPE, nameProperty, "(annotation?, (restriction | list | union))"}, content);
}
1.9 +4 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java
Index: XSDocumentInfo.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDocumentInfo.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSDocumentInfo.java 29 Jan 2002 20:24:57 -0000 1.8
+++ XSDocumentInfo.java 15 Mar 2002 23:01:58 -0000 1.9
@@ -77,7 +77,7 @@
* affect the contents of that schema document alone.
*
* @author Neil Graham, IBM
- * @version $Id: XSDocumentInfo.java,v 1.8 2002/01/29 20:24:57 sandygao Exp $
+ * @version $Id: XSDocumentInfo.java,v 1.9 2002/03/15 23:01:58 sandygao Exp $
*/
class XSDocumentInfo {
@@ -151,8 +151,9 @@
//set namespace support
fValidationContext.setNamespaceSupport(fNamespaceSupport);
fValidationContext.setSymbolTable(symbolTable);
- // REVISIT: we can't return, becaues we can't pop fNamespaceSupport
- //attrChecker.returnAttrArray(schemaAttrs, this);
+ // pass null as the schema document, so that the namespace
+ // context is not popped.
+ attrChecker.returnAttrArray(schemaAttrs, null);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org