axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r439444 - /webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Date Fri, 01 Sep 2006 19:52:39 GMT
Author: dims
Date: Fri Sep  1 12:52:38 2006
New Revision: 439444

URL: http://svn.apache.org/viewvc?rev=439444&view=rev
Log:
Fix for AXIS2-1054 - WSDL2Java: Correct support for optional and any attributes

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=439444&r1=439443&r2=439444&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Fri Sep  1 12:52:38 2006
@@ -268,7 +268,7 @@
                                    </xsl:otherwise>
                                </xsl:choose>
 
-                            } catch (Exception e) {
+                            } catch (java.lang.Exception e) {
                                 throw new java.lang.IllegalArgumentException();
                             }
                         }
@@ -543,17 +543,27 @@
                                                      <xsl:value-of select="$varName"/>.getAttributeValue(),
                                                      xmlWriter);
                         </xsl:when>
-                         <xsl:when test="@any and @array">
+                        <xsl:when test="@any and @array">
 							 if (<xsl:value-of select="$varName"/> != null) {
-                             for (int i=0;i &lt;<xsl:value-of select="$varName"/>.length;i++){
-                              writeAttribute(<xsl:value-of select="$varName"/>[i].getNamespace().getName(),
-                                                     <xsl:value-of select="$varName"/>[i].getLocalName(),
-                                                     <xsl:value-of select="$varName"/>[i].getAttributeValue(),
-                                                  xmlWriter);
-                             }
+								 for (int i=0;i &lt;<xsl:value-of select="$varName"/>.length;i++){
+									 writeAttribute(<xsl:value-of select="$varName"/>[i].getNamespace().getName(),
+                                                    <xsl:value-of select="$varName"/>[i].getLocalName(),
+                                                    <xsl:value-of select="$varName"/>[i].getAttributeValue(),xmlWriter);
+									 }
 							 }
-                         </xsl:when>
+                        </xsl:when>
                         <!-- there can never be attribute arrays in the normal case-->
+                        <xsl:when test="@optional">
+ 							// optional attribute <xsl:value-of select="$propertyName"/>
+ 							try {
+								writeAttribute("<xsl:value-of select="$namespace"/>",
+                                               "<xsl:value-of select="$propertyName"/>",
+                                               org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>), xmlWriter);							
+							} catch (NullPointerException e) {
+								// If <xsl:value-of select="$varName"/> was null
+								// it can not be serialized.
+							}
+                        </xsl:when>
                         <xsl:otherwise>
                              writeAttribute("<xsl:value-of select="$namespace"/>",
                                                      "<xsl:value-of select="$propertyName"/>",
@@ -1858,28 +1868,33 @@
                     <xsl:variable name="varName">typedBean.local<xsl:value-of select="@javaname"/></xsl:variable>
                      <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                     <xsl:choose>
-                        <!-- Note - It is assumed that any attributes are OMAttributes-->
+						<!-- Note - It is assumed that any attributes are OMAttributes-->
                         <xsl:when test="@any and not(@array)">
                             writeAttribute(<xsl:value-of select="$varName"/>.getNamespace().getName(),
                                                      <xsl:value-of select="$varName"/>.getLocalName(),
                                                      <xsl:value-of select="$varName"/>.getAttributeValue(),xmlWriter);
                         </xsl:when>
-                         <xsl:when test="@any and @array">
-                             for (int i=0;i &lt;<xsl:value-of select="$varName"/>.length;i++){
-                              writeAttribute(<xsl:value-of select="$varName"/>[i].getNamespace().getName(),
-                                                     <xsl:value-of select="$varName"/>[i].getLocalName(),
-                                                     <xsl:value-of select="$varName"/>[i].getAttributeValue(),xmlWriter);
-                             }
-                         </xsl:when>
+                        <xsl:when test="@any and @array">
+							 if (<xsl:value-of select="$varName"/> != null) {
+								 for (int i=0;i &lt;<xsl:value-of select="$varName"/>.length;i++){
+									 writeAttribute(<xsl:value-of select="$varName"/>[i].getNamespace().getName(),
+                                                    <xsl:value-of select="$varName"/>[i].getLocalName(),
+                                                    <xsl:value-of select="$varName"/>[i].getAttributeValue(),xmlWriter);
+									 }
+							 }
+                        </xsl:when>
                         <!-- there can never be attribute arrays in the normal case-->
-                         <xsl:when test="@optional">
+                        <xsl:when test="@optional">
  							// optional attribute <xsl:value-of select="$propertyName"/>
- 							if (<xsl:value-of select="$varName"/> != null) {
+ 							try {
 								writeAttribute("<xsl:value-of select="$namespace"/>",
                                                "<xsl:value-of select="$propertyName"/>",
                                                org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>), xmlWriter);
+							} catch (NullPointerException e) {
+								// If <xsl:value-of select="$varName"/> was null
+								// it can not be serialized.
 							}
-                         </xsl:when>
+                        </xsl:when>
                         <xsl:otherwise>
                              writeAttribute("<xsl:value-of select="$namespace"/>",
                                                      "<xsl:value-of select="$propertyName"/>",



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message