duftler     2002/06/09 22:59:01

  Modified:    java/src/org/apache/soap/encoding/soapenc SoapEncUtils.java
  Log:
  Fixed a NullPointerException problem that my changes created.
  
  Revision  Changes    Path
  1.11      +28 -8     
xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java
  
  Index: SoapEncUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SoapEncUtils.java 10 Jun 2002 03:52:56 -0000      1.10
  +++ SoapEncUtils.java 10 Jun 2002 05:59:00 -0000      1.11
  @@ -161,8 +161,15 @@
   
       // Get prefixes for the needed namespaces.
       String elementTypeNS = elementType.getNamespaceURI();
  -    String xsiNSPrefix = nsStack.getPrefixFromURI(elementTypeNS + "-instance",
  -                                                  sink);
  +    String xsiNamespaceURI = Constants.NS_URI_CURRENT_SCHEMA_XSI;
  +
  +    if (elementTypeNS.startsWith("http://www.w3.org/";)
  +        && elementTypeNS.endsWith("/XMLSchema"))
  +    {
  +      xsiNamespaceURI = elementTypeNS + "-instance";
  +    }
  +
  +    String xsiNSPrefix = nsStack.getPrefixFromURI(xsiNamespaceURI, sink);
       String elementTypeNSPrefix = nsStack.getPrefixFromURI(elementTypeNS, sink);
   
       sink.write(' ' + xsiNSPrefix + ':' + Constants.ATTR_TYPE + "=\"" +
  @@ -198,26 +205,39 @@
   
       if (isNull)
       {
  -      sink.write(' ' + xsiNSPrefix + ':' + nilName(elementTypeNS) + "=\"" +
  +      sink.write(' ' + xsiNSPrefix + ':' + nilName(xsiNamespaceURI) + "=\"" +
                    Constants.ATTRVAL_TRUE + "\"/");
       }
   
       sink.write('>');
     }
   
  -  private static String nilName(String currentSchemaXSD)
  +  private static String nilName(String currentSchemaXSI)
     {
  -    return (currentSchemaXSD == Constants.NS_URI_2001_SCHEMA_XSD)
  +    return (currentSchemaXSI.equals(Constants.NS_URI_2001_SCHEMA_XSI))
              ? Constants.ATTR_NIL
              : Constants.ATTR_NULL;
     }
   
     public static boolean isNull(Element element)
     {
  -    String elementTypeNS = getTypeQName(element).getNamespaceURI();
       String nullValue = DOMUtils.getAttributeNS(element,
  -                                               elementTypeNS + "-instance",
  -                                               nilName(elementTypeNS));
  +                                               Constants.NS_URI_2001_SCHEMA_XSI,
  +                                               Constants.ATTR_NIL);
  +
  +    if (nullValue == null)
  +    {
  +      nullValue = DOMUtils.getAttributeNS(element,
  +                                          Constants.NS_URI_2000_SCHEMA_XSI,
  +                                          Constants.ATTR_NULL);
  +    }
  +
  +    if (nullValue == null)
  +    {
  +      nullValue = DOMUtils.getAttributeNS(element,
  +                                          Constants.NS_URI_1999_SCHEMA_XSI,
  +                                          Constants.ATTR_NULL);
  +    }
   
       return nullValue != null && decodeBooleanValue(nullValue);
     }
  
  
  


Reply via email to