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 2003/03/24 22:10:59 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/xni XMLResourceIdentifier.java
sandygao 2003/03/24 13:10:59
Modified: java/src/org/apache/xerces/impl/xs SchemaGrammar.java
XMLSchemaValidator.java XSDDescription.java
java/src/org/apache/xerces/util
XMLResourceIdentifierImpl.java
java/src/org/apache/xerces/xni XMLResourceIdentifier.java
Log:
Introducing 2 new methods on XMLResourceIdentifier, to get/set
the namespace information, which is useful when the resource is some kind
of namespace-aware grammar.
Also re-organizing some import statements for readability, and removing some
local variables that are never referenced.
Revision Changes Path
1.29 +4 -5 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- SchemaGrammar.java 16 Jan 2003 23:59:03 -0000 1.28
+++ SchemaGrammar.java 24 Mar 2003 21:10:58 -0000 1.29
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -182,7 +182,7 @@
// grammar description
fGrammarDescription = new XSDDescription();
fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
- fGrammarDescription.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
+ fGrammarDescription.setNamespace(SchemaSymbols.URI_SCHEMAFORSCHEMA);
// no global decls other than types
fGlobalAttrDecls = new SymbolHash(1);
@@ -203,7 +203,7 @@
// grammar description
fGrammarDescription = new XSDDescription();
fGrammarDescription.fContextType = XSDDescription.CONTEXT_PREPARSE;
- fGrammarDescription.fTargetNamespace = SchemaSymbols.URI_XSI;
+ fGrammarDescription.setNamespace(SchemaSymbols.URI_XSI);
// no global decls other than attributes
fGlobalAttrGrpDecls = new SymbolHash(1);
@@ -218,7 +218,6 @@
String name = null;
String tns = null;
XSSimpleType type = null;
- short constraint = XSConstants.VC_NONE;
short scope = XSConstants.SCOPE_GLOBAL;
// xsi:type
1.137 +31 -37 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.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- XMLSchemaValidator.java 11 Mar 2003 15:49:32 -0000 1.136
+++ XMLSchemaValidator.java 24 Mar 2003 21:10:58 -0000 1.137
@@ -57,68 +57,63 @@
package org.apache.xerces.impl.xs;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.RevalidationHandler;
-import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.ValidatedInfo;
+import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.dv.DatatypeException;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.xerces.impl.xs.identity.*;
-import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.dv.ValidatedInfo;
+import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.validation.ValidationManager;
-import org.apache.xerces.util.XMLGrammarPoolImpl;
-import org.apache.xerces.impl.XMLErrorReporter;
-import org.apache.xerces.impl.xs.traversers.XSAttributeChecker;
+import org.apache.xerces.impl.validation.ValidationState;
+import org.apache.xerces.impl.xs.identity.Field;
+import org.apache.xerces.impl.xs.identity.FieldActivator;
+import org.apache.xerces.impl.xs.identity.IDValue;
+import org.apache.xerces.impl.xs.identity.IdentityConstraint;
+import org.apache.xerces.impl.xs.identity.KeyRef;
+import org.apache.xerces.impl.xs.identity.Selector;
+import org.apache.xerces.impl.xs.identity.UniqueOrKey;
+import org.apache.xerces.impl.xs.identity.ValueStore;
+import org.apache.xerces.impl.xs.identity.XPathMatcher;
import org.apache.xerces.impl.xs.models.CMBuilder;
+import org.apache.xerces.impl.xs.models.CMNodeFactory;
import org.apache.xerces.impl.xs.models.XSCMValidator;
import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
-import org.apache.xerces.impl.msg.XMLMessageFormatter;
-import org.apache.xerces.impl.validation.ValidationState;
-import org.apache.xerces.impl.XMLEntityManager;
-
-
import org.apache.xerces.util.AugmentationsImpl;
+import org.apache.xerces.util.IntStack;
import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.util.XMLSymbols;
+import org.apache.xerces.util.XMLAttributesImpl;
import org.apache.xerces.util.XMLChar;
-import org.apache.xerces.util.IntStack;
import org.apache.xerces.util.XMLResourceIdentifierImpl;
-import org.apache.xerces.util.XMLAttributesImpl;
-
+import org.apache.xerces.util.XMLSymbols;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentHandler;
-import org.apache.xerces.xni.parser.XMLDocumentFilter;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XMLResourceIdentifier;
+import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XNIException;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.apache.xerces.xni.parser.XMLComponent;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLConfigurationException;
+import org.apache.xerces.xni.parser.XMLDocumentFilter;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
-
-import org.apache.xerces.xni.grammars.XMLGrammarPool;
-import org.apache.xerces.xni.grammars.Grammar;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-
-
-import org.apache.xerces.xni.psvi.ElementPSVI;
import org.apache.xerces.xni.psvi.AttributePSVI;
-
-import org.xml.sax.InputSource ;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Stack;
-import java.util.Vector;
-import java.io.IOException;
-import org.apache.xerces.impl.xs.models.CMNodeFactory;
+import org.apache.xerces.xni.psvi.ElementPSVI;
/**
* The XML Schema validator. The validator implements a document
@@ -2327,7 +2322,7 @@
if (grammar == null){
fXSDDescription.reset();
fXSDDescription.fContextType = contextType ;
- fXSDDescription.fTargetNamespace = namespace ;
+ fXSDDescription.setNamespace(namespace);
fXSDDescription.fEnclosedElementName = enclosingElement ;
fXSDDescription.fTriggeringComponent = triggeringComponet ;
fXSDDescription.fAttributes = attributes ;
@@ -2872,7 +2867,6 @@
}
}
else if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
- XSSimpleType sType = (XSSimpleType)fCurrentType;
if (actualValue != null &&
!actualValue.equals(fCurrentElemDecl.fDefault.actualValue))
// REVISIT: the spec didn't mention this case: fixed
1.9 +12 -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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSDDescription.java 7 Jan 2003 22:47:11 -0000 1.8
+++ XSDDescription.java 24 Mar 2003 21:10:58 -0000 1.9
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2002 The Apache Software Foundation.
+ * Copyright (c) 2002, 2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,11 +57,11 @@
package org.apache.xerces.impl.xs;
-import org.apache.xerces.xni.grammars.XMLSchemaDescription;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
import org.apache.xerces.util.XMLResourceIdentifierImpl;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.grammars.XMLSchemaDescription;
/*
* All information specific to XML Schema grammars.
@@ -131,7 +131,6 @@
// REVISIT: write description of these fields
protected short fContextType;
- protected String fTargetNamespace;
protected String [] fLocationHints ;
protected QName fTriggeringComponent;
protected QName fEnclosedElementName;
@@ -164,7 +163,7 @@
* @return the expected/enclosing target namespace
*/
public String getTargetNamespace() {
- return fTargetNamespace ;
+ return fNamespace;
}
/**
@@ -227,9 +226,9 @@
public boolean equals(Object descObj) {
if(!(descObj instanceof XMLSchemaDescription)) return false;
XMLSchemaDescription desc = (XMLSchemaDescription)descObj;
- if (fTargetNamespace != null)
- return fTargetNamespace.equals(desc.getTargetNamespace());
- else // fTargetNamespace == null
+ if (fNamespace != null)
+ return fNamespace.equals(desc.getTargetNamespace());
+ else // fNamespace == null
return desc.getTargetNamespace() == null;
}
@@ -239,7 +238,7 @@
* @return The hash code
*/
public int hashCode() {
- return (fTargetNamespace == null) ? 0 : fTargetNamespace.hashCode();
+ return (fNamespace == null) ? 0 : fNamespace.hashCode();
}
public void setContextType(short contextType){
@@ -247,7 +246,7 @@
}
public void setTargetNamespace(String targetNamespace){
- fTargetNamespace = targetNamespace ;
+ fNamespace = targetNamespace ;
}
public void setLocationHints(String [] locationHints){
@@ -273,8 +272,8 @@
* resets all the fields
*/
public void reset(){
+ super.clear();
fContextType = CONTEXT_INITIALIZE;
- fTargetNamespace = null ;
fLocationHints = null ;
fTriggeringComponent = null ;
fEnclosedElementName = null ;
@@ -291,7 +290,7 @@
desc.fLiteralSystemId = this.fLiteralSystemId;
desc.fLocationHints = this.fLocationHints;
desc.fPublicId = this.fPublicId;
- desc.fTargetNamespace = this.fTargetNamespace;
+ desc.fNamespace = this.fNamespace;
desc.fTriggeringComponent = this.fTriggeringComponent;
return desc;
}
1.2 +52 -5 xml-xerces/java/src/org/apache/xerces/util/XMLResourceIdentifierImpl.java
Index: XMLResourceIdentifierImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/XMLResourceIdentifierImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLResourceIdentifierImpl.java 22 Jan 2002 16:42:27 -0000 1.1
+++ XMLResourceIdentifierImpl.java 24 Mar 2003 21:10:59 -0000 1.2
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002, 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -87,6 +87,9 @@
/** The expanded system identifier. */
protected String fExpandedSystemId;
+ /** The namespace of the resource. */
+ protected String fNamespace;
+
//
// Constructors
//
@@ -105,9 +108,26 @@
public XMLResourceIdentifierImpl(String publicId,
String literalSystemId, String baseSystemId,
String expandedSystemId) {
- setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
+ setValues(publicId, literalSystemId, baseSystemId,
+ expandedSystemId, null);
} // <init>(String,String,String,String)
+ /**
+ * Constructs a resource identifier.
+ *
+ * @param publicId The public identifier.
+ * @param literalSystemId The literal system identifier.
+ * @param baseSystemId The base system identifier.
+ * @param expandedSystemId The expanded system identifier.
+ * @param namespace The namespace.
+ */
+ public XMLResourceIdentifierImpl(String publicId, String literalSystemId,
+ String baseSystemId, String expandedSystemId,
+ String namespace) {
+ setValues(publicId, literalSystemId, baseSystemId,
+ expandedSystemId, namespace);
+ } // <init>(String,String,String,String,String)
+
//
// Public methods
//
@@ -115,11 +135,20 @@
/** Sets the values of the resource identifier. */
public void setValues(String publicId, String literalSystemId,
String baseSystemId, String expandedSystemId) {
+ setValues(publicId, literalSystemId, baseSystemId,
+ expandedSystemId, null);
+ } // setValues(String,String,String,String)
+
+ /** Sets the values of the resource identifier. */
+ public void setValues(String publicId, String literalSystemId,
+ String baseSystemId, String expandedSystemId,
+ String namespace) {
fPublicId = publicId;
fLiteralSystemId = literalSystemId;
fBaseSystemId = baseSystemId;
fExpandedSystemId = expandedSystemId;
- } // setValues(String,String,String,String)
+ fNamespace = namespace;
+ } // setValues(String,String,String,String,String)
/** Clears the values. */
public void clear() {
@@ -127,6 +156,7 @@
fLiteralSystemId = null;
fBaseSystemId = null;
fExpandedSystemId = null;
+ fNamespace = null;
} // clear()
/** Sets the public identifier. */
@@ -149,6 +179,11 @@
fExpandedSystemId = expandedSystemId;
} // setExpandedSystemId(String)
+ /** Sets the namespace of the resource. */
+ public void setNamespace(String namespace) {
+ fNamespace = namespace;
+ } // setNamespace(String)
+
//
// XMLResourceIdentifier methods
//
@@ -175,6 +210,11 @@
return fExpandedSystemId;
} // getExpandedSystemId():String
+ /** Returns the namespace of the resource. */
+ public String getNamespace() {
+ return fNamespace;
+ } // getNamespace():String
+
//
// Object methods
//
@@ -194,6 +234,9 @@
if (fExpandedSystemId != null) {
code += fExpandedSystemId.hashCode();
}
+ if (fNamespace != null) {
+ code += fNamespace.hashCode();
+ }
return code;
} // hashCode():int
@@ -215,7 +258,11 @@
if (fExpandedSystemId != null) {
str.append(fExpandedSystemId);
}
+ str.append(':');
+ if (fNamespace != null) {
+ str.append(fNamespace);
+ }
return str.toString();
} // toString():String
-} // class XMLAttributesImpl
+} // class XMLResourceIdentifierImpl
1.3 +9 -2 xml-xerces/java/src/org/apache/xerces/xni/XMLResourceIdentifier.java
Index: XMLResourceIdentifier.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/XMLResourceIdentifier.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLResourceIdentifier.java 16 Dec 2002 01:26:21 -0000 1.2
+++ XMLResourceIdentifier.java 24 Mar 2003 21:10:59 -0000 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -92,4 +92,11 @@
/** <p> Returns the base URI against which the literal SystemId is to be
resolved. </p> */
public String getBaseSystemId();
+
+ /** Sets the namespace of the resource. */
+ public void setNamespace(String namespace);
+
+ /** Returns the namespace of the resource. */
+ public String getNamespace();
+
} // XMLResourceIdentifier
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org