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 sa...@apache.org on 2007/02/23 09:46:31 UTC
svn commit: r510872 - in
/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema:
template/CADBBeanTemplateHeader.xsl template/CADBBeanTemplateSource.xsl
writer/CStructWriter.java
Author: samisa
Date: Fri Feb 23 00:46:30 2007
New Revision: 510872
URL: http://svn.apache.org/viewvc?view=rev&rev=510872
Log:
Dopped ops struct and fixed namespace problems in generated C code
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateHeader.xsl
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateSource.xsl
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateHeader.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateHeader.xsl?view=diff&rev=510872&r1=510871&r2=510872
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateHeader.xsl (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateHeader.xsl Fri Feb 23 00:46:30 2007
@@ -100,96 +100,85 @@
* <xsl:value-of select="$axis2_name"/> class class
*/
typedef struct <xsl:value-of select="$axis2_name"/><xsl:text> </xsl:text><xsl:value-of select="$axis2_name"/>_t;
- typedef struct <xsl:value-of select="$axis2_name"/>_ops<xsl:text> </xsl:text><xsl:value-of select="$axis2_name"/>_ops_t;
-
- struct <xsl:value-of select="$axis2_name"/>_ops
- {
- axis2_status_t (AXIS2_CALL*
- free )(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
-
- <xsl:if test="not(@type)">
- axis2_qname_t* (AXIS2_CALL*
- get_qname )(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
- </xsl:if>
-
- axiom_node_t* (AXIS2_CALL*
- serialize )(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env,
- axiom_node_t* <xsl:value-of select="$name"/>_om_node, int has_parent);
-
- axis2_status_t (AXIS2_CALL*
- deserialize )(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env, axiom_node_t* parent);
-
- <xsl:for-each select="property">
- <xsl:variable name="propertyType">
- <xsl:choose>
- <xsl:when test="@isarray">axis2_array_list_t*</xsl:when>
- <xsl:when test="not(@type)">axiom_node_t*</xsl:when> <!-- these are anonymous -->
- <xsl:when test="@ours">axis2_<xsl:value-of select="@type"/>_t*</xsl:when>
- <xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
- <xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
-
- /**
- * Auto generated getter method
- * @return <xsl:value-of select="$propertyName"/>
- */
- <xsl:value-of select="$propertyType"/> (AXIS2_CALL*
- get_<xsl:value-of select="$CName"/>)(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
-
- /**
- * Auto generated setter method
- * @param param <xsl:value-of select="$propertyName"/>
- */
- axis2_status_t (AXIS2_CALL*
- set_<xsl:value-of select="$CName"/>)(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env,
- <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text> param_<xsl:value-of select="$CName"/>);
-
- <xsl:if test="@isarray">
- /**
- * Auto generated resetter method
- * @param param <xsl:value-of select="$propertyName"/>
- */
- axis2_status_t (AXIS2_CALL*
- reset_<xsl:value-of select="$CName"/>)(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
- </xsl:if>
- </xsl:for-each>
- };
- struct <xsl:value-of select="$axis2_name"/>
- {
- <xsl:value-of select="$axis2_name"/>_ops_t* ops;
- };
AXIS2_EXTERN <xsl:value-of select="$axis2_name"/>_t* AXIS2_CALL
<xsl:value-of select="$axis2_name"/>_create(
const axis2_env_t *env );
+ axis2_status_t AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_free (
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env);
+
+ <xsl:if test="not(@type)">
+ axis2_qname_t* AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_get_qname (
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env);
+ </xsl:if>
+
+ axiom_node_t* AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_serialize(
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env,
+ axiom_node_t* <xsl:value-of select="$name"/>_om_node, int has_parent);
+
+ axis2_status_t AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_deserialize(
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env, axiom_node_t* parent);
+
+ <xsl:for-each select="property">
+ <xsl:variable name="propertyType">
+ <xsl:choose>
+ <xsl:when test="@isarray">axis2_array_list_t*</xsl:when>
+ <xsl:when test="not(@type)">axiom_node_t*</xsl:when> <!-- these are anonymous -->
+ <xsl:when test="@ours">axis2_<xsl:value-of select="@type"/>_t*</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
+ <xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
+
+ /**
+ * getter for <xsl:value-of select="$propertyName"/>.
+ */
+ <xsl:value-of select="$propertyType"/> AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_get_<xsl:value-of select="$CName"/>(
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env);
+
+ /**
+ * setter for <xsl:value-of select="$propertyName"/>
+ */
+ axis2_status_t AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_set_<xsl:value-of select="$CName"/>(
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env,
+ <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text> param_<xsl:value-of select="$CName"/>);
+
+ <xsl:if test="@isarray">
+ /**
+ * resetter for <xsl:value-of select="$propertyName"/>
+ */
+ axis2_status_t AXIS2_CALL
+ <xsl:value-of select="$axis2_name"/>_reset_<xsl:value-of select="$CName"/>(
+ <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
+ const axis2_env_t *env);
+ </xsl:if>
+ </xsl:for-each>
+
#define <xsl:value-of select="$caps_axis2_name"/>_FREE(<xsl:value-of select="$name"/>, env) \
- ((<xsl:value-of select="$name"/>)->ops->free(<xsl:value-of select="$name"/>, env))
+ <xsl:value-of select="$axis2_name"/>_free(<xsl:value-of select="$name"/>, env)
<xsl:if test="not(@type)">
#define <xsl:value-of select="$caps_axis2_name"/>_GET_QNAME(<xsl:value-of select="$name"/>, env) \
- ((<xsl:value-of select="$name"/>)->ops->get_qname(<xsl:value-of select="$name"/>, env))
+ <xsl:value-of select="$axis2_name"/>_get_qname(<xsl:value-of select="$name"/>, env)
</xsl:if>
#define <xsl:value-of select="$caps_axis2_name"/>_SERIALIZE(<xsl:value-of select="$name"/>, env, node, has_parent) \
- ((<xsl:value-of select="$name"/>)->ops->serialize(<xsl:value-of select="$name"/>, env, node, has_parent))
+ <xsl:value-of select="$axis2_name"/>_serialize(<xsl:value-of select="$name"/>, env, node, has_parent)
#define <xsl:value-of select="$caps_axis2_name"/>_DESERIALIZE(<xsl:value-of select="$name"/>, env, parent) \
- ((<xsl:value-of select="$name"/>)->ops->deserialize(<xsl:value-of select="$name"/>, env, parent))
+ <xsl:value-of select="$axis2_name"/>_deserialize(<xsl:value-of select="$name"/>, env, parent)
<xsl:for-each select="property">
<xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
@@ -198,15 +187,15 @@
<xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
<xsl:variable name="capsCName"><xsl:value-of select="@caps-cname"></xsl:value-of></xsl:variable>
- #define <xsl:value-of select="$caps_axis2_name"/>_GET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env) \
- ((<xsl:value-of select="$name"/>)->ops->get_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env))
+ #define <xsl:value-of select="$caps_axis2_name"/>_GET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env) \
+ <xsl:value-of select="$axis2_name"/>_get_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env)
- #define <xsl:value-of select="$caps_axis2_name"/>_SET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env, param) \
- ((<xsl:value-of select="$name"/>)->ops->set_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env, param))
+ #define <xsl:value-of select="$caps_axis2_name"/>_SET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env, param) \
+ <xsl:value-of select="$axis2_name"/>_set_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env, param)
<xsl:if test="@isarray">
- #define <xsl:value-of select="$caps_axis2_name"/>_RESET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env) \
- ((<xsl:value-of select="$name"/>)->ops->reset_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env))
+ #define <xsl:value-of select="$caps_axis2_name"/>_RESET_<xsl:value-of select="$capsCName"/>(<xsl:value-of select="$name"/>, env) \
+ <xsl:value-of select="$axis2_name"/>_reset_<xsl:value-of select="$CName"/>(<xsl:value-of select="$name"/>, env)
</xsl:if>
</xsl:for-each>
#ifdef __cplusplus
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateSource.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateSource.xsl?view=diff&rev=510872&r1=510871&r2=510872
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateSource.xsl (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/CADBBeanTemplateSource.xsl Fri Feb 23 00:46:30 2007
@@ -62,12 +62,8 @@
</xsl:choose>
- typedef struct <xsl:value-of select="$axis2_name"/><xsl:text>_impl </xsl:text><xsl:value-of select="$axis2_name"/>_impl_t;
-
- struct <xsl:value-of select="$axis2_name"/>_impl
+ struct <xsl:value-of select="$axis2_name"/>
{
- <xsl:value-of select="$axis2_name"/>_t <xsl:value-of select="$name"/>;
-
<xsl:if test="not(@type)">
axis2_qname_t* qname;
</xsl:if>
@@ -81,12 +77,6 @@
<xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
- <xsl:variable name="propertyBaseType">
- <xsl:choose>
- <xsl:when test="@ours">axis2_<xsl:value-of select="@type"/>_t*</xsl:when>
- <xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
<xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
<xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
@@ -94,138 +84,47 @@
</xsl:for-each>
};
- #define AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>) \
- ((<xsl:value-of select="$axis2_name"/>_impl_t *) <xsl:value-of select="$name"/>)
-
- /************************* Function prototypes ********************************/
-
- axis2_status_t AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_free (
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
-
- <xsl:if test="not(@type)">
- axis2_qname_t* AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_get_qname (
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
- </xsl:if>
-
- axiom_node_t* AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_serialize(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env,
- axiom_node_t* <xsl:value-of select="$name"/>_om_node, int has_parent);
-
- axis2_status_t AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_deserialize(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env, axiom_node_t* parent);
-
- <xsl:for-each select="property">
- <xsl:variable name="propertyType">
- <xsl:choose>
- <xsl:when test="@isarray">axis2_array_list_t*</xsl:when>
- <xsl:when test="not(@type)">axiom_node_t*</xsl:when> <!-- these are anonymous -->
- <xsl:when test="@ours">axis2_<xsl:value-of select="@type"/>_t*</xsl:when>
- <xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
- <xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
-
- /**
- * getter for <xsl:value-of select="$propertyName"/>.
- */
- <xsl:value-of select="$propertyType"/> AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_get_<xsl:value-of select="$CName"/>(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
-
- /**
- * setter for <xsl:value-of select="$propertyName"/>
- */
- axis2_status_t AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_set_<xsl:value-of select="$CName"/>(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env,
- <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text> param_<xsl:value-of select="$CName"/>);
-
- <xsl:if test="@isarray">
- /**
- * resetter for <xsl:value-of select="$propertyName"/>
- */
- axis2_status_t AXIS2_CALL
- <xsl:value-of select="$axis2_name"/>_reset_<xsl:value-of select="$CName"/>(
- <xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
- const axis2_env_t *env);
- </xsl:if>
- </xsl:for-each>
/************************* Function Implmentations ********************************/
AXIS2_EXTERN <xsl:value-of select="$axis2_name"/>_t* AXIS2_CALL
<xsl:value-of select="$axis2_name"/>_create(
const axis2_env_t *env )
{
- <xsl:value-of select="$axis2_name"/>_impl_t* <xsl:value-of select="$name"/>_impl = NULL;
+ <xsl:value-of select="$axis2_name"/>_t *<xsl:value-of select="$name"/> = NULL;
<xsl:if test="not(@type)">
axis2_qname_t* qname = NULL;
</xsl:if>
AXIS2_ENV_CHECK(env, NULL);
- <xsl:value-of select="$name"/>_impl = (<xsl:value-of select="$axis2_name"/>_impl_t *) AXIS2_MALLOC(env->
- allocator, sizeof(<xsl:value-of select="$axis2_name"/>_impl_t));
+ <xsl:value-of select="$name"/> = (<xsl:value-of select="$axis2_name"/>_t *) AXIS2_MALLOC(env->
+ allocator, sizeof(<xsl:value-of select="$axis2_name"/>_t));
- if(NULL == <xsl:value-of select="$name"/>_impl)
+ if(NULL == <xsl:value-of select="$name"/>)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
- <xsl:value-of select="$name"/>_impl-> <xsl:value-of select="$name"/>.ops =
- AXIS2_MALLOC (env->allocator, sizeof(<xsl:value-of select="$axis2_name"/>_ops_t));
- if(NULL == <xsl:value-of select="$name"/>_impl-> <xsl:value-of select="$name"/>.ops)
- {
- axis2_<xsl:value-of select="$name"/>_free(&(<xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>), env);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return NULL;
- }
-
<xsl:for-each select="property">
<xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
<xsl:choose>
<xsl:when test="@ours">
- <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/> = NULL;
+ <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/> = NULL;
</xsl:when>
<!-- todo for others -->
</xsl:choose>
</xsl:for-each>
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->free = <xsl:value-of select="$axis2_name"/>_free;
- <xsl:if test="not(@type)">
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->get_qname = <xsl:value-of select="$axis2_name"/>_get_qname;
- </xsl:if>
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->serialize = <xsl:value-of select="$axis2_name"/>_serialize;
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->deserialize = <xsl:value-of select="$axis2_name"/>_deserialize;
- <xsl:for-each select="property">
- <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
- <xsl:variable name="CName"><xsl:value-of select="@cname"></xsl:value-of></xsl:variable>
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->get_<xsl:value-of select="$CName"/> = <xsl:value-of select="$axis2_name"/>_get_<xsl:value-of select="$CName"/>;
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->set_<xsl:value-of select="$CName"/> = <xsl:value-of select="$axis2_name"/>_set_<xsl:value-of select="$CName"/>;
- <xsl:if test="@isarray">
- <xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>.ops->reset_<xsl:value-of select="$CName"/> = <xsl:value-of select="$axis2_name"/>_reset_<xsl:value-of select="$CName"/>;
- </xsl:if>
- </xsl:for-each>
<xsl:if test="not(@type)">
qname = axis2_qname_create (env,
"<xsl:value-of select="@originalName"/>",
"<xsl:value-of select="@nsuri"/>",
"<xsl:value-of select="@nsprefix"/>");
- <xsl:value-of select="$name"/>_impl->qname = qname;
+ <xsl:value-of select="$name"/>->qname = qname;
</xsl:if>
- return &(<xsl:value-of select="$name"/>_impl-><xsl:value-of select="$name"/>);
+ return <xsl:value-of select="$name"/>;
}
axis2_status_t AXIS2_CALL
@@ -233,7 +132,6 @@
<xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
const axis2_env_t *env)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
<!--<xsl:if test="property/@isarray and (property/@ours or property/@type='axis2_char_t*' or property/@type='axis2_date_time_t*' or property/@type='axis2_base64_binary_t*' or property/@type='axiom_node_t*')">-->
<xsl:if test="property/@isarray">
int i = 0;
@@ -243,8 +141,6 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
-
<xsl:for-each select="property">
<!-- please check all the freeing thing below -->
<!--<xsl:if test="@isarray or not(@type='short' or @type='int' or @type='char' or @type='long' or @type='double' or @type='float' or @type='axis2_bool_t')">-->
@@ -285,13 +181,13 @@
<xsl:variable name="attriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">(<xsl:value-of select="$nativePropertyType"/>)element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="justAttriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -299,12 +195,12 @@
<!-- handles arrays -->
<xsl:if test="@isarray">
- if ( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/> != NULL)
+ if ( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/> != NULL)
{
- count = AXIS2_ARRAY_LIST_SIZE( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/>, env);
+ count = AXIS2_ARRAY_LIST_SIZE( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/>, env);
for( i = 0; i < count; i ++)
{
- element = AXIS2_ARRAY_LIST_GET( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/>, env, i);
+ element = AXIS2_ARRAY_LIST_GET( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/>, env, i);
</xsl:if>
<!-- the following element can be inside array or independent one -->
@@ -363,30 +259,24 @@
<!-- close tags arrays -->
<xsl:if test="@isarray">
}
- AXIS2_ARRAY_LIST_FREE( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/>, env);
+ AXIS2_ARRAY_LIST_FREE( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/>, env);
}
</xsl:if>
</xsl:if> <!--close for test of primitive types -->
</xsl:for-each>
<xsl:if test="not(@type)">
- if(<xsl:value-of select="$name"/>_impl->qname )
+ if(<xsl:value-of select="$name"/>->qname )
{
- AXIS2_QNAME_FREE (<xsl:value-of select="$name"/>_impl->qname, env);
- <xsl:value-of select="$name"/>_impl->qname = NULL;
+ AXIS2_QNAME_FREE (<xsl:value-of select="$name"/>->qname, env);
+ <xsl:value-of select="$name"/>->qname = NULL;
}
</xsl:if>
- if(<xsl:value-of select="$name"/>->ops)
+ if(<xsl:value-of select="$name"/>)
{
- AXIS2_FREE(env->allocator, <xsl:value-of select="$name"/>->ops);
- <xsl:value-of select="$name"/>->ops = NULL;
- }
-
- if(<xsl:value-of select="$name"/>_impl)
- {
- AXIS2_FREE( env->allocator, <xsl:value-of select="$name"/>_impl);
- <xsl:value-of select="$name"/>_impl = NULL;
+ AXIS2_FREE( env->allocator, <xsl:value-of select="$name"/>);
+ <xsl:value-of select="$name"/> = NULL;
}
return AXIS2_SUCCESS;
}
@@ -397,13 +287,9 @@
<xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
const axis2_env_t *env)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
-
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
-
- return <xsl:value-of select="$name"/>_impl-> qname;
+ return <xsl:value-of select="$name"/>-> qname;
}
</xsl:if>
@@ -413,7 +299,6 @@
const axis2_env_t *env,
axiom_node_t* parent)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
axis2_status_t status = AXIS2_SUCCESS;
axiom_namespace_t *ns1 = NULL;
@@ -463,7 +348,6 @@
axiom_element_t *current_element = NULL;
</xsl:if>
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
ns1 = axiom_namespace_create (env,
"<xsl:value-of select="$nsuri"/>",
@@ -484,7 +368,7 @@
<xsl:if test="position()=1">
current_element = AXIOM_NODE_GET_DATA_ELEMENT( parent, env);
qname = AXIOM_ELEMENT_GET_QNAME( current_element, env, parent);
- if ( AXIS2_QNAME_EQUALS( qname, env, <xsl:value-of select="$name"/>_impl-> qname ) )
+ if ( AXIS2_QNAME_EQUALS( qname, env, <xsl:value-of select="$name"/>-> qname ) )
{
first_node = AXIOM_NODE_GET_FIRST_CHILD( parent, env);
}
@@ -544,13 +428,13 @@
<xsl:variable name="attriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">(<xsl:value-of select="$nativePropertyType"/>)element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="justAttriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
@@ -648,7 +532,7 @@
<!-- add hex_binary_t* s -->
<xsl:when test="$nativePropertyType='axis2_base64_binary_t*'">
element = (void*)axis2_base64_binary_create( env);
- AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/>, env,
+ AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/>, env,
attrib_text);
<xsl:value-of select="$axis2_capsname"/>_SET_<xsl:value-of select="$CapsCName"/>( <xsl:value-of select="$name"/>,
env, ( <xsl:value-of select="$nativePropertyType"/>)element);
@@ -894,7 +778,7 @@
<xsl:when test="$nativePropertyType='axis2_base64_binary_t*'">
element = (void*)axis2_base64_binary_create( env);
text_value = AXIOM_ELEMENT_GET_TEXT(current_element, env, current_node );
- status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/>, env,
+ status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( (axis2_base64_binary_t*)element, env,
text_value);
if( AXIS2_FAILURE == status)
{
@@ -1057,7 +941,7 @@
<xsl:when test="$nativePropertyType='axis2_base64_binary_t*'">
element = (void*)axis2_base64_binary_create( env);
text_value = AXIOM_ELEMENT_GET_TEXT(current_element, env, current_node );
- status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/>, env,
+ status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/>, env,
text_value);
if( AXIS2_FAILURE == status)
{
@@ -1212,7 +1096,7 @@
<xsl:when test="$nativePropertyType='axis2_base64_binary_t*'">
element = (void*)axis2_base64_binary_create( env);
text_value = AXIOM_ELEMENT_GET_TEXT(current_element, env, current_node );
- status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/>, env,
+ status = AXIS2_BASE64_BINARY_SET_ENCODED_BINARY( <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/>, env,
text_value);
if( AXIS2_FAILURE == status)
{
@@ -1258,8 +1142,6 @@
<xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
const axis2_env_t *env, axiom_node_t* parent, int has_parent)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
-
<!-- first declration part -->
axiom_namespace_t *ns1 = NULL;
<xsl:for-each select="property/@attribute">
@@ -1317,7 +1199,6 @@
unsigned int end_input_str_len = 0;
</xsl:if>
AXIS2_ENV_CHECK(env, NULL);
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
ns1 = axiom_namespace_create (env,
"<xsl:value-of select="$nsuri"/>",
@@ -1396,13 +1277,13 @@
<xsl:variable name="attriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">(<xsl:value-of select="$nativePropertyType"/>)element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="justAttriName"><!--these are used in arrays to take the native type-->
<xsl:choose>
<xsl:when test="@isarray">element</xsl:when>
- <xsl:otherwise><xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
+ <xsl:otherwise><xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -1521,16 +1402,16 @@
/**
* parsing <xsl:value-of select="$CName"/> array
*/
- if ( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/> != NULL)
+ if ( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/> != NULL)
{
- start_input_str = "<<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/>>";
+ start_input_str = "<<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/><xsl:if test="@child-nsuri and @child-nsprefix and @ours"> xmlns:<xsl:value-of select="@child-nsprefix"/>=\"<xsl:value-of select="@child-nsuri"/>\"</xsl:if>>";
start_input_str_len = axis2_strlen(start_input_str);
end_input_str = "</<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/>>";
end_input_str_len = axis2_strlen(end_input_str);
- count = AXIS2_ARRAY_LIST_SIZE( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/>, env);
+ count = AXIS2_ARRAY_LIST_SIZE( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/>, env);
for( i = 0; i < count; i ++)
{
- element = AXIS2_ARRAY_LIST_GET( <xsl:value-of select="$name"/>_impl->attrib_<xsl:value-of select="$CName"/>, env, i);
+ element = AXIS2_ARRAY_LIST_GET( <xsl:value-of select="$name"/>->attrib_<xsl:value-of select="$CName"/>, env, i);
</xsl:if>
<!-- for each non attribute properties there will always be an element-->
/**
@@ -1541,7 +1422,7 @@
<!-- how to build all the ours things -->
<xsl:if test="not(@isarray)">
- start_input_str = "<<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/>>";
+ start_input_str = "<<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/><xsl:if test="@child-nsuri and @child-nsprefix and @ours"> xmlns:<xsl:value-of select="@child-nsprefix"/>=\"<xsl:value-of select="@child-nsuri"/>\"</xsl:if>>";
start_input_str_len = axis2_strlen(start_input_str);
end_input_str = "</<xsl:value-of select="$nsprefix"/>:<xsl:value-of select="$propertyName"/>>";
end_input_str_len = axis2_strlen(end_input_str);
@@ -1737,13 +1618,9 @@
<xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
const axis2_env_t *env)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
-
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
-
- return <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/>;
+ return <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/>;
}
/**
@@ -1755,14 +1632,15 @@
const axis2_env_t *env,
<xsl:value-of select="$propertyType"/><xsl:text> </xsl:text> param_<xsl:value-of select="$CName"/>)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
<xsl:if test="@isarray">
int size = 0;
</xsl:if>
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
+ if(!<xsl:value-of select="$name"/>)
+ {
+ return AXIS2_FAILURE;
+ }
<xsl:if test="@isarray">
size = AXIS2_ARRAY_LIST_SIZE( param_<xsl:value-of select="$CName"/>, env);
@@ -1792,7 +1670,7 @@
return AXIS2_FAILURE;
}
</xsl:if>
- <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/> = param_<xsl:value-of select="$CName"/>;
+ <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/> = param_<xsl:value-of select="$CName"/>;
return AXIS2_SUCCESS;
}
@@ -1805,11 +1683,12 @@
<xsl:value-of select="$axis2_name"/>_t*<xsl:text> </xsl:text><xsl:value-of select="$name"/>,
const axis2_env_t *env)
{
- <xsl:value-of select="$axis2_name"/>_impl_t *<xsl:value-of select="$name"/>_impl = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- <xsl:value-of select="$name"/>_impl = AXIS2_INTF_TO_IMPL(<xsl:value-of select="$name"/>);
- <xsl:value-of select="$name"/>_impl-> attrib_<xsl:value-of select="$CName"/> = NULL;
+ if(!<xsl:value-of select="$name"/>)
+ {
+ return AXIS2_FAILURE;
+ }
+ <xsl:value-of select="$name"/>-> attrib_<xsl:value-of select="$CName"/> = NULL;
return AXIS2_SUCCESS;
}
</xsl:if>
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java?view=diff&rev=510872&r1=510871&r2=510872
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java Fri Feb 23 00:46:30 2007
@@ -24,10 +24,12 @@
import org.apache.axis2.schema.SchemaCompiler;
import org.apache.axis2.schema.util.SchemaPropertyLoader;
import org.apache.axis2.schema.util.PrimitiveTypeFinder;
+import org.apache.axis2.schema.util.PrimitiveTypeWrapper;
import org.apache.axis2.schema.i18n.SchemaCompilerMessages;
import org.apache.axis2.util.XSLTUtils;
import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.util.XSLTTemplateProcessor;
+import org.apache.axis2.wsdl.databinding.CUtils;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
@@ -38,10 +40,7 @@
import javax.xml.transform.stream.StreamSource;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.namespace.QName;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
+import java.util.*;
import java.io.*;
import com.ibm.wsdl.util.xml.DOM2Writer;
@@ -394,11 +393,28 @@
XSLTUtils.addAttribute(model, "extension", metainf.getExtensionClassName(), rootElt);
}
+ if (metainf.isRestriction()) {
+ XSLTUtils.addAttribute(model, "restriction", metainf
+ .getRestrictionClassName(), rootElt);
+ }
+
if (metainf.isChoice()) {
XSLTUtils.addAttribute(model, "choice", "yes", rootElt);
}
+ if (metainf.isSimple()) {
+ XSLTUtils.addAttribute(model, "simple", "yes", rootElt);
+ }
+
+ if (metainf.isUnion()) {
+ XSLTUtils.addAttribute(model, "union", "yes", rootElt);
+ }
+
+ if (metainf.isList()) {
+ XSLTUtils.addAttribute(model, "list", "yes", rootElt);
+ }
+
if (metainf.isOrdered()) {
XSLTUtils.addAttribute(model, "ordered", "yes", rootElt);
}
@@ -410,10 +426,64 @@
//populate all the information
populateInfo(metainf, model, rootElt, propertyNames, typeMap, false);
+ if (metainf.isSimple() && metainf.isUnion()) {
+ populateMemberInfo(metainf, model, rootElt, typeMap);
+ }
+
+ if (metainf.isSimple() && metainf.isList()) {
+ populateListInfo(metainf, model, rootElt, typeMap);
+ }
return rootElt;
}
+ protected void populateListInfo(BeanWriterMetaInfoHolder metainf,
+ Document model,
+ Element rootElement,
+ Map typeMap) {
+
+ String cName = makeUniqueCStructName(new ArrayList(), metainf.getItemTypeQName().getLocalPart());
+ Element itemType = XSLTUtils.addChildElement(model, "itemtype", rootElement);
+ XSLTUtils.addAttribute(model, "type", metainf.getItemTypeClassName(), itemType);
+ XSLTUtils.addAttribute(model, "nsuri", metainf.getItemTypeQName().getNamespaceURI(), itemType);
+ XSLTUtils.addAttribute(model, "originalName", metainf.getItemTypeQName().getLocalPart(), itemType);
+ XSLTUtils.addAttribute(model, "cname", cName, itemType);
+
+ if (typeMap.containsKey(metainf.getItemTypeQName())) {
+ XSLTUtils.addAttribute(model, "ours", "true", itemType);
+ }
+ if (PrimitiveTypeFinder.isPrimitive(metainf.getItemTypeClassName())) {
+ XSLTUtils.addAttribute(model, "primitive", "yes", itemType);
+ }
+
+ }
+
+ protected void populateMemberInfo(BeanWriterMetaInfoHolder metainf,
+ Document model,
+ Element rootElement,
+ Map typeMap) {
+ Map memberTypes = metainf.getMemberTypes();
+ QName memberQName;
+ for (Iterator iter = memberTypes.keySet().iterator(); iter.hasNext();) {
+ memberQName = (QName) iter.next();
+ String memberClass = (String) memberTypes.get(memberQName);
+ if (PrimitiveTypeFinder.isPrimitive(memberClass)) {
+ memberClass = PrimitiveTypeWrapper.getWrapper(memberClass);
+ }
+
+ // add member type element
+ Element memberType = XSLTUtils.addChildElement(model, "memberType", rootElement);
+ XSLTUtils.addAttribute(model, "type", memberClass, memberType);
+ XSLTUtils.addAttribute(model, "nsuri", memberQName.getNamespaceURI(), memberType);
+ XSLTUtils.addAttribute(model, "originalName", memberQName.getLocalPart(), memberType);
+ XSLTUtils.addAttribute(model, "caps-originalName", memberQName.getLocalPart().toUpperCase(), memberType);
+ if (typeMap.containsKey(memberQName)) {
+ XSLTUtils.addAttribute(model, "ours", "true", memberType);
+ }
+
+ }
+ }
+
/**
* @param metainf
* @param model
@@ -448,17 +518,31 @@
Map typeMap,
boolean isInherited) throws SchemaCompilationException {
// go in the loop and add the part elements
- QName[] qNames;
+ QName[] qName;
+ ArrayList missingQNames = new ArrayList();
+ ArrayList qNames = new ArrayList();
+ BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent();
+
if (metainf.isOrdered()) {
- qNames = metainf.getOrderedQNameArray();
+ qName = metainf.getOrderedQNameArray();
} else {
- qNames = metainf.getQNameArray();
+ qName = metainf.getQNameArray();
+ }
+
+ for (int i = 0; i < qName.length; i++) {
+ qNames.add(qName[i]);
+ }
+ //adding missing QNames to the end, including elements & attributes.
+ // for the simple types we have already add the parent elements
+ // it is almost consider as an extension
+ if (metainf.isRestriction() && !metainf.isSimple()) {
+ addMissingQNames(metainf, qNames, missingQNames);
}
QName name;
- for (int i = 0; i < qNames.length; i++) {
+ for (int i = 0; i < qName.length; i++) {
Element property = XSLTUtils.addChildElement(model, "property", rootElt);
- name = qNames[i];
+ name = qName[i];
String xmlName = name.getLocalPart();
XSLTUtils.addAttribute(model, "name", xmlName, property);
@@ -525,6 +609,13 @@
XSLTUtils.addAttribute(model, "inherited", "yes", property);
}
+ QName schemaQName = metainf.getSchemaQNameForQName(name);
+ if(!schemaQName.getNamespaceURI().equals(name.getNamespaceURI())){
+ XSLTUtils.addAttribute(model, "child-nsuri", schemaQName.getNamespaceURI(), property);
+ XSLTUtils.addAttribute(model, "child-nsprefix", getPrefixForURI(schemaQName.getNamespaceURI(), null), property);
+
+ }
+
if (metainf.getAnyStatusForQName(name)) {
XSLTUtils.addAttribute(model, "any", "yes", property);
}
@@ -563,7 +654,231 @@
XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "", property);
}
+
+ if ((parentMetaInf != null) && metainf.isRestriction() && missingQNames.contains(name)) {
+ // this element details should be there with the parent meta Inf
+ addAttributesToProperty(
+ parentMetaInf,
+ name,
+ model,
+ property,
+ typeMap,
+ CClassNameForElement);
+
+ } else {
+ addAttributesToProperty(
+ metainf,
+ name,
+ model,
+ property,
+ typeMap,
+ CClassNameForElement);
+ }
+ }
+ }
+
+ private void addAttributesToProperty(BeanWriterMetaInfoHolder metainf,
+ QName name,
+ Document model,
+ Element property,
+ Map typeMap,
+ String javaClassNameForElement) {
+ // add an attribute that says the type is default
+ if (metainf.getDefaultStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "default", "yes", property);
+ }
+
+ if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
+ XSLTUtils.addAttribute(model, "ours", "yes", property);
+ }
+
+ if (metainf.getAttributeStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "attribute", "yes", property);
+ }
+
+ if (metainf.isNillable(name)) {
+ XSLTUtils.addAttribute(model, "nillable", "yes", property);
+ }
+
+ if (metainf.getOptionalAttributeStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "optional", "yes", property);
+ }
+
+ String shortTypeName;
+ if (metainf.getSchemaQNameForQName(name) != null) {
+ // see whether the QName is a basetype
+ if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
+ shortTypeName = metainf.getSchemaQNameForQName(name).getLocalPart();
+ } else {
+ shortTypeName = getShortTypeName(javaClassNameForElement);
+ }
+ } else {
+ shortTypeName = getShortTypeName(javaClassNameForElement);
+ }
+ XSLTUtils.addAttribute(model, "shorttypename", shortTypeName, property);
+
+
+ if (metainf.getAnyStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "any", "yes", property);
+ }
+
+ if (metainf.getBinaryStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "binary", "yes", property);
+ }
+
+ if (metainf.isSimple() || metainf.getSimpleStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "simple", "yes", property);
+ }
+
+ // put the min occurs count irrespective of whether it's an array or
+ // not
+ long minOccurs = metainf.getMinOccurs(name);
+ XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property);
+
+
+ if (metainf.getArrayStatusForQName(name)) {
+
+ XSLTUtils.addAttribute(model, "array", "yes", property);
+
+ int endIndex = javaClassNameForElement.indexOf("[");
+ if (endIndex >= 0) {
+ XSLTUtils.addAttribute(model, "arrayBaseType",
+ javaClassNameForElement.substring(0, endIndex), property);
+ } else {
+ XSLTUtils.addAttribute(model, "arrayBaseType",
+ javaClassNameForElement, property);
+ }
+
+ long maxOccurs = metainf.getMaxOccurs(name);
+ if (maxOccurs == Long.MAX_VALUE) {
+ XSLTUtils.addAttribute(model, "unbound", "yes", property);
+ } else {
+ XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "", property);
+ }
+ }
+ if (metainf.isRestrictionBaseType(name)) {
+ XSLTUtils.addAttribute(model, "restrictionBaseType", "yes", property);
+ }
+
+ if (metainf.isExtensionBaseType(name)) {
+ XSLTUtils.addAttribute(model, "extensionBaseType", "yes", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getLengthFacet() != -1) {
+ XSLTUtils.addAttribute(model, "lenFacet", metainf.getLengthFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMaxLengthFacet() != -1) {
+ XSLTUtils.addAttribute(model, "maxLenFacet", metainf.getMaxLengthFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMinLengthFacet() != -1) {
+ XSLTUtils.addAttribute(model, "minLenFacet", metainf.getMinLengthFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMaxExclusiveFacet() != null) {
+ XSLTUtils.addAttribute(model, "maxExFacet", metainf.getMaxExclusiveFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMinExclusiveFacet() != null) {
+ XSLTUtils.addAttribute(model, "minExFacet", metainf.getMinExclusiveFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMaxInclusiveFacet() != null) {
+ XSLTUtils.addAttribute(model, "maxInFacet", metainf.getMaxInclusiveFacet() + "", property);
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getMinInclusiveFacet() != null) {
+ XSLTUtils.addAttribute(model, "minInFacet", metainf.getMinInclusiveFacet() + "", property);
+ }
+
+ if (!metainf.getEnumFacet().isEmpty()) {
+ boolean validJava = true; // Assume all enum values are valid ids
+
+ Iterator iterator = metainf.getEnumFacet().iterator();
+ // Walk the values looking for invalid ids
+ while (iterator.hasNext()) {
+ String value = (String) iterator.next();
+ if (!JavaUtils.isJavaId(value)) {
+ validJava = false;
+ }
+ }
+
+ int id = 0;
+ iterator = metainf.getEnumFacet().iterator();
+ while (iterator.hasNext()) {
+ Element enumFacet = XSLTUtils.addChildElement(model, "enumFacet", property);
+ String attribValue = (String) iterator.next();
+ XSLTUtils.addAttribute(model, "value", attribValue, enumFacet);
+ if (validJava) {
+ XSLTUtils.addAttribute(model, "id", attribValue, enumFacet);
+ } else {
+ id++;
+ XSLTUtils.addAttribute(model, "id", "value" + id, enumFacet);
+ }
+ }
+ }
+
+ if (metainf.isRestrictionBaseType(name) && metainf.getPatternFacet() != null) {
+ XSLTUtils.addAttribute(model, "patternFacet", metainf.getPatternFacet(), property);
+ }
+ }
+
+
+
+ private void addMissingQNames(BeanWriterMetaInfoHolder metainf, ArrayList qName, ArrayList missingQNames) {
+
+ QName[] qNames = null;
+ QName[] pQNames = null;
+
+ BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent();
+
+ if (metainf.isOrdered()) {
+ qNames = metainf.getOrderedQNameArray();
+ } else {
+ qNames = metainf.getQNameArray();
+ }
+
+ if (parentMetaInf != null) {
+ if (parentMetaInf.isOrdered()) {
+ pQNames = parentMetaInf.getOrderedQNameArray();
+ } else {
+ pQNames = parentMetaInf.getQNameArray();
+ }
+ }
+
+
+ for (int i = 0; pQNames != null && i < pQNames.length; i++) {
+ if (qNameNotFound(pQNames[i], metainf)) {
+ missingQNames.add(pQNames[i]);
+ }
+ }
+ //adding missing QNames to the end of list.
+ if (!missingQNames.isEmpty()) {
+ for (int i = 0; i < missingQNames.size(); i++) {
+ qName.add(missingQNames.get(i));
+ }
+ }
+
+ }
+
+ private boolean qNameNotFound(QName qname, BeanWriterMetaInfoHolder metainf) {
+
+ boolean found = false;
+ QName[] qNames;
+
+ if (metainf.isOrdered()) {
+ qNames = metainf.getOrderedQNameArray();
+ } else {
+ qNames = metainf.getQNameArray();
+ }
+
+ for (int j = 0; j < qNames.length; j++) {
+ if (qname.getLocalPart().equals(qNames[j].getLocalPart())) {
+ found = true;
+ }
}
+ return !found;
}
/**
@@ -588,20 +903,22 @@
* @return Returns String.
*/
private String makeUniqueCStructName(List listOfNames, String xmlName) {
- String javaName;
- if (JavaUtils.isJavaKeyword(xmlName)) {
- javaName = JavaUtils.makeNonJavaKeyword(xmlName);
+ String cName;
+ if (CUtils.isCKeyword(xmlName)) {
+ cName = CUtils.makeNonCKeyword(xmlName);
} else {
//javaName = JavaUtils.capitalizeFirstChar(JavaUtils.xmlNameToJava(xmlName));
- javaName = xmlName;
+ cName = xmlName;
}
- while (listOfNames.contains(javaName.toLowerCase())) {
- javaName = javaName + CStructWriter.count++;
+ while (listOfNames.contains(cName.toLowerCase())) {
+ cName = cName + CStructWriter.count++;
}
- listOfNames.add(javaName.toLowerCase());
- return javaName;
+ String intName = cName.replace('.','_');
+ String outName = intName.replace('-','_');
+ listOfNames.add(outName.toLowerCase());
+ return outName;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org