gdaniels 2003/02/18 05:19:37
Modified: java/src/org/apache/axis/encoding
DeserializationContextImpl.java
Log:
A start at fixing problems with mulitple schema versions. Make sure that
the correct SchemaVersion gets associated with a message context
when deserializing, by assuming that the first schema namespace
declaration we see is the base schema version for this interaction.
Revision Changes Path
1.74 +28 -0
xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
Index: DeserializationContextImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- DeserializationContextImpl.java 16 Jan 2003 23:47:28 -0000 1.73
+++ DeserializationContextImpl.java 18 Feb 2003 13:19:37 -0000 1.74
@@ -58,6 +58,7 @@
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
+import org.apache.axis.schema.SchemaVersion;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.message.EnvelopeBuilder;
@@ -100,6 +101,12 @@
protected static Log log =
LogFactory.getLog(DeserializationContextImpl.class.getName());
+ static final SchemaVersion schemaVersions[] = new SchemaVersion [] {
+ SchemaVersion.SCHEMA_1999,
+ SchemaVersion.SCHEMA_2000,
+ SchemaVersion.SCHEMA_2001,
+ };
+
private NSStack namespaces = new NSStack();
private Locator locator;
@@ -130,6 +137,11 @@
protected int startOfMappingsPos = -1;
+ // This is a hack to associate the first schema namespace we see with
+ // the correct SchemaVersion. It assumes people won't often be mixing
+ // schema versions in a given document, which I think is OK. --Glen
+ protected boolean haveSeenSchemaNS = false;
+
public void deserializing(boolean isDeserializing) {
doneParsing = isDeserializing;
}
@@ -803,6 +815,22 @@
namespaces.add(uri, "");
}
+ if (!haveSeenSchemaNS && msgContext != null) {
+ // If we haven't yet seen a schema namespace, check if this
+ // is one. If so, set the SchemaVersion appropriately.
+ // Hopefully the schema def is on the outermost element so we
+ // get this over with quickly.
+ for (int i = 0; !haveSeenSchemaNS && i < schemaVersions.length;
+ i++) {
+ SchemaVersion schemaVersion = schemaVersions[i];
+ if (uri.equals(schemaVersion.getXsdURI()) ||
+ uri.equals(schemaVersion.getXsiURI())) {
+ msgContext.setSchemaVersion(schemaVersion);
+ haveSeenSchemaNS = true;
+ }
+ }
+ }
+
if (topHandler != null) {
topHandler.startPrefixMapping(prefix, uri);
}