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 ve...@apache.org on 2009/07/03 21:41:37 UTC
svn commit: r790996 [6/6] - in
/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template:
ADBBeanTemplate-bean.xsl ADBBeanTemplate-helpermode.xsl 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=790996&r1=790995&r2=790996&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 Jul 3 19:41:36 2009
@@ -49,5708 +49,19 @@
<xsl:apply-templates/>
</xsl:template>
- <xsl:template match="bean[not(@helperMode)]">
- <xsl:variable name="name" select="@name"/>
- <xsl:variable name="choice" select="@choice"/>
- <xsl:variable name="simple" select="@simple"/>
- <xsl:variable name="ordered" select="@ordered"/>
- <xsl:variable name="unordered" select="not($ordered)"/> <!-- for convenience -->
- <xsl:variable name="isType" select="@type"/>
- <xsl:variable name="anon" select="@anon"/>
- <xsl:variable name="union" select="@union"/>
- <xsl:variable name="list" select="@list"/>
-
- <xsl:variable name="nsuri" select="@nsuri"/>
- <xsl:variable name="originalName" select="@originalName"/>
- <xsl:variable name="nsprefix" select="@nsprefix"/>
- <xsl:variable name="extension" select="@extension"/>
- <xsl:variable name="restriction" select="@restriction"/>
- <xsl:variable name="mapperClass" select="@mapperClass"/>
- <xsl:variable name="particleClass" select="@particleClass"/>
- <xsl:variable name="hasParticleType" select="@hasParticleType"/>
- <xsl:variable name="usewrapperclasses" select="@usewrapperclasses"/>
- <!-- write the class header. this should be done only when unwrapped -->
-
- <xsl:if test="not(not(@unwrapped) or (@skip-write))">
-/**
- * <xsl:value-of select="$name"/>.java
- *
- * This file was auto-generated from WSDL
- * by the Apache Axis2 version: #axisVersion# #today#
- */
- <xsl:if test="string-length(normalize-space(@package)) > 0">
- package <xsl:value-of select="@package"/>;
- </xsl:if>
-
- /**
- * <xsl:value-of select="$name"/> bean class
- */
- </xsl:if>
- public <xsl:if test="not(@unwrapped) or (@skip-write)">static</xsl:if> <xsl:if test="@isAbstract and @unwrapped and not(@skip-write)">abstract</xsl:if> class <xsl:value-of select="$name"/> <xsl:if test="$extension"> extends <xsl:value-of select="$extension"/></xsl:if> <xsl:if test="$restriction"> extends <xsl:value-of select="$restriction"/></xsl:if>
- <xsl:if test="$union and not($restriction) and not($extension)"> extends org.apache.axis2.databinding.types.Union </xsl:if>
- implements org.apache.axis2.databinding.ADBBean{
- <xsl:choose>
- <xsl:when test="@type">/* This type was generated from the piece of schema that had
- name = <xsl:value-of select="$originalName"/>
- Namespace URI = <xsl:value-of select="$nsuri"/>
- Namespace Prefix = <xsl:value-of select="$nsprefix"/>
- */
- </xsl:when>
- <xsl:otherwise>
- public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
- "<xsl:value-of select="$nsuri"/>",
- "<xsl:value-of select="$originalName"/>",
- "<xsl:value-of select="$nsprefix"/>");
-
- </xsl:otherwise>
- </xsl:choose>
-
- private static java.lang.String generatePrefix(java.lang.String namespace) {
- if(namespace.equals("<xsl:value-of select="$nsuri"/>")){
- return "<xsl:value-of select="$nsprefix"/>";
- }
- return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
- }
-
- <xsl:if test="$choice">
- /** Whenever a new property is set ensure all others are unset
- * There can be only one choice and the last one wins
- */
- private void clearAllSettingTrackers() {
- <xsl:for-each select="property">
- <xsl:if test="not(@attribute)">
- local<xsl:value-of select="@javaname"/>Tracker = false;
- </xsl:if>
- </xsl:for-each>
- }
- </xsl:if>
-
-
- <xsl:for-each select="property">
- <!-- Write only the NOT inherited properties
- but we have to generate two specital methods for simple type restriction and extenesions -->
- <xsl:if test="not(@inherited) or ($simple and $extension) or ($simple and $restriction)">
-
- <xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
- <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
- <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
-
- <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
- <xsl:variable name="varName">local<xsl:value-of select="$javaName"/></xsl:variable>
- <xsl:variable name="settingTracker">local<xsl:value-of select="$javaName"/>Tracker</xsl:variable>
-
-
- <xsl:variable name="lenFacet"><xsl:value-of select="@lenFacet"/></xsl:variable>
- <xsl:variable name="maxLenFacet"><xsl:value-of select="@maxLenFacet"/></xsl:variable>
- <xsl:variable name="minLenFacet"><xsl:value-of select="@minLenFacet"/></xsl:variable>
- <xsl:variable name="maxExFacet"><xsl:value-of select="@maxExFacet"/></xsl:variable>
- <xsl:variable name="minExFacet"><xsl:value-of select="@minExFacet"/></xsl:variable>
- <xsl:variable name="maxInFacet"><xsl:value-of select="@maxInFacet"/></xsl:variable>
- <xsl:variable name="minInFacet"><xsl:value-of select="@minInFacet"/></xsl:variable>
- <xsl:variable name="patternFacet"><xsl:value-of select="@patternFacet"/></xsl:variable>
- <xsl:variable name="shortTypeNameUncapped" select="@shorttypename"/>
- <xsl:variable name="shortTypeName"
- select="concat(translate( substring($shortTypeNameUncapped, 1, 1 ),'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ), substring($shortTypeNameUncapped, 2, string-length($shortTypeNameUncapped)))" />
-
-
- <xsl:choose>
- <xsl:when test="@removed">
-
- /**
- * Auto generated getter method
- * Overridden from <xsl:value-of select="$restriction"/>
- *
- * @throws RuntimeException
- */
- public <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
- throw new java.lang.RuntimeException();
- }
-
- /**
- * Auto generated setter method
- * Overridden from <xsl:value-of select="$restriction"/>
- *
- * @param param <xsl:value-of select="$javaName"/>
- * @throws RuntimeException
- */
- public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- throw new java.lang.RuntimeException();
- }
-
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="(@restricted) and (@occuranceChanged) and (not(@typeChanged)) and (not(@rewrite))">
- <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
-
-
- <!-- generate the validator Method, this is specifiacally for validating the arrays-->
- /**
- * Validate the array for <xsl:value-of select="$javaName"/>
- * Overridden from <xsl:value-of select="$restriction"/>
- */
- protected void validate<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- <xsl:if test="not(@unbound) and @array">
- if ((param != null) && (param.length > <xsl:value-of select="@maxOccurs"/>)){
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- <xsl:if test="$min!=0 and @array">
- if ((param != null) && (param.length < <xsl:value-of select="$min"/>)){
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- }
-
-
- /**
- * Auto generated setter method
- * Overridden from <xsl:value-of select="$restriction"/>
- *
- * @param param <xsl:value-of select="$javaName"/>
- */
- public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- <!-- call the validator-->
- validate<xsl:value-of select="$javaName"/>(param);
-
- <xsl:if test="$choice">
- clearAllSettingTrackers();
- </xsl:if>
- <xsl:if test="$min=0 or $choice">
- <!-- the updating of setting tracker for null values should
- happen if the attribute is marked as nillable. Else
- the user can set a null value and it is never marked
- as set
- -->
- <xsl:choose>
- <xsl:when test="@primitive and not(@array)">
- // setting primitive variable always to true
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- if (param != null){
- //update the setting tracker
- <xsl:value-of select="$settingTracker"/> = true;
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$settingTracker"/> = false;
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- this.<xsl:value-of select="$varName"/>=param;
- }
- </xsl:when>
- <xsl:otherwise>
-
- /**
- * field for <xsl:value-of select="$javaName"/>
- <xsl:if test="@attribute">
- * This was an Attribute!</xsl:if>
- <xsl:if test="@array">
- * This was an Array!</xsl:if>
- <xsl:if test="@typeChanged">
- * Type of this field is a subtype of its original.</xsl:if>
- <xsl:if test="(@rewrite) and (@occuranceChanged)">
- * This field was an array in <xsl:value-of select="$restriction"/>.</xsl:if>
- */
-
- <xsl:if test="not(@inherited)">
- <xsl:choose>
- <xsl:when test="@defaultValue">
- protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> =
- org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>("<xsl:value-of
- select="@defaultValue"/>");
- </xsl:when>
- <xsl:otherwise>
- protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:if>
- <xsl:if test="enumFacet">
- private static java.util.HashMap _table_ = new java.util.HashMap();
-
- // Constructor
- <xsl:if test="not(@inherited)">
- protected <xsl:value-of select="$name"/>(<xsl:value-of select="$propertyType"/> value, boolean isRegisterValue) {
- <xsl:value-of select="$varName" /> = value;
- if (isRegisterValue){
- <xsl:choose>
- <xsl:when test="@primitive">
- _table_.put(<xsl:value-of select="$varName" /> + "", this);
- </xsl:when>
- <xsl:otherwise>
- _table_.put(<xsl:value-of select="$varName" />, this);
- </xsl:otherwise>
- </xsl:choose>
- }
-
- }
- </xsl:if>
- <xsl:if test="@inherited">
- protected <xsl:value-of select="$name"/>(<xsl:value-of select="$propertyType"/> value, boolean isRegisterValue) {
- super(value,false);
- if (isRegisterValue){
- <xsl:choose>
- <xsl:when test="@primitive">
- _table_.put(<xsl:value-of select="$varName" /> + "", this);
- </xsl:when>
- <xsl:otherwise>
- _table_.put(<xsl:value-of select="$varName" />, this);
- </xsl:otherwise>
- </xsl:choose>
- }
- }
- </xsl:if>
- <xsl:if test="not(@inherited)">
- <xsl:for-each select="enumFacet">
- public static final <xsl:value-of select="$propertyType"/> _<xsl:value-of select="@id"/> =
- org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>("<xsl:value-of select="@value"/>");
- </xsl:for-each>
- </xsl:if>
-
- <xsl:for-each select="enumFacet">
- public static final <xsl:value-of select="$name"/><xsl:text> </xsl:text><xsl:value-of select="@id"/> =
- new <xsl:value-of select="$name"/>(_<xsl:value-of select="@id"/>,true);
- </xsl:for-each>
-
- public <xsl:value-of select="$propertyType"/> getValue() { return <xsl:value-of select="$varName" />;}
-
- public boolean equals(java.lang.Object obj) {return (obj == this);}
- public int hashCode() { return toString().hashCode();}
- public java.lang.String toString() {
- <xsl:choose>
- <xsl:when test="@primitive">
- return <xsl:value-of select="$varName"/> + "";
- </xsl:when>
- <xsl:otherwise>
- return <xsl:value-of select="$varName"/>.toString();
- </xsl:otherwise>
- </xsl:choose>
-
- }
-
- </xsl:if>
- <xsl:if test="not(enumFacet)">
- <!-- Generate a tracker only if the min occurs is zero, which means if the user does
- not bother to set that value, we do not send it -->
- <xsl:if test="$min=0 or $choice">
- /* This tracker boolean wil be used to detect whether the user called the set method
- * for this attribute. It will be used to determine whether to include this field
- * in the serialized XML
- */
- protected boolean <xsl:value-of select="$settingTracker"/> = false ;
- </xsl:if>
-
- /**
- * Auto generated getter method
- * @return <xsl:value-of select="$propertyType"/>
- */
- public <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
- return <xsl:value-of select="$varName"/>;
- }
-
- <!-- When generating the setters, we have to cater differently for the array!-->
- <xsl:choose>
- <xsl:when test="@array">
- <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
-
-
- <!-- generate the validator Method, this is specifiacally for validating the arrays-->
- /**
- * validate the array for <xsl:value-of select="$javaName"/>
- */
- protected void validate<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- <xsl:if test="not(@unbound)">
- if ((param != null) && (param.length > <xsl:value-of select="@maxOccurs"/>)){
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- <xsl:if test="$min!=0">
- if ((param != null) && (param.length < <xsl:value-of select="$min"/>)){
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- }
-
-
- /**
- * Auto generated setter method
- * @param param <xsl:value-of select="$javaName"/>
- */
- public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- <!-- call the validator-->
- validate<xsl:value-of select="$javaName"/>(param);
-
- <xsl:if test="$choice">
- clearAllSettingTrackers();
- </xsl:if>
- <xsl:if test="$min=0 or $choice">
- <!-- the updating of setting tracker for null values should
- happen if the attribute is marked as nillable. Else
- the user can set a null value and it is never marked
- as set
- -->
- <xsl:choose>
- <xsl:when test="@primitive and not(@array)">
- // setting the primitive attribute to true
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- if (param != null){
- //update the setting tracker
- <xsl:value-of select="$settingTracker"/> = true;
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$settingTracker"/> = false;
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:if>
- this.<xsl:value-of select="$varName"/>=param;
- }
-
- <!--
-
- we special case the 'array' scenario and generate a
- convenience method for adding elements one by one to
- the array. The current implementation is somewhat
- inefficient but gets the job done.Since a primitive
- cannot be treated as an object it has to be ignored!
-
- -->
- <xsl:if test="not(@primitive)">
- /**
- * Auto generated add method for the array for convenience
- * @param param <xsl:value-of select="$basePropertyType"/>
- */
- public void add<xsl:value-of select="$javaName"/>(<xsl:value-of select="$basePropertyType"/> param){
- if (<xsl:value-of select="$varName"/> == null){
- <xsl:value-of select="$varName"/> = new <xsl:value-of select="$propertyType"/>{};
- }
-
- <xsl:if test="$choice">
- clearAllSettingTrackers();
- </xsl:if>
- <xsl:if test="$min=0 or $choice">
- //update the setting tracker
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:if>
-
- java.util.List list =
- org.apache.axis2.databinding.utils.ConverterUtil.toList(<xsl:value-of select="$varName"/>);
- list.add(param);
- this.<xsl:value-of select="$varName"/> =
- (<xsl:value-of select="$propertyType"/>)list.toArray(
- new <xsl:value-of select="$basePropertyType"/>[list.size()]);
-
- }
- </xsl:if>
- <!-- end of special casing for the array-->
-
- </xsl:when>
- <!-- Non array setter method-->
- <xsl:otherwise>
- /**
- * Auto generated setter method
- * @param param <xsl:value-of select="$javaName"/>
- */
- public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
- <xsl:if test="$choice">
- clearAllSettingTrackers();
- </xsl:if>
- <xsl:if test="$min=0 or $choice">
- <xsl:choose>
- <xsl:when test="@primitive and not(@array)">
- // setting primitive attribute tracker to true
- <xsl:choose>
- <xsl:when test="$usewrapperclasses">
- if (false) {
- </xsl:when>
- <xsl:when test="$propertyType='int'">
- if (param==java.lang.Integer.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='long'">
- if (param==java.lang.Long.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='byte'">
- if (param==java.lang.Byte.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='double'">
- if (java.lang.Double.isNaN(param)) {
- </xsl:when>
- <xsl:when test="$propertyType='float'">
- if (java.lang.Float.isNaN(param)) {
- </xsl:when>
- <xsl:when test="$propertyType='short'">
- if (param==java.lang.Short.MIN_VALUE) {
- </xsl:when>
- <xsl:otherwise>
- if (false) {
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="@nillable">
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$settingTracker"/> = false;
- </xsl:otherwise>
- </xsl:choose>
- } else {
- <xsl:value-of select="$settingTracker"/> = true;
- }
- </xsl:when>
- <xsl:otherwise>
- if (param != null){
- //update the setting tracker
- <xsl:value-of select="$settingTracker"/> = true;
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- <xsl:value-of select="$settingTracker"/> = true;
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$settingTracker"/> = false;
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:choose>
- <xsl:when test="(@restrictionBaseType)">
- <xsl:choose>
- <xsl:when test="(@patternFacet)">
- if (org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).matches("<xsl:value-of select="$patternFacet"/>")) {
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:when>
- <xsl:when test="(@lenFacet)">
- if (org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).length() == <xsl:value-of select="@lenFacet"/> ) {
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:when>
- <xsl:when test="(@maxLenFacet) or (@minLenFacet)">
- if ( <xsl:if test="(@minLenFacet)"> (<xsl:value-of select="$minLenFacet"/> <= java.lang.String.valueOf(param).length())</xsl:if>
- <xsl:if test="(@maxLenFacet)"> <xsl:if test="(@minLenFacet)"> && </xsl:if> (java.lang.String.valueOf(param).length() <= <xsl:value-of select="$maxLenFacet"/>) </xsl:if> ) {
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:when>
- <xsl:when test="@maxExFacet or @minExFacet or @maxInFacet or @minInFacet">
- <xsl:if test="@maxExFacet">
- if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "<xsl:value-of select="$maxExFacet"/>") < 0){
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- <xsl:if test="@minExFacet">
- if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "<xsl:value-of select="$minExFacet"/>") > 0){
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- <xsl:if test="@maxInFacet">
- if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "<xsl:value-of select="$maxInFacet"/>") <= 0){
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
- <xsl:if test="@minInFacet">
- if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, "<xsl:value-of select="$minInFacet"/>") >= 0){
- this.<xsl:value-of select="$varName"/>=param;
- }
- else {
- throw new java.lang.RuntimeException();
- }
- </xsl:if>
-
- </xsl:when>
- <xsl:otherwise>
- this.<xsl:value-of select="$varName"/>=param;
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <xsl:otherwise>
- this.<xsl:value-of select="$varName"/>=param;
- </xsl:otherwise>
- </xsl:choose>
-
- }
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <!-- generate from string and to string methods for
- simple types to be ued in attribute handling -->
- <xsl:if test="$simple and not(@attribute) and not(enumFacet)">
-
- public java.lang.String toString(){
- <xsl:choose>
- <xsl:when test="@primitive">
- return <xsl:value-of select="$varName"/> + "";
- </xsl:when>
- <xsl:otherwise>
- return <xsl:value-of select="$varName"/>.toString();
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:if>
-
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:otherwise>
- </xsl:choose>
-
- <!-- end of xsl:if for not(@inherited) -->
- </xsl:if>
-
- </xsl:for-each>
-
- <!-- we don't need to generate the setObject method in parent classes -->
- <xsl:if test="$union and $simple and not($restriction) and not($extension)">
- <!-- generate class for a union type -->
-
- public void setObject(java.lang.Object object){
- <xsl:for-each select="memberType">
- <xsl:if test="position() > 1">} else </xsl:if>
- if (object instanceof <xsl:value-of select="@type"/>){
- this.localObject = object;
- </xsl:for-each>
- } else {
- throw new java.lang.RuntimeException("Invalid object type");
- }
- }
-
- </xsl:if>
-
- <xsl:if test="$list and not($restriction) and not($extension)" >
- <xsl:variable name="javaName"><xsl:value-of select="itemtype/@javaname"/></xsl:variable>
- <xsl:variable name="varName">local<xsl:value-of select="itemtype/@javaname"/></xsl:variable>
- <xsl:variable name="varType"><xsl:value-of select="itemtype/@type"/></xsl:variable>
- <xsl:variable name="primitive"><xsl:value-of select="itemtype/@primitive"/></xsl:variable>
-
- protected <xsl:value-of select="$varType"/>[] <xsl:value-of select="$varName"/>;
-
- public <xsl:value-of select="$varType"/>[] get<xsl:value-of select="$javaName"/>(){
- return <xsl:value-of select="$varName"/>;
- }
-
- public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$varType"/>[] itemList){
- this.<xsl:value-of select="$varName"/> = itemList;
- }
-
- public java.lang.String toString() {
- java.lang.StringBuffer outString = new java.lang.StringBuffer();
- if (<xsl:value-of select="$varName"/> != null){
- for(int i = 0; i < <xsl:value-of select="$varName"/>.length;i++){
- <xsl:choose>
- <xsl:when test="$primitive">
- outString.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i])).append(" ");
- </xsl:when>
- <xsl:otherwise>
- outString.append(<xsl:value-of select="$varName"/>[i].toString()).append(" ");
- </xsl:otherwise>
- </xsl:choose>
-
- }
- }
- return outString.toString().trim();
- }
- </xsl:if>
-
- /**
- * isReaderMTOMAware
- * @return true if the reader supports MTOM
- */
- public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) {
- boolean isReaderMTOMAware = false;
- <!-- workaround for the issues in the wstx reader!-->
- try{
- isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE));
- }catch(java.lang.IllegalArgumentException e){
- isReaderMTOMAware = false;
- }
- return isReaderMTOMAware;
- }
- <!-- ######################################################################################### -->
- <!-- get OMElement methods that allows direct writing -->
- /**
- *
- * @param parentQName
- * @param factory
- * @return org.apache.axiom.om.OMElement
- */
- public org.apache.axiom.om.OMElement getOMElement (
- final javax.xml.namespace.QName parentQName,
- final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{
-
-
- <xsl:choose>
- <xsl:when test="@type">
- org.apache.axiom.om.OMDataSource dataSource =
- new org.apache.axis2.databinding.ADBDataSource(this,parentQName){
-
- public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
- <xsl:value-of select="$name"/>.this.serialize(parentQName,factory,xmlWriter);
- }
- };
- return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
- parentQName,factory,dataSource);
- </xsl:when>
- <xsl:otherwise>
- org.apache.axiom.om.OMDataSource dataSource =
- new org.apache.axis2.databinding.ADBDataSource(this,MY_QNAME){
-
- public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
- <xsl:value-of select="$name"/>.this.serialize(MY_QNAME,factory,xmlWriter);
- }
- };
- return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
- MY_QNAME,factory,dataSource);
- </xsl:otherwise>
- </xsl:choose>
- }
-
- public void serialize(final javax.xml.namespace.QName parentQName,
- final org.apache.axiom.om.OMFactory factory,
- org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter)
- throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{
- serialize(parentQName,factory,xmlWriter,false);
- }
-
- public void serialize(final javax.xml.namespace.QName parentQName,
- final org.apache.axiom.om.OMFactory factory,
- org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter,
- boolean serializeType)
- throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{
- <xsl:choose>
-
- <xsl:when test="$simple and $union">
- writeStartElement(null, parentQName.getNamespaceURI(), parentQName.getLocalPart(), xmlWriter);
-
- <xsl:for-each select="memberType">
- <xsl:if test="position() > 1">} else </xsl:if>
- if (localObject instanceof <xsl:value-of select="@type"/>){
- java.lang.String namespacePrefix = registerPrefix(xmlWriter,"<xsl:value-of select="@nsuri"/>");
- if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- namespacePrefix+":<xsl:value-of select="@originalName"/>",
- xmlWriter);
- } else {
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- "<xsl:value-of select="@originalName"/>",
- xmlWriter);
- }
-
- <xsl:choose>
- <xsl:when test="@type='javax.xml.namespace.QName'">
- writeQName((javax.xml.namespace.QName)localObject,xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString((<xsl:value-of select="@type"/>)localObject));
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- } else {
- throw new org.apache.axis2.databinding.ADBException("Invalid object type");
- }
- xmlWriter.writeEndElement();
- </xsl:when>
-
- <xsl:when test="$simple and $list">
-
- <xsl:variable name="javaName"><xsl:value-of select="itemtype/@javaname"/></xsl:variable>
- <xsl:variable name="varType"><xsl:value-of select="itemtype/@type"/></xsl:variable>
-
- writeStartElement(null, parentQName.getNamespaceURI(), parentQName.getLocalPart(), xmlWriter);
-
- <xsl:choose>
- <xsl:when test="$varType='javax.xml.namespace.QName'">
- writeQNames(local<xsl:value-of select="$javaName"/>,xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- xmlWriter.writeCharacters(<xsl:value-of select="$name"/>.this.toString());
- </xsl:otherwise>
- </xsl:choose>
-
- xmlWriter.writeEndElement();
- </xsl:when>
-
- <xsl:when test="@type or @anon">
- <!-- For a type write the passed in QName first
- we create special particle classes for Sequence,Choice and all elements to
- handle maxOccurs correctly. So these classes should not write parent Qname-->
-
-
- java.lang.String prefix = null;
- java.lang.String namespace = null;
- <xsl:if test="not($particleClass)">
-
- prefix = parentQName.getPrefix();
- namespace = parentQName.getNamespaceURI();
- writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter);
- </xsl:if>
-
-
- <!-- write the type attribute if needed -->
- <xsl:if test="not($extension) or @anon">
- if (serializeType){
- </xsl:if>
-
- java.lang.String namespacePrefix = registerPrefix(xmlWriter,"<xsl:value-of select="$nsuri"/>");
- if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- namespacePrefix+":<xsl:value-of select="$originalName"/>",
- xmlWriter);
- } else {
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- "<xsl:value-of select="$originalName"/>",
- xmlWriter);
- }
-
- <xsl:if test="not($extension) or @anon">
- }
- </xsl:if>
- <!--First serialize the attributes!-->
- <xsl:for-each select="property[@attribute]">
- <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
- <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
- <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
- <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
- <xsl:choose>
- <!-- 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">
- if (<xsl:value-of select="$varName"/> != null) {
- for (int i=0;i <<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:otherwise>
- <xsl:choose>
- <xsl:when test="@ours">
- <!-- this can only be a simple type -->
- if (<xsl:value-of select="$varName"/> != null){
- writeAttribute("<xsl:value-of select="$namespace"/>",
- "<xsl:value-of select="$propertyName"/>",
- <xsl:value-of select="$varName"/>.toString(), xmlWriter);
- }
- <xsl:if test="not(@optional)">
- else {
- throw new org.apache.axis2.databinding.ADBException("required attribute <xsl:value-of select="$varName"/> is null");
- }
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="@primitive">
- <xsl:choose>
- <xsl:when test="$usewrapperclasses">
- if (true) {
- </xsl:when>
- <xsl:when test="$propertyType='int'">
- if (<xsl:value-of select="$varName"/>!=java.lang.Integer.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='long'">
- if (<xsl:value-of select="$varName"/>!=java.lang.Long.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='byte'">
- if (<xsl:value-of select="$varName"/>!=java.lang.Byte.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='double'">
- if (!java.lang.Double.isNaN(<xsl:value-of select="$varName"/>)) {
- </xsl:when>
- <xsl:when test="$propertyType='float'">
- if (!java.lang.Float.isNaN(<xsl:value-of select="$varName"/>)) {
- </xsl:when>
- <xsl:when test="$propertyType='short'">
- if (<xsl:value-of select="$varName"/>!=java.lang.Short.MIN_VALUE) {
- </xsl:when>
- <xsl:otherwise>
- if (true) {
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- if (<xsl:value-of select="$varName"/> != null){
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="$propertyType='javax.xml.namespace.QName'">
- writeQNameAttribute("<xsl:value-of select="$namespace"/>",
- "<xsl:value-of select="$propertyName"/>",
- <xsl:value-of select="$varName"/>, xmlWriter);
-
- </xsl:when>
- <xsl:otherwise>
- writeAttribute("<xsl:value-of select="$namespace"/>",
- "<xsl:value-of select="$propertyName"/>",
- org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>), xmlWriter);
-
- </xsl:otherwise>
- </xsl:choose>
- }
- <xsl:if test="not(@optional)">
- else {
- throw new org.apache.axis2.databinding.ADBException("required attribute <xsl:value-of select="$varName"/> is null");
- }
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
-
- <!-- Now serialize the elements-->
- <xsl:for-each select="property[not(@attribute)]">
- <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
- <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
- <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
- <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
- <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="propertyBaseType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
- <xsl:variable name="particleClassType" select="@particleClassType"></xsl:variable>
-
- <xsl:if test="$min=0 or $choice"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
- <xsl:choose>
- <xsl:when test="@ours and not(@array) and not(@default)">
- <xsl:choose>
- <xsl:when test="@nillable">
- if (<xsl:value-of select="$varName"/>==null){
-
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- }else{
- <xsl:value-of select="$varName"/>.serialize(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory,xmlWriter);
- }
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$particleClassType">
- if (<xsl:value-of select="$varName"/>==null){
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
- <xsl:value-of select="$varName"/>.serialize(null,factory,xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- if (<xsl:value-of select="$varName"/>==null){
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
- <xsl:value-of select="$varName"/>.serialize(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory,xmlWriter);
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="@ours and @array and not(@default)">
- <xsl:choose>
- <xsl:when test="$particleClassType">
- <!-- if it is a particle clase that can only be minOccurs zero or not -->
- if (<xsl:value-of select="$varName"/>!=null){
- for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
- if (<xsl:value-of select="$varName"/>[i] != null){
- <xsl:value-of select="$varName"/>[i].serialize(null,factory,xmlWriter);
- } else {
- <xsl:choose>
- <xsl:when test="$min=0">
- // we don't have to do any thing since minOccures is zero
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
-
- }
- } else {
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
- </xsl:when>
- <xsl:otherwise>
- if (<xsl:value-of select="$varName"/>!=null){
- for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
- if (<xsl:value-of select="$varName"/>[i] != null){
- <xsl:value-of select="$varName"/>[i].serialize(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory,xmlWriter);
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:when test="$min=0">
- // we don't have to do any thing since minOccures is zero
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
-
- }
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:when>
-
- <xsl:when test="@default and @array">
- <!-- Note - Assumed to be OMElement-->
- if (<xsl:value-of select="$varName"/>!=null){
- for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
- if (<xsl:value-of select="$varName"/>[i] != null){
-
- if (<xsl:value-of select="$varName"/>[i] instanceof org.apache.axis2.databinding.ADBBean){
- ((org.apache.axis2.databinding.ADBBean)<xsl:value-of select="$varName"/>[i]).serialize(
- new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory,xmlWriter,true);
- } else {
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
- org.apache.axis2.databinding.utils.ConverterUtil.serializeAnyType(<xsl:value-of select="$varName"/>[i], xmlWriter);
- xmlWriter.writeEndElement();
- }
-
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- // write null attribute
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:when test="$min=0">
- // we have to do nothing since minOccurs is zero
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
- }
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- // write null attribute
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
-
- </xsl:when>
-
- <xsl:when test="@default and not(@array)">
- <!-- Note - Assumed to be OMElement-->
- if (<xsl:value-of select="$varName"/>!=null){
- if (<xsl:value-of select="$varName"/> instanceof org.apache.axis2.databinding.ADBBean){
- ((org.apache.axis2.databinding.ADBBean)<xsl:value-of select="$varName"/>).serialize(
- new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory,xmlWriter,true);
- } else {
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
- org.apache.axis2.databinding.utils.ConverterUtil.serializeAnyType(<xsl:value-of select="$varName"/>, xmlWriter);
- xmlWriter.writeEndElement();
- }
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- // write null attribute
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
-
-
- </xsl:when>
- <!-- handle non ADB arrays - Not any however -->
- <xsl:when test="@array and not(@any)">
- if (<xsl:value-of select="$varName"/>!=null) {
- namespace = "<xsl:value-of select="$namespace"/>";
- for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
- <xsl:if test="@primitive">
- <xsl:choose>
- <xsl:when test="$usewrapperclasses">
- if (true) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='int'">
- if (<xsl:value-of select="$varName"/>[i]!=java.lang.Integer.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='long'">
- if (<xsl:value-of select="$varName"/>[i]!=java.lang.Long.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='byte'">
- if (<xsl:value-of select="$varName"/>[i]!=java.lang.Byte.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='double'">
- if (!java.lang.Double.isNaN(<xsl:value-of select="$varName"/>[i])) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='float'">
- if (!java.lang.Float.isNaN(<xsl:value-of select="$varName"/>[i])) {
- </xsl:when>
- <xsl:when test="$propertyBaseType='short'">
- if (<xsl:value-of select="$varName"/>[i]!=java.lang.Short.MIN_VALUE) {
- </xsl:when>
- <xsl:otherwise>
- if (true) {
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="not(@primitive)">
- if (<xsl:value-of select="$varName"/>[i] != null){
- </xsl:if>
- writeStartElement(null, namespace, "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- <xsl:if test="@primitive">
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i]));
- xmlWriter.writeEndElement();
- </xsl:if>
-
- <xsl:if test="not(@primitive)">
- <xsl:choose>
- <xsl:when test="@binary">
- xmlWriter.writeDataHandler(<xsl:value-of select="$varName"/>[i]);
- </xsl:when>
- <xsl:otherwise>
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i]));
- </xsl:otherwise>
- </xsl:choose>
- xmlWriter.writeEndElement();
- </xsl:if>
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- // write null attribute
- namespace = "<xsl:value-of select="$namespace"/>";
- writeStartElement(null, namespace, "<xsl:value-of select="$propertyName"/>", xmlWriter);
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:when test="$min=0">
- // we have to do nothing since minOccurs is zero
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
-
- </xsl:choose>
- }
-
- }
- } else {
- <xsl:choose>
- <xsl:when test="@nillable">
- // write the null attribute
- // write null attribute
- writeStartElement(null, "<xsl:value-of select="$namespace"/>", "<xsl:value-of select="$propertyName"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
-
- </xsl:when>
-
- <!-- handle non ADB arrays - Any case - any may not be
- nillable -->
- <xsl:when test="@array and @any">
- <!-- Note - Assumed to be OMElement-->
- if (<xsl:value-of select="$varName"/> != null){
- for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
- if (<xsl:value-of select="$varName"/>[i] != null){
- <xsl:value-of select="$varName"/>[i].serialize(xmlWriter);
- } else {
- <xsl:choose>
- <xsl:when test="$min=0">
- // we have to do nothing since minOccures zero
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }
- }
- } else {
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
- </xsl:when>
- <!-- handle any - non array case-->
- <xsl:when test="@any">
- <!-- Note - Assumed to be OMElement-->
- if (<xsl:value-of select="$varName"/> != null) {
- <xsl:value-of select="$varName"/>.serialize(xmlWriter);
- } else {
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
- </xsl:when>
- <!-- handle all other cases -->
- <xsl:otherwise>
- <xsl:if test="not($simple)">
- namespace = "<xsl:value-of select="$namespace"/>";
- writeStartElement(null, namespace, "<xsl:value-of select="$propertyName"/>", xmlWriter);
- </xsl:if>
- <xsl:choose>
- <!-- handle the binary case -->
- <xsl:when test="@binary">
- <!-- Handling the null byte array -->
- if (<xsl:value-of select="$varName"/>!=null)
- {
- xmlWriter.writeDataHandler(<xsl:value-of select="$varName"/>);
- }
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="not(@primitive)">
-
- if (<xsl:value-of select="$varName"/>==null){
- // write the nil attribute
- <xsl:choose>
- <xsl:when test="@nillable">
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- }else{
-
- <xsl:choose>
- <xsl:when test="$propertyType='javax.xml.namespace.QName'">
- writeQName(<xsl:value-of select="$varName"/>,xmlWriter);
- </xsl:when>
- <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
- <xsl:value-of select="$varName"/>.serialize(xmlWriter);
- </xsl:when>
- <xsl:when test="$propertyType='java.lang.String'">
- xmlWriter.writeCharacters(<xsl:value-of select="$varName"/>);
- </xsl:when>
- <xsl:otherwise>
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- </xsl:otherwise>
- </xsl:choose>
- }
- </xsl:if>
- <xsl:if test="@primitive">
- <!-- we have to check for nillability with min value -->
- <xsl:choose>
- <xsl:when test="$usewrapperclasses">
- if (false) {
- </xsl:when>
- <xsl:when test="$propertyType='int'">
- if (<xsl:value-of select="$varName"/>==java.lang.Integer.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='long'">
- if (<xsl:value-of select="$varName"/>==java.lang.Long.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='byte'">
- if (<xsl:value-of select="$varName"/>==java.lang.Byte.MIN_VALUE) {
- </xsl:when>
- <xsl:when test="$propertyType='double'">
- if (java.lang.Double.isNaN(<xsl:value-of select="$varName"/>)) {
- </xsl:when>
- <xsl:when test="$propertyType='float'">
- if (java.lang.Float.isNaN(<xsl:value-of select="$varName"/>)) {
- </xsl:when>
- <xsl:when test="$propertyType='short'">
- if (<xsl:value-of select="$varName"/>==java.lang.Short.MIN_VALUE) {
- </xsl:when>
- <xsl:otherwise>
- if (false) {
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="@nillable">
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- throw new org.apache.axis2.databinding.ADBException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- </xsl:otherwise>
- </xsl:choose>
- } else {
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- }
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="not($simple)">
- xmlWriter.writeEndElement();
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="$min=0 or $choice">}</xsl:if>
-
- </xsl:for-each>
- <!-- write the end element for the type-->
- <xsl:if test="not($particleClass)">
- xmlWriter.writeEndElement();
- </xsl:if>
- <!-- end of when for type & anon -->
- </xsl:when>
-
- <!-- Not a type and not anon. So it better be only one inclusion-->
- <xsl:otherwise>
- <!-- 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" 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:choose>
- <!-- This better be only one!!-->
- <xsl:when test="property/@ours">
- <xsl:choose>
- <xsl:when test="$nillable">
- if (<xsl:value-of select="$varName"/>==null){
- java.lang.String namespace = "<xsl:value-of select="property/@nsuri"/>";
- writeStartElement(null, namespace, "<xsl:value-of select="property/@name"/>", xmlWriter);
-
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
- xmlWriter.writeEndElement();
- }else{
- <xsl:value-of select="$varName"/>.serialize(MY_QNAME,factory,xmlWriter);
- }
- </xsl:when>
- <xsl:otherwise>
- if (<xsl:value-of select="$varName"/>==null){
- throw new org.apache.axis2.databinding.ADBException("Property cannot be null!");
- }
- <xsl:value-of select="$varName"/>.serialize(MY_QNAME,factory,xmlWriter);
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!-- end of ours block-->
- <xsl:otherwise>
- <xsl:if test="not(property/@simple)">
- java.lang.String namespace = "<xsl:value-of select="property/@nsuri"/>";
- java.lang.String localName = "<xsl:value-of select="property/@name"/>";
- </xsl:if>
- <xsl:if test="property/@simple">
- java.lang.String namespace = parentQName.getNamespaceURI();
- java.lang.String localName = parentQName.getLocalPart();
- </xsl:if>
- writeStartElement(null, namespace, localName, xmlWriter);
-
- // add the type details if this is used in a simple type
- if (serializeType){
- java.lang.String namespacePrefix = registerPrefix(xmlWriter,"<xsl:value-of select="$nsuri"/>");
- if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- namespacePrefix+":<xsl:value-of select="$originalName"/>",
- xmlWriter);
- } else {
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
- "<xsl:value-of select="$originalName"/>",
- xmlWriter);
- }
- }
- <xsl:if test="not($primitive)">
- if (<xsl:value-of select="$varName"/>==null){
[... 4334 lines stripped ...]