You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/10/16 03:33:08 UTC

svn commit: r464356 - /webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl

Author: dims
Date: Sun Oct 15 18:33:05 2006
New Revision: 464356

URL: http://svn.apache.org/viewvc?view=rev&rev=464356
Log:
- Replace the following construct 
  <xsl:variable name="primitive"><xsl:value-of select="property/@primitive"/></xsl:variable>
  with 
  <xsl:variable name="primitive" select="property/@primitive"></xsl:variable>
  Because a xsl:if on the $primitive behaves differently in JDK1.5's embedded xsltc vs latest xalan
- added serialize direct for OMElements
- change the check for QName ser/deser from XSl:if to xsl:choose/xsl:when to make it easier to add the check for OMElement in the same pattern.


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

Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=464356&r1=464355&r2=464356
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Sun Oct 15 18:33:05 2006
@@ -619,8 +619,6 @@
                     <xsl:variable name="settingTracker">local<xsl:value-of select="@javaname"/>Tracker</xsl:variable>
 
                     <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
-                    <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
-
 
                     <xsl:if test="$min=0 or $choice"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
                     <xsl:choose>
@@ -1065,7 +1063,9 @@
                                                   </xsl:otherwise>
                                               </xsl:choose>
                                           }else{
-                                                   <xsl:if test="$propertyTypeName=$propertyType">
+
+                                        <xsl:choose>
+                                            <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                                                         java.lang.String namespaceURI =<xsl:value-of select="$varName"/>.getNamespaceURI();
                                                         if(namespaceURI !=null){
                                                            prefix = <xsl:value-of select="$varName"/>.getPrefix();
@@ -1077,10 +1077,14 @@
                                                         } else {
                                                            xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
                                                         }
-                                                   </xsl:if>
-                                                  <xsl:if test="not($propertyTypeName=$propertyType)">
+                                            </xsl:when>
+                                            <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
+                                                <xsl:value-of select="$varName"/>.serialize(xmlWriter);
+                                            </xsl:when>
+                                            <xsl:otherwise>
                                                    xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
-                                                  </xsl:if>
+                                            </xsl:otherwise>
+                                        </xsl:choose>
                                           }
                                     </xsl:if>
                                     <xsl:if test="@primitive">
@@ -1106,11 +1110,9 @@
                 <!-- if the element is associated with a type, then its gonna be only one -->
                 //We can safely assume an element has only one type associated with it
                 <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
-                <xsl:variable name="nillable"><xsl:value-of select="property/@nillable"/></xsl:variable>
-                <xsl:variable name="primitive"><xsl:value-of select="property/@primitive"/></xsl:variable>
+                <xsl:variable name="nillable" select="property/@nillable"></xsl:variable>
+                <xsl:variable name="primitive" select="property/@primitive"></xsl:variable>
                 <xsl:variable name="propertyType"><xsl:value-of select="property/@type"/></xsl:variable>
-                <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
-
 
                 <xsl:choose>
                     <!-- This better be only one!!-->
@@ -1189,7 +1191,8 @@
                                           // write the nil attribute
                                           writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
                                          }else{
-                                               <xsl:if test="$propertyTypeName=$propertyType">
+                                <xsl:choose>
+                                    <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                                                    java.lang.String prefix ="";
                                                     java.lang.String namespaceURI =<xsl:value-of select="$varName"/>.getNamespaceURI();
                                                     if(namespaceURI !=null){
@@ -1202,10 +1205,14 @@
                                                     } else {
                                                        xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
                                                     }
-                                               </xsl:if>
-                                              <xsl:if test="not($propertyTypeName=$propertyType)">
+                                    </xsl:when>
+                                    <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
+                                        <xsl:value-of select="$varName"/>.serialize(xmlWriter);
+                                    </xsl:when>
+                                    <xsl:otherwise>
                                                xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
-                                               </xsl:if>
+                                    </xsl:otherwise>
+                                </xsl:choose>
                                          }
                                     </xsl:if>
                                     <xsl:if test="$primitive">
@@ -1514,8 +1521,8 @@
                 <!-- if the element is associated with a type, then its gonna be only one -->
                 //We can safely assume an element has only one type associated with it
                 <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
-                <xsl:variable name="nillable"><xsl:value-of select="property/@nillable"/></xsl:variable>
-                <xsl:variable name="primitive"><xsl:value-of select="property/@primitive"/></xsl:variable>
+                <xsl:variable name="nillable" select="property/@nillable"></xsl:variable>
+                <xsl:variable name="primitive" select="property/@primitive"></xsl:variable>
 
                 <xsl:choose>
                     <!-- This better be only one!!-->
@@ -1626,7 +1633,6 @@
                     <xsl:variable name="javaName" select="@javaname"/>
                     <xsl:variable name="namespace" select="@nsuri"/>
                     <xsl:variable name="attribName">tempAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
-                    <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
 
                     <xsl:if test="$propertyName != 'extraAttributes'">
                     // handle attribute "<xsl:value-of select="$propertyName"/>"
@@ -1634,7 +1640,8 @@
                       reader.getAttributeValue("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>");
                    if (<xsl:value-of select="$attribName"/>!=null){
                          java.lang.String content = <xsl:value-of select="$attribName"/>;
-                        <xsl:if test="$propertyTypeName=$propertyType">
+                        <xsl:choose>
+                            <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                                 int index = <xsl:value-of select="$attribName"/>.indexOf(":");
                                 java.lang.String prefix ="";
                                 java.lang.String namespaceuri ="";
@@ -1644,12 +1651,13 @@
                                  }
                                  object.set<xsl:value-of select="$javaName"/>(
                                       org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(<xsl:value-of select="$attribName"/>,namespaceuri));
-                        </xsl:if>
-                        <xsl:if test="not($propertyTypeName=$propertyType)">
+                            </xsl:when>
+                            <xsl:otherwise>
                          object.set<xsl:value-of select="$javaName"/>(
                            org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(
                                 <xsl:value-of select="$attribName"/>));
-                        </xsl:if>
+                            </xsl:otherwise>
+                        </xsl:choose>
                     }
                     handledAttributes.add("<xsl:value-of select="$propertyName"/>");
                     </xsl:if>
@@ -1723,7 +1731,6 @@
                             <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
                             <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                             <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
-                            <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
 
                             <xsl:variable name="propQName">new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>")</xsl:variable>
 
@@ -1965,7 +1972,7 @@
                                 <!-- end of OMelement handling -->
                                 <!-- start of the simple types handling for binary content-->
                                 <xsl:when test="@binary">
-
+                                    <xsl:if test="not($simple)">reader.next();</xsl:if>
                                     if (isReaderMTOMAware
                                             &amp;&amp;
                                             java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
@@ -1998,7 +2005,8 @@
                                     </xsl:if>
                                     java.lang.String content = reader.getElementText();
                                     <xsl:if test="not(enumFacet)">
-                                    <xsl:if test="$propertyTypeName=$propertyType">
+                                        <xsl:choose>
+                                            <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                                             int index = content.indexOf(":");
                                             java.lang.String prefix ="";
                                             java.lang.String namespaceuri ="";
@@ -2008,11 +2016,12 @@
                                              }
                                              object.set<xsl:value-of select="$javaName"/>(
                                                   org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(content,namespaceuri));
-                                    </xsl:if>
-                                    <xsl:if test="not($propertyTypeName=$propertyType)">
+                                            </xsl:when>
+                                            <xsl:otherwise>
                                               object.set<xsl:value-of select="$javaName"/>(
                                         org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
-                                    </xsl:if>
+                                            </xsl:otherwise>
+                                        </xsl:choose>
                                     </xsl:if>
                                     <xsl:if test="(enumFacet)">
                                     object = <xsl:value-of select="$name"/>.fromString(content);
@@ -2762,12 +2771,12 @@
                     <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
                     <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                     <xsl:variable name="attribName">tempAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
-                    <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
 
                     java.lang.String <xsl:value-of select="$attribName"/> =
                       reader.getAttributeValue("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>");
                    if (<xsl:value-of select="$attribName"/>!=null){
-                    <xsl:if test="$propertyTypeName=$propertyType">
+                    <xsl:choose>
+                        <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                             int index = <xsl:value-of select="$attribName"/>.indexOf(":");
                             java.lang.String prefix ="";
                             java.lang.String namespaceuri ="";
@@ -2777,12 +2786,13 @@
                              }
                              object.set<xsl:value-of select="$javaName"/>(
                                   org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(<xsl:value-of select="$attribName"/>,namespaceuri));
-                    </xsl:if>
-                    <xsl:if test="not($propertyTypeName=$propertyType)">
+                        </xsl:when>
+                        <xsl:otherwise>
                          object.set<xsl:value-of select="$javaName"/>(
                            org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(
                                 <xsl:value-of select="$attribName"/>));
-                    </xsl:if>
+                        </xsl:otherwise>
+                    </xsl:choose>
                     }
 
                 </xsl:for-each>
@@ -2832,7 +2842,6 @@
                             <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
                             <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                             <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
-                             <xsl:variable name="propertyTypeName">javax.xml.namespace.QName</xsl:variable>
 
                             <xsl:variable name="propQName">new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>")</xsl:variable>
 
@@ -3065,7 +3074,6 @@
                                 <!-- end of OMelement handling -->
                                 <!-- start of the simple types handling for binary content-->
                                 <xsl:when test="@binary">
-
                                     if (isReaderMTOMAware
                                             &amp;&amp;
                                             java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
@@ -3096,7 +3104,8 @@
                                        if (!"true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
                                     </xsl:if>
                                     java.lang.String content = reader.getElementText();
-                                    <xsl:if test="$propertyTypeName=$propertyType">
+                                    <xsl:choose>
+                                        <xsl:when test="$propertyType='javax.xml.namespace.QName'">
                                             int index = content.indexOf(":");
                                             java.lang.String prefix ="";
                                             java.lang.String namespaceuri ="";
@@ -3106,11 +3115,12 @@
                                              }
                                              object.set<xsl:value-of select="$javaName"/>(
                                                   org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(content,namespaceuri));
-                                         </xsl:if>
-                                    <xsl:if test="not($propertyTypeName=$propertyType)">
+                                        </xsl:when>
+                                        <xsl:otherwise>
                                               object.set<xsl:value-of select="$javaName"/>(
                                         org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
-                                          </xsl:if>
+                                        </xsl:otherwise>
+                                    </xsl:choose>
                                     <xsl:if test="@nillable">
                                         } else {
                                             reader.getElementText(); // throw away text nodes if any.
@@ -3316,8 +3326,8 @@
                 <!-- if the element is associated with a type, then its gonna be only one -->
                 //We can safely assume an element has only one type associated with it
                 <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
-                <xsl:variable name="nillable"><xsl:value-of select="property/@nillable"/></xsl:variable>
-                <xsl:variable name="primitive"><xsl:value-of select="property/@primitive"/></xsl:variable>
+                <xsl:variable name="nillable" select="property/@nillable"></xsl:variable>
+                <xsl:variable name="primitive" select="property/@primitive"></xsl:variable>
 
                 <xsl:choose>
                     <!-- This better be only one!!-->



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