gdaniels 2002/06/30 11:15:46 Modified: java/src/org/apache/axis/encoding SerializationContextImpl.java DeserializerImpl.java java/src/org/apache/axis MessageContext.java Constants.java Added: java/src/org/apache/axis/schema SchemaVersion2001.java SchemaVersion2000.java SchemaVersion1999.java SchemaVersion.java Log: Rough in the beginnings of dynamic schema support. For now, the only real functionality is getting the "null" QName. Introduce the SchemaVersion class, which is associated with MessageContexts and SerializationContexts and provides version- specific schema constants and behavior. The implicit assumption here is that for a given piece of processing (a single request), only one schema version will be active. (We make this same assumption about SOAP versions) Revision Changes Path 1.35 +11 -1 xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java Index: SerializationContextImpl.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- SerializationContextImpl.java 27 Jun 2002 17:22:32 -0000 1.34 +++ SerializationContextImpl.java 30 Jun 2002 18:15:46 -0000 1.35 @@ -59,6 +59,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.soap.SOAPConstants; import org.apache.axis.wsdl.symbolTable.SymbolTable; import org.apache.axis.enum.Style; @@ -177,6 +178,11 @@ private boolean outputMultiRefsFlag = false; /** + * Which schema version are we using? + */ + SchemaVersion schemaVersion = SchemaVersion.SCHEMA_2001; + + /** * Construct SerializationContextImpl with associated writer * @param writer java.io.Writer */ @@ -198,6 +204,9 @@ AxisEngine engine = null ; if ( msgContext != null ) { + // Use whatever schema is associated with this MC + schemaVersion = msgContext.getSchemaVersion(); + engine = msgContext.getAxisEngine(); Boolean shouldSendDecl = (Boolean)engine.getOption( AxisEngine.PROP_XML_DECL); @@ -556,7 +565,8 @@ attrs.setAttributes(attributes); if (sendType) attrs = (AttributesImpl) setTypeAttribute(attrs, xmlType); - attrs.addAttribute(Constants.URI_2001_SCHEMA_XSI, "nil", "xsi:nil", + String nil = schemaVersion.getNilQName().getLocalPart(); + attrs.addAttribute(schemaVersion.getXsiURI(), nil, "xsi:" + nil, "CDATA", "true"); startElement(elemQName, attrs); endElement(); 1.20 +6 -10 xml-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java Index: DeserializerImpl.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- DeserializerImpl.java 27 Jun 2002 23:10:36 -0000 1.19 +++ DeserializerImpl.java 30 Jun 2002 18:15:46 -0000 1.20 @@ -318,17 +318,13 @@ { super.startElement(namespace, localName, qName, attributes, context); - // If the xsi:nil attribute, set the value to null and return since - // there is nothing to deserialize. + // If the nil attribute is present and true, set the value to null + // and return since there is nothing to deserialize. if (JavaUtils.isTrueExplicitly(Constants.getValue(attributes, - Constants.URIS_SCHEMA_XSI, - "nil")) || - JavaUtils.isTrueExplicitly(Constants.getValue(attributes, - Constants.URIS_SCHEMA_XSI, - "null"))) { - value = null; - isNil = true; - return; + Constants.QNAMES_NIL))) { + value = null; + isNil = true; + return; } // If this element has an id, then associate the value with the id. 1.1 xml-axis/java/src/org/apache/axis/schema/SchemaVersion2001.java Index: SchemaVersion2001.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 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/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.axis.schema; import org.apache.axis.Constants; import javax.xml.namespace.QName; /** * 2001 Schema characteristics. * * @author Glen Daniels ([EMAIL PROTECTED]) */ public class SchemaVersion2001 implements SchemaVersion { public static QName QNAME_NIL = new QName(Constants.URI_2001_SCHEMA_XSI, "nil"); /** * Package-access constructor - access this through SchemaVersion * constants. */ SchemaVersion2001() { } /** * Get the appropriate QName for the "null"/"nil" attribute for this * Schema version. * @return */ public QName getNilQName() { return QNAME_NIL; } /** * The XSI URI * @return */ public String getXsiURI() { return Constants.URI_2001_SCHEMA_XSI; } /** * The XSD URI * @return */ public String getXsdURI() { return Constants.URI_2001_SCHEMA_XSD; } } 1.1 xml-axis/java/src/org/apache/axis/schema/SchemaVersion2000.java Index: SchemaVersion2000.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 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/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.axis.schema; import org.apache.axis.Constants; import javax.xml.namespace.QName; /** * 2000 Schema characteristics. * * @author Glen Daniels ([EMAIL PROTECTED]) */ public class SchemaVersion2000 implements SchemaVersion { public static QName QNAME_NIL = new QName(Constants.URI_2000_SCHEMA_XSI, "null"); /** * Package-access constructor - access this through SchemaVersion * constants. */ SchemaVersion2000() { } /** * Get the appropriate QName for the "null"/"nil" attribute for this * Schema version. * @return */ public QName getNilQName() { return QNAME_NIL; } /** * The XSI URI * @return */ public String getXsiURI() { return Constants.URI_2000_SCHEMA_XSI; } /** * The XSD URI * @return */ public String getXsdURI() { return Constants.URI_2000_SCHEMA_XSD; } } 1.1 xml-axis/java/src/org/apache/axis/schema/SchemaVersion1999.java Index: SchemaVersion1999.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 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/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.axis.schema; import org.apache.axis.Constants; import javax.xml.namespace.QName; /** * 1999 Schema characteristics. * * @author Glen Daniels ([EMAIL PROTECTED]) */ public class SchemaVersion1999 implements SchemaVersion { public static QName QNAME_NIL = new QName(Constants.URI_1999_SCHEMA_XSI, "null"); /** * Package-access constructor - access this through SchemaVersion * constants. */ SchemaVersion1999() { } /** * Get the appropriate QName for the "null"/"nil" attribute for this * Schema version. * @return */ public QName getNilQName() { return QNAME_NIL; } /** * The XSI URI * @return */ public String getXsiURI() { return Constants.URI_1999_SCHEMA_XSI; } /** * The XSD URI * @return */ public String getXsdURI() { return Constants.URI_1999_SCHEMA_XSD; } } 1.1 xml-axis/java/src/org/apache/axis/schema/SchemaVersion.java Index: SchemaVersion.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 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/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.axis.schema; import javax.xml.namespace.QName; /** * The SchemaVersion interface allows us to abstract out the differences * between the 1999, 2000, and 2001 versions of XML Schema. * * @author Glen Daniels ([EMAIL PROTECTED]) */ public interface SchemaVersion { public static SchemaVersion SCHEMA_1999 = new SchemaVersion1999(); public static SchemaVersion SCHEMA_2000 = new SchemaVersion2000(); public static SchemaVersion SCHEMA_2001 = new SchemaVersion2001(); /** * Get the appropriate QName for the "null"/"nil" attribute for this * Schema version. * @return */ public QName getNilQName(); /** * The XSI URI * @return */ public String getXsiURI(); /** * The XSD URI * @return */ public String getXsdURI(); } 1.105 +15 -3 xml-axis/java/src/org/apache/axis/MessageContext.java Index: MessageContext.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- MessageContext.java 21 Jun 2002 19:48:39 -0000 1.104 +++ MessageContext.java 30 Jun 2002 18:15:46 -0000 1.105 @@ -67,6 +67,7 @@ import org.apache.axis.soap.SOAPConstants; import org.apache.axis.utils.JavaUtils; import org.apache.axis.utils.LockableHashtable; +import org.apache.axis.schema.SchemaVersion; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -188,6 +189,8 @@ /** Our SOAP namespaces and such - defaults to SOAP 1.1 */ private SOAPConstants soapConstants = new SOAP11Constants(); + /** Schema version information - defaults to 2001 */ + private SchemaVersion schemaVersion = SchemaVersion.SCHEMA_2001; private OperationDesc currentOperation = null; @@ -354,6 +357,18 @@ } /** + * Schema version information + */ + + public SchemaVersion getSchemaVersion() { + return schemaVersion; + } + + public void setSchemaVersion(SchemaVersion schemaVersion) { + this.schemaVersion = schemaVersion; + } + + /** * Sessions */ public Session getSession() @@ -461,9 +476,6 @@ /** * Sets the SOAPMessage for this message context * @param message Request SOAP message - * @throws JAXRPCException If any error during the setting - * of the request message or if invalid SOAPMessage - * is set * @throws java.lang.UnsupportedOperationException If this * operation is not supported */ 1.66 +30 -0 xml-axis/java/src/org/apache/axis/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- Constants.java 28 Jun 2002 23:27:25 -0000 1.65 +++ Constants.java 30 Jun 2002 18:15:46 -0000 1.66 @@ -56,6 +56,9 @@ package org.apache.axis; import org.xml.sax.Attributes; +import org.apache.axis.schema.SchemaVersion1999; +import org.apache.axis.schema.SchemaVersion2000; +import org.apache.axis.schema.SchemaVersion2001; import javax.xml.namespace.QName; @@ -163,6 +166,28 @@ } /** + * Search an attribute collection for a list of QNames, returning + * the value of the first one found, or null if none were found. + * + * @param attributes + * @param search + * @return + */ + public static String getValue(Attributes attributes, + QName [] search) { + if (attributes == null || search == null) + return null; + + String value = null; + for (int i=0; (value == null) && (i < search.length); i++) { + value = attributes.getValue(search[i].getNamespaceURI(), + search[i].getLocalPart()); + } + + return value; + } + + /** * equals * The first QName is the current version of the name. The second qname is compared * with the first considering all namespace uri versions. @@ -241,6 +266,11 @@ URI_1999_SCHEMA_XSD, URI_2000_SCHEMA_XSD, URI_2001_SCHEMA_XSD, + }; + public static final QName [] QNAMES_NIL = { + SchemaVersion1999.QNAME_NIL, + SchemaVersion2000.QNAME_NIL, + SchemaVersion2001.QNAME_NIL }; /**