|
|
Axis 2 example source code file (PlainBeanTemplate.xsl)
This example Axis 2 source code file (PlainBeanTemplate.xsl) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The Axis 2 PlainBeanTemplate.xsl source code
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<!-- cater for the multiple classes - wrappped mode -->
<xsl:template match="/beans">
<xsl:variable name="name">
/**
* <xsl:value-of select="$name"/>.java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: #axisVersion# #today#
*/
package <xsl:value-of select="@package"/>;
/**
* <xsl:value-of select="$name"/> wrapped bean classes
*/
public class <xsl:value-of select="$name"/>{
<xsl:apply-templates/>
}
</xsl:template>
<!--cater for the multiple classes - unwrappped mode -->
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="bean">
/**
* <xsl:value-of select="@name"/>.java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: #axisVersion# #today#
*/
package <xsl:value-of select="@package"/>;
<xsl:variable name="name">
/**
* <xsl:value-of select="$name"/> bean class
*/
public class <xsl:value-of select="$name"/> extends {
<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>
<xsl:for-each select="property">
<xsl:variable name="propertyType">
<xsl:variable name="propertyName">
<xsl:variable name="javaName">
<xsl:variable name="varName">local
/**
* field for <xsl:value-of select="$javaName"/>
<xsl:if test="@attribute">* This was an Attribute!
<xsl:if test="@array">* This was an Array!
*/
private <xsl:value-of select="$propertyType"/> ;
/**
* Auto generated getter method
* @return <xsl:value-of select="$propertyType"/>
*/
public <xsl:value-of select="$propertyType"/> get(){
return <xsl:value-of select="$varName"/>;
}
/**
* Auto generated setter method
* @param param <xsl:value-of select="$javaName"/>
*/
public void set<xsl:value-of select="$javaName"/>( param){
<!--Add the validation code. For now we only add the validation code for arrays-->
<xsl:if test="@array">
<xsl:if test="not(@unbound)">
if (param.length > <xsl:value-of select="@maxOccurs">){
throw new java.lang.RuntimeException();
}
</xsl:if>
<xsl:if test="@minOccurs">
if (param.length < <xsl:value-of select="@minOccurs">){
throw new java.lang.RuntimeException();
}
</xsl:if>
</xsl:if>
this.<xsl:value-of select="$varName"/>=param;
}
</xsl:for-each>
}
</xsl:template>
</xsl:stylesheet>
Other Axis 2 examples (source code examples)
Here is a short list of links related to this Axis 2 PlainBeanTemplate.xsl source code file:
|