You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2007/01/31 21:35:35 UTC
svn commit: r501978 [3/24] - in /webservices/axis2/branches/java/maven2: ./
etc/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/
modules/adb-codegen/src/org/apache/axis2/sc...
Modified: webservices/axis2/branches/java/maven2/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/branches/java/maven2/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Wed Jan 31 12:35:21 2007
@@ -11,7 +11,9 @@
* by the Apache Axis2 version: #axisVersion# #today#
*/
- package <xsl:value-of select="@package"/>;
+ <xsl:if test="string-length(normalize-space(@package)) > 0">
+ package <xsl:value-of select="@package"/>;
+ </xsl:if>
/**
* <xsl:value-of select="$name"/> wrapped bean classes
@@ -59,6 +61,7 @@
* <xsl:value-of select="$name"/> bean class
*/
</xsl:if>
+
public <xsl:if test="not(@unwrapped) or (@skip-write)">static</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>
implements org.apache.axis2.databinding.ADBBean{
<xsl:choose>
@@ -91,7 +94,7 @@
<xsl:for-each select="property">
<!-- Write only the NOT inherited properties-->
- <xsl:if test="not(@inherited)">
+ <xsl:if test="not(@inherited) or ($simple and $extension)">
<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>
@@ -142,7 +145,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:choose>
- <xsl:when test="(@restricted) and (@occuranceChanged) and (not(@typeChanged))">
+ <xsl:when test="(@restricted) and (@occuranceChanged) and (not(@typeChanged)) and (not(@rewrite))">
<xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
@@ -152,12 +155,12 @@
* 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)">
+ <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">
+ <xsl:if test="$min!=0 and @array">
if ((param != null) && (param.length < <xsl:value-of select="$min"/>)){
throw new java.lang.RuntimeException();
}
@@ -223,31 +226,54 @@
* This field was an array in <xsl:value-of select="$restriction"/>.</xsl:if>
*/
- protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
+ <xsl:if test="not(@inherited)">
+ protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
+ </xsl:if>
<xsl:if test="enumFacet">
- private static java.util.HashMap _table_ = new java.util.HashMap();
+ private static java.util.HashMap _table_ = new java.util.HashMap();
// Constructor
- protected <xsl:value-of select="$name"/>(<xsl:value-of select="$propertyType"/> value) {
- <xsl:value-of select="$varName" /> = value;
- <xsl:choose>
+ <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: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="$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: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"/>);
+ 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" />;}
@@ -687,7 +713,7 @@
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
}else{
<xsl:value-of select="$varName"/>.getOMDataSource(
@@ -736,7 +762,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:when test="$min=0">
@@ -773,7 +799,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:otherwise>
@@ -833,7 +859,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:when test="$min=0">
@@ -869,7 +895,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:otherwise>
@@ -928,7 +954,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:otherwise>
@@ -1015,7 +1041,7 @@
} else {
xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
}
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:when test="$min=0">
@@ -1054,7 +1080,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
</xsl:when>
<xsl:otherwise>
@@ -1138,7 +1164,7 @@
// write the nil attribute
<xsl:choose>
<xsl:when test="@nillable">
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
</xsl:when>
<xsl:otherwise>
throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
@@ -1226,7 +1252,7 @@
}
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
xmlWriter.writeEndElement();
}else{
<xsl:value-of select="$varName"/>.getOMDataSource(
@@ -1276,10 +1302,10 @@
<xsl:choose>
<xsl:when test="$nillable">
// write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
</xsl:when>
<xsl:otherwise>
- throw new RuntimeException("testValue cannot be null !!");
+ throw new RuntimeException("Value cannot be null !!");
</xsl:otherwise>
</xsl:choose>
}else{
@@ -1677,16 +1703,25 @@
* If this object is a complex type, the reader is positioned at the end element of its outer element
*/
public static <xsl:value-of select="$name"/> parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
- <xsl:if test="not(property/enumFacet)"><xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();</xsl:if>
- <xsl:if test="property/enumFacet"><xsl:value-of select="$name"/> object = null;</xsl:if>
+ <xsl:variable name="isEnumFacet" select="property/enumFacet"/>
+ <xsl:if test="not($isEnumFacet)"><xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();</xsl:if>
+ <xsl:if test="$isEnumFacet">
+ <xsl:value-of select="$name"/> object = null;
+ // initialize a hash map to keep values
+ java.util.Map attributeMap = new java.util.HashMap();
+ java.util.List extraAttributeList = new java.util.ArrayList();
+ </xsl:if>
+
int event;
+ String nillableValue = null;
try {
<!-- Advance to our start element, or if we are a complex type, to our first property start element or the outer end element if no properties -->
while (!reader.isStartElement() && !reader.isEndElement())
reader.next();
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
// Skip the element and report the null value. It cannot have subelements.
while (!reader.isEndElement())
reader.next();
@@ -1701,7 +1736,7 @@
}
</xsl:if>
- <xsl:if test="$isType or $anon">
+ <xsl:if test="$isType or $anon">
if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){
java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance",
"type");
@@ -1726,7 +1761,9 @@
// Note all attributes that were handled. Used to differ normal attributes
// from anyAttributes.
java.util.Vector handledAttributes = new java.util.Vector();
- <xsl:for-each select="property[@attribute]">
+ <!-- if this is an enumeration then we have to read attributes after-->
+
+ <xsl:for-each select="property[@attribute]">
<xsl:variable name="propertyName" select="@name"/>
<xsl:variable name="propertyType" select="@type"/>
<xsl:variable name="shortTypeNameUncapped" select="@shorttypename"/>
@@ -1751,14 +1788,30 @@
prefix = <xsl:value-of select="$attribName"/>.substring(0,index);
namespaceuri = reader.getNamespaceURI(prefix);
}
- object.set<xsl:value-of select="$javaName"/>(
- org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(<xsl:value-of select="$attribName"/>,namespaceuri));
+ <xsl:choose>
+ <xsl:when test="$isEnumFacet">
+ attributeMap.put("<xsl:value-of select="$javaName"/>",
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(<xsl:value-of select="$attribName"/>,namespaceuri));
+ </xsl:when>
+ <xsl:otherwise>
+ object.set<xsl:value-of select="$javaName"/>(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(<xsl:value-of select="$attribName"/>,namespaceuri));
+ </xsl:otherwise>
+ </xsl:choose>
+
</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:otherwise>
+ <xsl:choose>
+ <xsl:when test="$isEnumFacet">
+ attributeMap.put("<xsl:value-of select="$javaName"/>",
+ org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(<xsl:value-of select="$attribName"/>));
+ </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:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
</xsl:choose>
}
handledAttributes.add("<xsl:value-of select="$propertyName"/>");
@@ -1781,13 +1834,22 @@
org.apache.axiom.om.OMAbstractFactory.getOMFactory());
// and add it to the extra attributes
- object.addExtraAttributes(attr);
+ <xsl:choose>
+ <xsl:when test="property/enumFacet">
+ extraAttributeList.add(attr);
+ </xsl:when>
+ <xsl:otherwise>
+ object.addExtraAttributes(attr);
+ </xsl:otherwise>
+ </xsl:choose>
+
}
}
</xsl:if>
</xsl:for-each>
+
<xsl:if test="($isType or $anon) and not($simple)">
<!-- Skip the outer start element in order to process the subelements. -->
reader.next();
@@ -1859,7 +1921,8 @@
<xsl:choose>
<xsl:when test="@ours">
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -1883,7 +1946,8 @@
} else {
if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -1967,7 +2031,8 @@
<!-- if-block that handles nillable -->
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
}else{
@@ -2010,7 +2075,8 @@
<!-- handling binary case -->
<xsl:when test="@binary">
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -2064,7 +2130,8 @@
} else {
if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -2130,7 +2197,8 @@
<!-- if-block that handles nillable -->
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
}else{
</xsl:if>
@@ -2172,7 +2240,8 @@
<!-- End of Array handling of default class - that is the OMElement -->
<xsl:otherwise>
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -2197,7 +2266,8 @@
} else {
if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
<xsl:value-of select="$listName"/>.add(null);
reader.next();
} else {
@@ -2228,7 +2298,8 @@
</xsl:when>
<xsl:when test="@ours">
<xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if ("true".equals(nillableValue) || "1".equals(nillableValue)){
object.set<xsl:value-of select="$javaName"/>(null);
reader.next();
<xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
@@ -2325,7 +2396,8 @@
<!-- start of the simple types handling -->
<xsl:otherwise>
<xsl:if test="@nillable">
- if (!"true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+ if (!"true".equals(nillableValue) && !"1".equals(nillableValue)){
</xsl:if>
java.lang.String content = reader.getElementText();
<xsl:if test="not(enumFacet)">
@@ -2355,7 +2427,42 @@
</xsl:choose>
</xsl:if>
<xsl:if test="(enumFacet)">
- object = <xsl:value-of select="$name"/>.fromString(content);
+ object = <xsl:value-of select="$name"/>.fromString(content);
+ <!-- set the attribute values here since onbject is not initalized yet -->
+ <xsl:for-each select="../property[@attribute]">
+ <xsl:variable name="propertyName" select="@name"/>
+ <xsl:variable name="propertyType" select="@type"/>
+ <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:variable name="javaName" select="@javaname"/>
+ <xsl:variable name="attribName">tempObjectAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
+
+ <xsl:if test="$propertyName != 'extraAttributes'">
+ // handle attribute "<xsl:value-of select="$propertyName"/>"
+ java.lang.Object <xsl:value-of select="$attribName"/> =
+ attributeMap.get("<xsl:value-of select="$javaName"/>");
+ if (<xsl:value-of select="$attribName"/>!=null){
+ <xsl:choose>
+ <xsl:when test="$propertyType='javax.xml.namespace.QName'">
+ object.set<xsl:value-of select="$javaName"/>((javax.xml.namespace.QName)<xsl:value-of select="$attribName"/>);
+ </xsl:when>
+ <xsl:otherwise>
+ object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$shortTypeName"/>)<xsl:value-of select="$attribName"/>);
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+ </xsl:if>
+
+ <!-- Handle anyAttributes here -->
+ <xsl:if test="$propertyName = 'extraAttributes'">
+ for(java.util.Iterator iter = extraAttributeList.iterator();iter.hasNext();){
+ object.addExtraAttributes((org.apache.axiom.om.impl.llom.OMAttributeImpl)iter.next());
+ }
+ </xsl:if>
+
+ </xsl:for-each>
+
</xsl:if>
<xsl:if test="@nillable">
} else {
@@ -2427,8 +2534,9 @@
<!-- this is the common template -->
<xsl:template match="bean[@helperMode]">
- <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+ <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"/>
@@ -2438,10 +2546,11 @@
<xsl:variable name="originalName" select="@originalName"/>
<xsl:variable name="nsprefix" select="@nsprefix"/>
<xsl:variable name="extension" select="@extension"/>
- <xsl:variable name="mapperClass" select="@mapperClass"/>
- <xsl:variable name="package" select="@package"/>
+ <xsl:variable name="restriction" select="@restriction"/>
+ <xsl:variable name="mapperClass" select="@mapperClass"/>
+ <xsl:variable name="package" select="@package"/>
<xsl:variable name="helpername"><xsl:value-of select="$name"/>Helper</xsl:variable>
- <!-- write the class header. this should be done only when unwrapped -->
+ <!-- write the class header. this should be done only when unwrapped -->
<xsl:if test="not(not(@unwrapped) or (@skip-write))">
/**
@@ -2451,7 +2560,7 @@
* by the Apache Axis2 version: #axisVersion# #today#
*/
- package <xsl:value-of select="$package"/>;
+ package <xsl:value-of select="@package"/>;
/**
* <xsl:value-of select="$name"/> bean class
*/
@@ -2465,16 +2574,16 @@
{
<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"/>
+ 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:value-of select="$nsuri"/>",
+ "<xsl:value-of select="$originalName"/>",
+ "<xsl:value-of select="$nsprefix"/>");
</xsl:otherwise>
</xsl:choose>
@@ -2504,214 +2613,520 @@
<xsl:variable name="settingTracker">local<xsl:value-of select="$javaName"/>Tracker</xsl:variable>
- /**
- * 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: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)))" />
- protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
- <!-- 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>
- }
+ <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
- * @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 tracker always 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>
+ /**
+ * 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:if>
- this.<xsl:value-of select="$varName"/>=param;
- }
+ </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>
- <!-- 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"/>{};
- }
+ <!-- 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>
+ }
- <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()]);
+ /**
+ * 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>
- <!-- end of special casing for the array-->
+ <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>
- </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 the primivite tracker 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>
+ /**
+ * 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>
- this.<xsl:value-of select="$varName"/>=param;
- }
- </xsl:otherwise>
- </xsl:choose>
+ protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
+ <xsl:if test="enumFacet">
+ private static java.util.HashMap _table_ = new java.util.HashMap();
+ // Constructor
+ protected <xsl:value-of select="$name"/>(<xsl:value-of select="$propertyType"/> value) {
+ <xsl:value-of select="$varName" /> = value;
+ <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>
- <!-- end of xsl:if for not(@inherited) -->
- </xsl:if>
+ }
- </xsl:for-each>
+ <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: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"/>);
+ </xsl:for-each>
- }
- </xsl:when>
- <xsl:otherwise>
- <!-- Start of helper generation part of the template-->
+ public <xsl:value-of select="$propertyType"/> getValue() { return <xsl:value-of select="$varName" />;}
+ public static <xsl:value-of select="$name"/> fromValue(<xsl:value-of select="$propertyType"/> value)
+ throws java.lang.IllegalArgumentException {
+ <xsl:value-of select="$name"/> enumeration = (<xsl:value-of select="$name"/>)
+ <xsl:choose>
+ <xsl:when test="@primitive">
+ _table_.get(value + "");
+ </xsl:when>
+ <xsl:otherwise>
+ _table_.get(value);
+ </xsl:otherwise>
+ </xsl:choose>
+
+ if (enumeration==null) throw new java.lang.IllegalArgumentException();
+ return enumeration;
+ }
+ public static <xsl:value-of select="$name"/> fromString(java.lang.String value)
+ throws java.lang.IllegalArgumentException {
+ try {
+ <xsl:choose>
+ <xsl:when test="@primitive">
+ return fromValue(org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(value));
+ </xsl:when>
+ <xsl:otherwise>
+ return fromValue(new <xsl:value-of select="$propertyType"/>(value));
+ </xsl:otherwise>
+ </xsl:choose>
+
+ } catch (java.lang.Exception e) {
+ throw new java.lang.IllegalArgumentException();
+ }
+ }
+ 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: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 ( 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 ( 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"/> < </xsl:if> param.length() <xsl:if test="(@maxLenFacet)"> > <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)">
+ if ( <xsl:if test="(@minExFacet)"> <xsl:value-of select="$minExFacet"/> < </xsl:if> <xsl:if test="(@minInFacet)"> <xsl:value-of select="$minInFacet"/> <= </xsl:if> param <xsl:if test="(@maxExFacet)"> > <xsl:value-of select="$maxExFacet"/> </xsl:if> <xsl:if test="(@maxInFacet)"> >= <xsl:value-of select="$maxInFacet"/> </xsl:if> ) {
+
+ this.<xsl:value-of select="$varName"/>=param;
+ }
+ else {
+ throw new java.lang.RuntimeException();
+ }
+ </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>
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- end of xsl:if for not(@inherited) -->
+ </xsl:if>
+
+ </xsl:for-each>
+
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- Start of helper generation part of the template-->
public <xsl:if test="not(@unwrapped) or (@skip-write)">static</xsl:if> class <xsl:value-of select="$helpername"/> {
<!-- get OMElement methods that allows direct writing. generated inside the helper class-->
<xsl:variable name="fullyQualifiedName"><xsl:value-of select="$package"/>.<xsl:value-of select="$name"/></xsl:variable>
<xsl:variable name="fullyQualifiedHelperName"><xsl:value-of select="$package"/>.<xsl:value-of select="$helpername"/></xsl:variable>
- /**
+
+ /**
+ * 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 static org.apache.axiom.om.OMElement getOMElement(
+ final <xsl:value-of select="$fullyQualifiedName"/> bean,
+ final javax.xml.namespace.QName parentQName,
+ final org.apache.axiom.om.OMFactory factory){
+
+ org.apache.axiom.om.OMDataSource dataSource = getOMDataSource(bean,parentQName, factory);
+
+ <xsl:choose>
+ <xsl:when test="@type">
+ return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
+ parentQName,factory,dataSource);
+ </xsl:when>
+ <xsl:otherwise>
+ return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
+ <xsl:value-of select="$fullyQualifiedName"/>.MY_QNAME,factory,dataSource);
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+
+ /**
*
* @param parentQName
* @param factory
* @return org.apache.axiom.om.OMElement
*/
- public static org.apache.axiom.om.OMElement getOMElement(
+ public static org.apache.axiom.om.OMDataSource getOMDataSource(
final <xsl:value-of select="$fullyQualifiedName"/> bean,
final javax.xml.namespace.QName parentQName,
final org.apache.axiom.om.OMFactory factory){
+
org.apache.axiom.om.OMDataSource dataSource =
new org.apache.axis2.databinding.ADBHelperDataSource(bean,parentQName,"<xsl:value-of select="$fullyQualifiedHelperName"/>"){
- public void serialize(
- javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
- <xsl:value-of select="$fullyQualifiedName"/> typedBean =
+ public void serialize(
+ javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
+
+ <xsl:value-of select="$fullyQualifiedName"/> typedBean =
(<xsl:value-of select="$fullyQualifiedName"/>)bean;
- <xsl:choose>
+
+ <xsl:choose>
<xsl:when test="@type or @anon">
<!-- For a type write the passed in QName first-->
- xmlWriter.writeStartElement(parentQName.getNamespaceURI(),
- parentQName.getLocalPart());
- <!-- write the type attribute if needed -->
+ java.lang.String prefix = parentQName.getPrefix();
+ java.lang.String namespace = parentQName.getNamespaceURI();
+
+ if (namespace != null) {
+ java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
+ if (writerPrefix != null) {
+ xmlWriter.writeStartElement(namespace, parentQName.getLocalPart());
+ } else {
+ if (prefix == null) {
+ prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+ }
+
+ xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace);
+ xmlWriter.writeNamespace(prefix, namespace);
+ xmlWriter.setPrefix(prefix, namespace);
+ }
+ } else {
+ xmlWriter.writeStartElement(parentQName.getLocalPart());
+ }
+
+ <!-- write the type attribute if needed -->
<xsl:if test="$extension">
writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
registerPrefix(xmlWriter,"<xsl:value-of select="$nsuri"/>")+":<xsl:value-of select="$originalName"/>",
@@ -2725,9 +3140,10 @@
<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(),
+ writeAttribute(<xsl:value-of select="$varName"/>.getNamespace().getName(),
<xsl:value-of select="$varName"/>.getLocalName(),
- <xsl:value-of select="$varName"/>.getAttributeValue(),xmlWriter);
+ <xsl:value-of select="$varName"/>.getAttributeValue(),
+ xmlWriter);
</xsl:when>
<xsl:when test="@any and @array">
if (<xsl:value-of select="$varName"/> != null) {
@@ -2753,7 +3169,8 @@
<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);
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>),
+ xmlWriter);
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
@@ -2762,10 +3179,12 @@
<xsl:for-each select="property[not(@attribute)]">
<xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
<xsl:variable name="varName">typedBean.local<xsl:value-of select="@javaname"/></xsl:variable>
+ <xsl:variable name="javaname"><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="settingTracker">typedBean.local<xsl:value-of select="@javaname"/>Tracker</xsl:variable>
+ <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
<xsl:if test="$min=0 or $choice"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
<xsl:choose>
@@ -2773,14 +3192,34 @@
<xsl:choose>
<xsl:when test="@nillable">
if (<xsl:value-of select="$varName"/>==null){
- xmlWriter.writeStartElement("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>");
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
- xmlWriter.writeEndElement();
+
+ java.lang.String namespace2 = "<xsl:value-of select="$namespace"/>";
+
+ if (! namespace2.equals("")) {
+ java.lang.String prefix2 = xmlWriter.getPrefix(namespace2);
+
+ if (prefix2 == null) {
+ prefix2 = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+
+ xmlWriter.writeStartElement(prefix2,"<xsl:value-of select="$propertyName"/>", namespace2);
+ xmlWriter.writeNamespace(prefix2, namespace2);
+ xmlWriter.setPrefix(prefix2, namespace2);
+
+ } else {
+ xmlWriter.writeStartElement(namespace2,"<xsl:value-of select="$propertyName"/>");
+ }
+
+ } else {
+ xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
+ }
+
+
+ // write the nil attribute
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
+ xmlWriter.writeEndElement();
}else{
- <xsl:value-of select="@type"/>Helper.getOMElement(
- <xsl:value-of select="$varName"/>,
- new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
+ <xsl:value-of select="@type"/>Helper.getOMDataSource(<xsl:value-of select="$varName"/>,
+ new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
factory).serialize(xmlWriter);
}
</xsl:when>
@@ -2788,127 +3227,487 @@
if (<xsl:value-of select="$varName"/>==null){
throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
}
-
- <xsl:value-of select="@type"/>Helper.getOMElement(
- <xsl:value-of select="$varName"/>,
- new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
- factory).serialize(xmlWriter);
-
+ <xsl:value-of select="@type"/>Helper.getOMDataSource(<xsl:value-of select="$varName"/>,
+ new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
+ factory).serialize(xmlWriter);
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@ours and @array and not(@default)">
- <xsl:choose>
+ 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="@arrayBaseType"/>Helper.getOMDataSource(<xsl:value-of select="$varName"/>[i],
+ new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"),
+ factory).serialize(xmlWriter);
+ } else {
+ <xsl:choose>
+ <xsl:when test="@nillable">
+ // write null attribute
+ java.lang.String namespace2 = "<xsl:value-of select="$namespace"/>";
+ if (! namespace2.equals("")) {
+ java.lang.String prefix2 = xmlWriter.getPrefix(namespace2);
+
+ if (prefix2 == null) {
+ prefix2 = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+
+ xmlWriter.writeStartElement(prefix2,"<xsl:value-of select="$propertyName"/>", namespace2);
+ xmlWriter.writeNamespace(prefix2, namespace2);
+ xmlWriter.setPrefix(prefix2, namespace2);
+
+ } else {
+ xmlWriter.writeStartElement(namespace2,"<xsl:value-of select="$propertyName"/>");
+ }
+
+ } else {
+ xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
+ }
+
+ // 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 RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
+ </xsl:otherwise>
+ </xsl:choose>
+ }
+
+ }
+ } else {
+ <xsl:choose>
<xsl:when test="@nillable">
- // this property is nillable
- if (<xsl:value-of select="$varName"/>!=null){
- <!--this bracket needs to be closed!-->
+ // write null attribute
+ java.lang.String namespace2 = "<xsl:value-of select="$namespace"/>";
+ if (! namespace2.equals("")) {
+ java.lang.String prefix2 = xmlWriter.getPrefix(namespace2);
+
+ if (prefix2 == null) {
+ prefix2 = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+
+ xmlWriter.writeStartElement(prefix2,"<xsl:value-of select="$propertyName"/>", namespace2);
+ xmlWriter.writeNamespace(prefix2, namespace2);
+ xmlWriter.setPrefix(prefix2, namespace2);
+
+ } else {
+ xmlWriter.writeStartElement(namespace2,"<xsl:value-of select="$propertyName"/>");
+ }
+
+ } else {
+ xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
+ }
+
+ // write the nil attribute
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter);
+ xmlWriter.writeEndElement();
</xsl:when>
<xsl:otherwise>
- if (<xsl:value-of select="$varName"/>==null){
- throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
- }
+ throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
</xsl:otherwise>
</xsl:choose>
+ }
+ </xsl:when>
+
+ <xsl:when test="@default and @array">
+ <!-- Note - Assumed to be OMElement-->
[... 1800 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org