axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From din...@apache.org
Subject svn commit: r427511 - /webservices/axis2/trunk/c/guththila/src/
Date Tue, 01 Aug 2006 10:03:19 GMT
Author: dinesh
Date: Tue Aug  1 03:03:17 2006
New Revision: 427511

URL: http://svn.apache.org/viewvc?rev=427511&view=rev
Log:
guththila writer implementation

Added:
    webservices/axis2/trunk/c/guththila/src/guththila_writer.c
    webservices/axis2/trunk/c/guththila/src/guththila_writer.h
    webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.h
Modified:
    webservices/axis2/trunk/c/guththila/src/guththila_attribute.h
    webservices/axis2/trunk/c/guththila/src/guththila_error.h
    webservices/axis2/trunk/c/guththila/src/guththila_reader.h
    webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.h

Modified: webservices/axis2/trunk/c/guththila/src/guththila_attribute.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_attribute.h?rev=427511&r1=427510&r2=427511&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_attribute.h (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_attribute.h Tue Aug  1 03:03:17 2006
@@ -27,6 +27,7 @@
     guththila_token_t *prefix;
     guththila_token_t *name;
     guththila_token_t *value;
+  guththila_token_t *namespace_uri;
 } guththila_attribute_t;
 
 #endif /* GUTHTHILA_ATTRIBUTE_H */

Modified: webservices/axis2/trunk/c/guththila/src/guththila_error.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_error.h?rev=427511&r1=427510&r2=427511&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_error.h (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_error.h Tue Aug  1 03:03:17 2006
@@ -24,92 +24,76 @@
 {
 #endif
 
-    typedef enum guththila_status_codes
+  typedef enum guththila_status_codes
     {
-        GUTHTHILA_FAILURE = 0,
-        GUTHTHILA_SUCCESS
+      GUTHTHILA_FAILURE = 0,
+      GUTHTHILA_SUCCESS
     } guththila_status_codes_t;
 
-    typedef enum guththila_error_codes
+  typedef enum guththila_error_codes
     {
-        GUTHTHILA_ERROR_NONE = 0,
-        GUTHTHILA_ERROR_NO_MEMORY,
-        GUTHTHILA_ERROR_INVALID_NULL_PARAMETER,
-        GUTHTHILA_ERROR_INVALID_ITERATOR_STATE,
-        GUTHTHILA_ERROR_INVALID_NODE_TYPE,
-        GUTHTHILA_STREAM_WRITER_ERROR_NOT_IN_GUTHTHILA_START_ELEMENT,
-        GUTHTHILA_STREAM_WRITER_ERROR_WRITING_TO_STREAM,
-        GUTHTHILA_STREAM_WRITER_ERROR_STREAM_STRUCT_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_LOCAL_NAME_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_PREFIX_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NOT_DECLARED,
-        GUTHTHILA_STREAM_WRITER_ERROR_guththila_element_t_guththila_stack_t_EMPTY,
-        GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_STATE,
-        GUTHTHILA_STREAM_WRITER_ERROR_GUTHTHILA_COMMENT_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_GUTHTHILA_COMMENT,
-        GUTHTHILA_STREAM_WRITER_ERROR_PROCESSING_INSTRUCTION_TARGET_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_CDATA_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_CDATA,
-        GUTHTHILA_STREAM_WRITER_ERROR_DTD_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_ENTITY_REF_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_XML_VERSION,
-        GUTHTHILA_STREAM_WRITER_ERROR_TEXT_NULL,
-        GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_PREFIX,
-        GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY,
-        GUTHTHILA_STREAM_WRITER_ERROR_FILE_NOT_FOUND,
-        GUTHTHILA_STREAM_READER_ERROR_OUT_OF_MEMORY,
-   GUTHTHILA_ERROR_INVALID_ENCODING_DECLARATION,
-   GUTHTHILA_ERROR_UNEXPECTED_UTF16_EOF,
-   GUTHTHILA_ERROR_UNEXPECTED_EOF,
-   GUTHTHILA_ERROR_PROCESS_EQUAL,
-   GUTHTHILA_ERROR_INCORRECT_VERSION_INFO,
-   GUTHTHILA_ERROR_INCORRECT_XML_DECLARATION,
-   GUTHTHILA_ERROR_VERSION_INFO_NOT_FOUND,
-   GUTHTHILA_ERROR_ENCODING_DECLARATION_ERROR,
-   GUTHTHILA_ERROR_STANDALONE_ERROR_IN_YES,
-   GUTHTHILA_ERROR_STANDALONE_ERROR_IN_NO,
-   GUTHTHILA_ERROR_STANDALONE_ERROR_YES_OR_NO_NOT_AVAILABLE,
-   GUTHTHILA_ERROR_MISSING_GREATER_SIGN_IN_XML_DECLARATION,
-   GUTHTHILA_ERROR_INVALID_NAME_STARTING_CHARACTER,
-   GUTHTHILA_ERROR_QUOTES_NOT_FOUND_BEFORE_ATTRIBUTE_VALUE,
-   GUTHTHILA_ERROR_EMPTY_ELEMENT_NOT_CLOSED,
-   GUTHTHILA_ERROR_END_TAG_NOT_CLOSED,
-   GUTHTHILA_ERROR_MORE_HYPENS_OCCURED_IN_COMMENT,
-   GUTHTHILA_ERROR_TOKENIZE_ERROR,
-   GUTHTHILA_ERROR_INVALID_TOKEN_TYPE,
-   GUTHTHILA_ERROR_NULL_ATTRIBUTE_NAME,
-   GUTHTHILA_ERROR_NULL_ATTRIBUTE_VALUE,
-   GUTHTHILA_ERROR_NULL_ATTRIBUTE_PREFIX,
-   GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE
+      GUTHTHILA_ERROR_NONE = 0,
+      GUTHTHILA_ERROR_NO_MEMORY,
+      GUTHTHILA_ERROR_INVALID_NULL_PARAMETER,
+      GUTHTHILA_ERROR_INVALID_ITERATOR_STATE,
+      GUTHTHILA_ERROR_INVALID_NODE_TYPE,
+      GUTHTHILA_STREAM_WRITER_ERROR_NOT_IN_GUTHTHILA_START_ELEMENT,
+      GUTHTHILA_STREAM_WRITER_ERROR_WRITING_TO_STREAM,
+      GUTHTHILA_STREAM_WRITER_ERROR_STREAM_STRUCT_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_LOCAL_NAME_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_PREFIX_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NOT_DECLARED,
+      GUTHTHILA_STREAM_WRITER_ERROR_guththila_element_t_guththila_stack_t_EMPTY,
+      GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_STATE,
+      GUTHTHILA_STREAM_WRITER_ERROR_GUTHTHILA_COMMENT_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_GUTHTHILA_COMMENT,
+      GUTHTHILA_STREAM_WRITER_ERROR_PROCESSING_INSTRUCTION_TARGET_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_CDATA_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_CDATA,
+      GUTHTHILA_STREAM_WRITER_ERROR_DTD_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_ENTITY_REF_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_XML_VERSION,
+      GUTHTHILA_STREAM_WRITER_ERROR_TEXT_NULL,
+      GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_PREFIX,
+      GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY,
+      GUTHTHILA_STREAM_WRITER_ERROR_FILE_NOT_FOUND,
+      GUTHTHILA_STREAM_READER_ERROR_OUT_OF_MEMORY,
+      GUTHTHILA_ERROR_INVALID_ENCODING_DECLARATION,
+      GUTHTHILA_ERROR_UNEXPECTED_UTF16_EOF,
+      GUTHTHILA_ERROR_UNEXPECTED_EOF,
+      GUTHTHILA_ERROR_PROCESS_EQUAL,
+      GUTHTHILA_ERROR_INCORRECT_VERSION_INFO,
+      GUTHTHILA_ERROR_INCORRECT_XML_DECLARATION,
+      GUTHTHILA_ERROR_VERSION_INFO_NOT_FOUND,
+      GUTHTHILA_ERROR_ENCODING_DECLARATION_ERROR,
+      GUTHTHILA_ERROR_STANDALONE_ERROR_IN_YES,
+      GUTHTHILA_ERROR_STANDALONE_ERROR_IN_NO,
+      GUTHTHILA_ERROR_STANDALONE_ERROR_YES_OR_NO_NOT_AVAILABLE,
+      GUTHTHILA_ERROR_MISSING_GREATER_SIGN_IN_XML_DECLARATION,
+      GUTHTHILA_ERROR_INVALID_NAME_STARTING_CHARACTER,
+      GUTHTHILA_ERROR_QUOTES_NOT_FOUND_BEFORE_ATTRIBUTE_VALUE,
+      GUTHTHILA_ERROR_EMPTY_ELEMENT_NOT_CLOSED,
+      GUTHTHILA_ERROR_END_TAG_NOT_CLOSED,
+      GUTHTHILA_ERROR_MORE_HYPENS_OCCURED_IN_COMMENT,
+      GUTHTHILA_ERROR_TOKENIZE_ERROR,
+      GUTHTHILA_ERROR_INVALID_TOKEN_TYPE,
+      GUTHTHILA_ERROR_NULL_ATTRIBUTE_NAME,
+      GUTHTHILA_ERROR_NULL_ATTRIBUTE_VALUE,
+      GUTHTHILA_ERROR_NULL_ATTRIBUTE_PREFIX,
+      GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE,
+      GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS,
+      GUTHTHILA_WRITER_ERROR_NON_EXSISTING_PREFIX,
+      GUTHTHILA_WRITER_ERROR_EMPTY_WRITER,
+      GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS,
+      GUTHTHILA_WRITER_ERROR_INVALID_BUFFER,
+      GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_NAME,
+      GUTHTHILA_WRITER_ERROR_XML_STRING_IN_NAME,
+      GUTHTHILA_WRITER_ERROR_EXCESS_HYPENS_IN_COMMENT,
+      GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE,
+      GUTHTHILA_WRITER_ERROR_NON_EXSISTING_URI
     } guththila_error_codes_t;
 
-
-
-/*     typedef struct guththila_error guththila_error_t; */
-/*     struct guththila_error_ops; */
-
-
-/*  GUTHTHILA_DECLARE_DATA typedef struct guththila_error_ops */
-/* { */
-/*     guththila_char_t *(GUTHTHILA_CALL * get_message) (); */
-/*     int (GUTHTHILA_CALL *free)(guththila_error_t *error); */
-/* } guththila_error_ops_t; */
-
-/* struct guththila_error */
-/* { */
-/*     struct guththila_error_ops *ops; */
-/*     int errorno; */
-/* } ; */
-
-
-/* GUTHTHILA_DECLARE (guththila_error_t *) */
-/* guththila_error_create (guththila_allocator_t * allocator); */
-
-
-/* #define GUTHTHILA_ERROR_GET_MESSAGE(error) ((error)->ops->get_message()) */
-
-/* #define GUTHTHILA_ERROR_FREE(error) ((error)->ops->free(error)) */
 
 
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/guththila/src/guththila_reader.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_reader.h?rev=427511&r1=427510&r2=427511&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_reader.h (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_reader.h Tue Aug  1 03:03:17 2006
@@ -30,10 +30,10 @@
 #include "guththila_error.h"
 
 typedef enum guththila_reader_types
-{
+  {
     GUTHTHILA_FILE_READER = 1,
     GUTHTHILA_IN_MEMORY_READER
-} guththila_reader_types_t;
+  } guththila_reader_types_t;
 
 typedef struct guththila_reader_s
 {

Added: webservices/axis2/trunk/c/guththila/src/guththila_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer.c?rev=427511&view=auto
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.c (added)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.c Tue Aug  1 03:03:17 2006
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ *
+ *	
+ * @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)	
+ */
+
+#include "guththila_writer.h"
+
+
+AXIS2_EXTERN guththila_writer_t *
+guththila_writer_create_for_file (axis2_env_t *env, char *fp)
+{
+
+  if (!fp)
+    return NULL;
+
+  guththila_writer_impl_t *wt = NULL;
+
+  wt = (guththila_writer_impl_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_writer_impl_t));
+ 
+  wt->outputstream = fopen (fp, "w");
+ 
+  if (!wt->outputstream)
+    return NULL;
+
+ wt->writer.guththila_writer_type = GUTHTHILA_WRITER_CREATE_FOR_FILE;
+ return &(wt->writer);
+}
+
+AXIS2_EXTERN void
+guththila_writer_free (axis2_env_t *env, guththila_writer_t *wt)
+{
+  if (wt)
+    {
+      if (wt->guththila_writer_type == GUTHTHILA_WRITER_CREATE_FOR_FILE)
+	{
+	  if (((guththila_writer_impl_t *)wt)->outputstream)
+	    fclose (((guththila_writer_impl_t *)wt)->outputstream);
+	  ((guththila_writer_impl_t *)wt)->outputstream = NULL;
+	}
+      AXIS2_FREE (env->allocator, (guththila_writer_t *)wt);
+      wt = NULL;
+    }
+}
+
+AXIS2_EXTERN int 
+guththila_writer_write (axis2_env_t *env, char *buffer, int offset, int length, guththila_writer_t *wt)
+{
+ 
+  if (wt->guththila_writer_type == GUTHTHILA_WRITER_CREATE_FOR_FILE)
+    {
+      int c;
+      c = fwrite (buffer+offset, 1, length, ((guththila_writer_impl_t *)wt)->outputstream);
+      return c;
+    }
+  else 
+    return 0;
+}

Added: webservices/axis2/trunk/c/guththila/src/guththila_writer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer.h?rev=427511&view=auto
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.h (added)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.h Tue Aug  1 03:03:17 2006
@@ -0,0 +1,50 @@
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ *
+ *	
+ * @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)	
+ */
+
+#ifndef GUTHTHILA_WRITER_H
+#define GUTHTHILA_WRITER_H
+#include <stdio.h>
+#include <stdlib.h>
+#include "guththila_buffer.h"
+#include <axis2_env.h>
+#include "guththila_defines.h"
+#include "guththila_error.h"
+
+typedef enum guththila_writer_types
+  {
+    GUTHTHILA_WRITER_CREATE_FOR_FILE = 1,
+    GUTHTHILA_WRITER_CREATE_FOR_MEMORY
+  }guththila_writer_types_t;
+
+typedef struct guththila_writer_s
+{
+  int guththila_writer_type;  
+}guththila_writer_t;
+
+typedef struct guththila_writer_impl_t
+{
+  guththila_writer_t writer;
+  FILE *outputstream;
+}guththila_writer_impl_t; 
+
+AXIS2_EXTERN guththila_writer_t *guththila_writer_create_for_file (axis2_env_t *env, char *fp);
+AXIS2_EXTERN int guththila_writer_write (axis2_env_t *env, char *buffer, int offset, int length, guththila_writer_t *wt);
+AXIS2_EXTERN void guththila_writer_free (axis2_env_t *env, guththila_writer_t *wt);
+
+#endif	/* GUTHTHILA_WRITE_H */

Added: webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c?rev=427511&view=auto
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c (added)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c Tue Aug  1 03:03:17 2006
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <guththila_buffer.h>
+#include <guththila_reader.h>
+#include <guththila_xml_pull_parser.h>
+int main ()
+{
+  axis2_allocator_t *allocator = axis2_allocator_init (NULL);
+  axis2_env_t *env = axis2_env_create (allocator);
+  guththila_reader_t *reader = guththila_reader_create_for_file (env, "x.xml");
+  guththila_xml_pull_parser_t *parser = guththila_xml_pull_parser_create (env, reader);
+  guththila_xml_pull_parser_createXmlStreamWriter (env, parser, "w.xml");
+  guththila_xml_pull_parser_writeStartDocument (env, parser);
+  guththila_xml_pull_parser_writeStartElement (env, parser, "person");
+  guththila_xml_pull_parser_writeStartElement (env, parser, "name");
+  guththila_xml_pull_parser_writeCharacters (env, parser, "guththila");
+  guththila_xml_pull_parser_writeStartElement (env, parser, "escape");
+  guththila_xml_pull_parser_writeEscapeCharacter (env, parser, "&");
+  guththila_xml_pull_parser_writeEscapeCharacter (env, parser, ">");
+  guththila_xml_pull_parser_writeEndElement (env, parser);
+  guththila_xml_pull_parser_writeStartElement (env, parser, "escape");
+  guththila_xml_pull_parser_writeDefaultNamespace (env, parser, "http://www.cse.mrt.ac.lk");
+  guththila_xml_pull_parser_writeNamespace (env, parser, "a", "http://ws.apache.org");
+  guththila_xml_pull_parser_writeAttribute_with_prefix(env, parser, "a", "web", "false");
+  guththila_xml_pull_parser_writeStartElement (env, parser, "one");
+  guththila_xml_pull_parser_writeStartElement (env, parser, "two");
+  guththila_xml_pull_parser_writeCharacters (env, parser, "it works !");
+  guththila_xml_pull_parser_writeEndElement (env,parser);
+  guththila_xml_pull_parser_writeEndDocument (env, parser);
+  guththila_reader_free (env, reader);
+  guththila_xml_pull_parser_free (env, parser);
+  axis2_allocator_free (allocator);
+  axis2_env_free (env);
+  return 0;
+}

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c?rev=427511&r1=427510&r2=427511&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c Tue Aug  1 03:03:17 2006
@@ -33,7 +33,6 @@
   guththila_xml_pull_parser_t *parser =
     (guththila_xml_pull_parser_t *) AXIS2_MALLOC (
 						  environment->allocator, sizeof (guththila_xml_pull_parser_t));
-                
   parser->buffer = guththila_buffer_create (environment, 1024);
   parser->stack = axis2_stack_create (environment);
   parser->attrib = axis2_stack_create (environment);
@@ -48,6 +47,7 @@
   parser->last = -1;
   parser->status = S_1;
   parser->unicode_state = None;
+  parser->xsw = NULL;
 
   return parser;
 }
@@ -67,6 +67,7 @@
     AXIS2_STACK_FREE (parser->namesp, environment);
   if (parser->dep)
     AXIS2_STACK_FREE (parser->dep, environment);
+  
   AXIS2_FREE (environment->allocator, (void *) parser);
 }
 

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.h?rev=427511&r1=427510&r2=427511&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.h (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.h Tue Aug  1 03:03:17 2006
@@ -26,6 +26,7 @@
 #include <ctype.h>
 #include "guththila_buffer.h"
 #include "guththila_reader.h"
+#include "guththila_xml_writer.h"
 #include "guththila_token.h"
 #include "guththila_namespace.h"
 #include "guththila_depth.h"
@@ -77,6 +78,7 @@
 {
   guththila_buffer_t *buffer;
   guththila_reader_t *reader;
+  guththila_xml_writer_t *xsw;
   guththila_token_t *prefix;
   guththila_token_t *name;
   guththila_token_t *value;
@@ -94,17 +96,17 @@
 
 
 AXIS2_EXTERN int
-     guththila_xml_pull_parser_read (axis2_env_t * environment,
-                 guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_read (axis2_env_t * environment,
+				guththila_xml_pull_parser_t * p);
                                 
-     AXIS2_EXTERN int
-     guththila_xml_pull_parser_next_char (axis2_env_t *environment,
-                 guththila_xml_pull_parser_t * p,
-                 int eof);
+AXIS2_EXTERN int
+guththila_xml_pull_parser_next_char (axis2_env_t *environment,
+				     guththila_xml_pull_parser_t * p,
+				     int eof);
 
 AXIS2_EXTERN int
 guththila_xml_pull_parser_tokenize (axis2_env_t *environment,
-                guththila_xml_pull_parser_t * p);
+				    guththila_xml_pull_parser_t * p);
                                         
                                         
 AXIS2_EXTERN int
@@ -112,12 +114,12 @@
 
 AXIS2_EXTERN int
 guththila_xml_pull_parser_skip_spaces (axis2_env_t *environment,
-                   guththila_xml_pull_parser_t *p,
-                   int c);
+				       guththila_xml_pull_parser_t *p,
+				       int c);
                                            
 AXIS2_EXTERN int
 guththila_xml_pull_parser_process_xml_decl(axis2_env_t *environment,
-                  guththila_xml_pull_parser_t * p);
+					   guththila_xml_pull_parser_t * p);
                                             
 AXIS2_EXTERN int
 guththila_xml_pull_parser_process_version_info(axis2_env_t * environment,
@@ -184,7 +186,7 @@
                                       
 AXIS2_EXTERN int
 guththila_xml_pull_parser_process_end_tag (axis2_env_t *environment,
-                                             guththila_xml_pull_parser_t *p);
+					   guththila_xml_pull_parser_t *p);
                                              
 AXIS2_EXTERN void
 guththila_xml_pull_parser_reset (axis2_env_t *environment,
@@ -246,133 +248,424 @@
                                          
 
 AXIS2_EXTERN int
-     guththila_xml_pull_parser_next (axis2_env_t * environment,
-                 guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_next (axis2_env_t * environment,
+				guththila_xml_pull_parser_t * p);
                                 
 AXIS2_EXTERN guththila_xml_pull_parser_t *
-     guththila_xml_pull_parser_create (axis2_env_t * environment,
-                   guththila_reader_t * r);
+guththila_xml_pull_parser_create (axis2_env_t * environment,
+				  guththila_reader_t * r);
                                   
 AXIS2_EXTERN void
-     guththila_xml_pull_parser_free (axis2_env_t * environment,
-                 guththila_xml_pull_parser_t * parser);
+guththila_xml_pull_parser_free (axis2_env_t * environment,
+				guththila_xml_pull_parser_t * parser);
                                
 AXIS2_EXTERN int
-  guththila_xml_pull_parser_get_attribute_count 
-     (axis2_env_t * environment,
-      guththila_xml_pull_parser_t *p);
+guththila_xml_pull_parser_get_attribute_count 
+(axis2_env_t * environment,
+ guththila_xml_pull_parser_t *p);
                                  
                                  
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_name 
+guththila_xml_pull_parser_get_attribute_name 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t * p,
  guththila_attribute_t * att);
                                  
                                  
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_value 
+guththila_xml_pull_parser_get_attribute_value 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t *p,
  guththila_attribute_t * att);
                                  
                                  
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_prefix 
+guththila_xml_pull_parser_get_attribute_prefix 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t *p,
  guththila_attribute_t * att);
                                  
                                  
 AXIS2_EXTERN guththila_attribute_t *
-     guththila_xml_pull_parser_get_attribute (axis2_env_t *environment,
-                     guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_get_attribute (axis2_env_t *environment,
+					 guththila_xml_pull_parser_t * p);
                                          
                                          
-     AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_name_by_number
-     (axis2_env_t * environment,
-      guththila_xml_pull_parser_t * p,
-      int i);
+AXIS2_EXTERN guththila_char_t *
+guththila_xml_pull_parser_get_attribute_name_by_number
+(axis2_env_t * environment,
+ guththila_xml_pull_parser_t * p,
+ int i);
                                          
                                          
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_value_by_number
+guththila_xml_pull_parser_get_attribute_value_by_number
 (axis2_env_t * environment,
  guththila_xml_pull_parser_t * p,
  int i);
                                          
                                          
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_prefix_by_number
+guththila_xml_pull_parser_get_attribute_prefix_by_number
 (axis2_env_t * environment,
  guththila_xml_pull_parser_t * p,
  int i);
                                          
                                          
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_name (axis2_env_t * environment,
-                guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_get_name (axis2_env_t * environment,
+				    guththila_xml_pull_parser_t * p);
                                     
                                     
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_prefix (axis2_env_t * environment,
-                  guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_get_prefix (axis2_env_t * environment,
+				      guththila_xml_pull_parser_t * p);
                                       
                                       
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_value (axis2_env_t * environment,
-                 guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_get_value (axis2_env_t * environment,
+				     guththila_xml_pull_parser_t * p);
                                      
                                      
 AXIS2_EXTERN guththila_namespace_t *
-     guththila_xml_pull_parser_get_namespace (axis2_env_t *environment,
-                     guththila_xml_pull_parser_t * p);
+guththila_xml_pull_parser_get_namespace (axis2_env_t *environment,
+					 guththila_xml_pull_parser_t * p);
                                          
                                          
 AXIS2_EXTERN int
-     guththila_xml_pull_parser_get_namespace_count 
-     (axis2_env_t *environment,
-      guththila_xml_pull_parser_t *p);
+guththila_xml_pull_parser_get_namespace_count 
+(axis2_env_t *environment,
+ guththila_xml_pull_parser_t *p);
                                          
                                          
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_namespace_uri 
+guththila_xml_pull_parser_get_namespace_uri 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t * p,
  guththila_namespace_t * ns);
                                              
                                              
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_namespace_prefix 
+guththila_xml_pull_parser_get_namespace_prefix 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t *p,
  guththila_namespace_t * ns);
                                      
-                                     
+
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_namespace_prefix_by_number
+guththila_xml_pull_parser_get_namespace_prefix_by_number
 (axis2_env_t * environment,
  guththila_xml_pull_parser_t * p,
  int i);
                                      
                                      
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_namespace_uri_by_number 
+guththila_xml_pull_parser_get_namespace_uri_by_number 
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t * p,
  int i);
                                        
                                        
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_attribute_namespace_by_number
+guththila_xml_pull_parser_get_attribute_namespace_by_number
 (axis2_env_t * environment,
  guththila_xml_pull_parser_t * p,
  int i);
 
 AXIS2_EXTERN guththila_char_t *
-     guththila_xml_pull_parser_get_encoding 
+guththila_xml_pull_parser_get_encoding 
+(axis2_env_t *environment,
+ guththila_xml_pull_parser_t *p);
+
+/* --------------writer api --------------------------*/
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_createXmlStreamWriter 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *fp);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeToBuffer 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p,
+ const char *buff);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_closeStartElement 
+(axis2_env_t *environment,
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_close_depth_element
 (axis2_env_t *environment,
  guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_checkNameValidity
+(axis2_env_t *environment,
+ guththila_xml_pull_parser_t *p,
+ char *start_element);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_open_depth_element
+(axis2_env_t *environment,
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *local_name, 
+ const char *value);
+
+
+AXIS2_EXTERN int
+guththila_xml_pull_parser_checkDefaultNamespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ char *ns_uri);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteDefaultNamespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ char *ns_uri);
+
+
+AXIS2_EXTERN int 
+guththila_xml_pull_parser_checkPrefixValidity 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ char *prefix, 
+ char *uri);
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeNamespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ char *prefix, 
+ char *uri);
+
+
+AXIS2_EXTERN int 
+guththila_xml_pull_parser_checkXmlStreamWriter 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteNamespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ char *prefix, 
+ char *uri);
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p,
+ const char *prefix, 
+ const char *namespace_uri,
+ const char *local_name, 
+ const char *value);
+
+
+AXIS2_EXTERN int
+guththila_xml_pull_parser_isExsistingPrefix 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ const char *prefix);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeStartDocument 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute_with_prefix
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ const char *prefix,
+ const char *local_name, 
+ const char *value);
+
+
+AXIS2_EXTERN char *
+guththila_xml_pull_parser_getPrefixForNamespace 
+(axis2_env_t *env, 
+ guththila_xml_pull_parser_t *p, 
+ const char *namespace);
+
+
+
+AXIS2_EXTERN void  guththila_xml_pull_parser_writeStartElement 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *start_element);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeEndElement 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_flush 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_close 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeCharacters 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p,
+ const char  *buff);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeComment 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *buff);
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeEscapeCharacter 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *buff);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeEmptyElement 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *empty_element);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeDefaultNamespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *namespace_uri);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeNamespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *prefix, char *uri);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeAttribute 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *localname, 
+ const char *value);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeAttribute_with_prefix_and_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p,
+ const char *prefix, 
+ const char *namespace_uri,
+ const char *localname, const char *value);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeAttribute_with_prefix 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p,
+ const char *prefix,
+ const char *localname, const char *value);
+
+
+AXIS2_EXTERN void  
+guththila_xml_pull_parser_writeAttribute_with_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p,
+ const char *namespace,
+ const char *localname, const char *value);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeStartElement_with_prefix_and_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char* prefix,
+ const char *namespace_uri, const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeStartElement_with_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *namespace_uri, 
+ const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeStartElement_with_prefix 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *prefix, 
+ const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeEmptyElement_with_prefix_and_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char* prefix,
+ const char *namespace_uri, 
+ const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeEmptyElement_with_namespace 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *namespace_uri, 
+ const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeEmptyElement_with_prefix 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ const char *prefix, 
+ const char *local_name);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeEndDocument 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p);
+
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_writeLine 
+(axis2_env_t *environment, 
+ guththila_xml_pull_parser_t *p, 
+ char *element_name, 
+ char *characters);
 
 #endif /* GUTHTHILA_XML_PULL_PARSER_H */

Added: webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c?rev=427511&view=auto
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c (added)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c Tue Aug  1 03:03:17 2006
@@ -0,0 +1,1078 @@
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ *
+ *	
+ * @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)	
+ */
+
+#include "guththila_xml_pull_parser.h"
+
+
+void
+guththila_xml_pull_parser_createXmlStreamWriter (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *file)
+{
+  if (p && file)
+    {
+      p->xsw = (guththila_xml_writer_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_xml_writer_t));
+      p->xsw->writer = guththila_writer_create_for_file (env, file);
+      p->xsw->writer_buffer = guththila_buffer_create (env, 1024);
+      p->xsw->element = axis2_stack_create (env);
+      p->xsw->attribute = axis2_stack_create (env);
+      p->xsw->namespace = axis2_stack_create (env);
+      p->xsw->depth = axis2_stack_create (env);
+      p->xsw->next = 0;
+      p->xsw->offset = 0;
+      p->xsw->last = 1024;	/* size of the buffer */
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_freeXmlStreamWriter (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  if (p->xsw->writer)
+    free (p->xsw->writer);
+  if (p->xsw->writer_buffer)
+    free (p->xsw->writer_buffer);
+  if (p->xsw)
+    free (p->xsw);
+}
+
+
+int
+guththila_xml_pull_parser_checkXmlStreamWriter (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  if (!p->xsw->writer)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_WRITER);
+  else 
+    return 1;
+  return 0;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeStartDocument (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p); 
+  char *sd = "<?xml version = \"1.0\" encoding = \"utf-8\" ?>";
+  guththila_xml_pull_parser_writeToBuffer (env, p, sd);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEndElement (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  void *element;
+  element = AXIS2_STACK_POP (p->xsw->element, env);
+  if (p->xsw->empty_element_open)
+    {
+      guththila_xml_pull_parser_closeStartElement (env, p);
+    }
+  else
+    {
+      guththila_xml_pull_parser_closeStartElement (env, p);
+      if (element)
+	{
+	  guththila_xml_pull_parser_writeToBuffer (env, p, "</");
+	  guththila_xml_pull_parser_writeToBuffer (env, p, element);
+	  guththila_xml_pull_parser_writeToBuffer (env, p, ">");
+	  guththila_xml_pull_parser_close_depth_element (env, p);
+	}
+      else
+	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+    }
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_flush (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  int c;
+  int ii = strlen (p->xsw->writer_buffer->buff);
+  c = guththila_writer_write (env, p->xsw->writer_buffer->buff, 0, ii, p->xsw->writer);
+  p->xsw->writer_buffer->buff[0] = 0;
+  p->xsw->writer_buffer->buff[1] = 0;
+  p->xsw->next = 0;
+  p->xsw->offset = 0;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeStartElement (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *start_element)
+{
+  int size;
+  void *element;
+  if (!p || !start_element)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  else
+    {
+      guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+      guththila_xml_pull_parser_closeStartElement (env, p);
+      size = AXIS2_STACK_SIZE (p->xsw->element, env);
+      if (size)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->element, env, 0);
+	  if (!strcmp ((char *)element, start_element))
+	    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	}
+      guththila_xml_pull_parser_checkNameValidity (env, p,start_element);
+      p->xsw->start_element_open = 1;
+
+      if (!p->xsw->empty_element_open)
+	AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
+      guththila_xml_pull_parser_writeToBuffer (env, p,"<");
+      guththila_xml_pull_parser_writeToBuffer  (env, p,start_element);
+    }
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeToBuffer (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
+{
+  if (buff)
+    {
+      guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+      if (p->xsw->next >= p->xsw->last)
+	{
+	  guththila_xml_pull_parser_flush (env, p);
+	  p->xsw->next = 0;
+	  p->xsw->offset = 0;
+	}
+      else
+	{
+	  int length;
+	  length = strlen (buff);
+	  strcat ((p->xsw->writer_buffer->buff) + (p->xsw->next), buff);
+	  p->xsw->offset = p->xsw->next;
+	  p->xsw->next += length;
+	}
+    }
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeCharacters (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  
+  if (buff)
+    {
+      guththila_xml_pull_parser_writeToBuffer (env, p,buff);
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_BUFFER);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_closeStartElement (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  if (p->xsw->start_element_open && p->xsw->empty_element_open)
+    {
+      p->xsw->start_element_open = 0;
+      p->xsw->empty_element_open = 0;
+      guththila_xml_pull_parser_writeToBuffer (env, p,"/>");
+   /*    Stack_clear (p->xsw->attribute); */
+    }
+  
+  if (p->xsw->start_element_open && !p->xsw->empty_element_open)
+    {
+      p->xsw->start_element_open = 0;
+      guththila_xml_pull_parser_writeToBuffer (env, p,">");
+/*       Stack_clear (p->xsw->attribute); */
+    }
+
+  guththila_xml_pull_parser_open_depth_element (env, p);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_checkNameValidity (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *name)
+{
+  int length;
+  int ii;
+  length = strlen (name);
+  /* ideograhic characters are also valid for name_starting charactes
+   * need to add them to here isIdeograpic function doesn't
+   * functionning correctly yet*/
+  if  (!(isalpha (name[0]) || name[0] == '_' || name[0] == ':'))
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_NAME);
+
+  /* xml in any case combination isn't allow */
+  if ((name[0] == 'x' || name[0] == 'X')
+      && (name[1] == 'm' || name[1] == 'M')
+      && (name[2] == 'l' || name[2] == 'L'))
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_XML_STRING_IN_NAME);
+  
+  /* some punctuation's not allowed */
+  for (ii = 1; ii < length; ii++)
+    {
+      if ((name[ii] == '$' || name[ii] == '^' || name[ii] == '%'
+	   || name[ii] == ';' || name[ii] == '\'' || name[ii] == '"'
+	   || name[ii] == '&' || name[ii] == '<' || name[ii] == '>'
+	   || isspace(name[ii])))
+	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_NAME);
+    }
+}
+
+
+int
+guththila_xml_pull_parser_isIdeographic (char *id)
+{
+  int ii;
+  short *xy = (short *)id;
+  for (ii = 0x4e00 ; ii < 0x9fa5; ii ++)
+    {
+      if (ii == xy[0])
+	return 1;
+    }
+
+  if (0x3007 == xy[0])
+    return 1;
+  
+  for (ii = 0x3021 ; ii <  0x3029; ii ++)
+    {
+      if (ii == xy[0])
+	return 1;
+    }
+  return 0;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeComment (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  char *s = strchr (buff, '-');
+  if (s && s[1] == '-')
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EXCESS_HYPENS_IN_COMMENT);
+
+  guththila_xml_pull_parser_writeToBuffer (env, p,"<!--");
+  guththila_xml_pull_parser_writeToBuffer (env, p,buff);
+  guththila_xml_pull_parser_writeToBuffer (env, p,"-->");
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEscapeCharacter (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
+{
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  if (buff)
+    {
+      switch (buff[0])
+	{
+	case '>':
+	  {
+	    guththila_xml_pull_parser_writeToBuffer (env, p,"&gt;");
+	  }
+	  break;
+	case '<':
+	  {
+	    guththila_xml_pull_parser_writeToBuffer (env, p,"&lt;");
+	  }
+	  break;
+	case '\'':
+	  {
+	    guththila_xml_pull_parser_writeToBuffer (env, p,"&apos;");
+	  }
+	  break;
+	case '"':
+	  {
+	    guththila_xml_pull_parser_writeToBuffer (env, p,"&quot;");
+	  }
+	  break;
+	case '&':
+	  {
+	    guththila_xml_pull_parser_writeToBuffer (env, p,"&amp;");
+	  }
+	  break;
+	};
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_BUFFER);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeAttribute (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *local_name, const char *value)
+{
+  int size = 0;
+  void *element;
+  guththila_attribute_t *attr;
+
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+
+  size = AXIS2_STACK_SIZE (p->xsw->attribute, env);
+  if (size)
+    {
+      int ii;
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->attribute, env, size - ii);
+	  if (element)
+	    {
+	      attr = (guththila_attribute_t *)element;
+	      if (!strcmp((char *)attr->name, local_name))
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	      else
+		{
+		  guththila_xml_pull_parser_doWriteAttribute (env, p,local_name, value);
+		  break;
+		}
+	    }
+	}
+	    
+    }
+  else
+    {
+      guththila_xml_pull_parser_doWriteAttribute (env, p,local_name, value);
+    }
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *local_name, const char *value)
+{
+ guththila_attribute_t *attr = (guththila_attribute_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_attribute_t));
+  
+  if (local_name)
+    attr->name = (guththila_token_t *)local_name;
+  if (value)
+    attr->value = (guththila_token_t *)value;
+  if (local_name && value)
+    {
+      AXIS2_STACK_PUSH (p->xsw->attribute, env, (AXIS2_EXTERN void *)attr);
+    }
+
+  guththila_xml_pull_parser_checkNameValidity (env, p,(char *)local_name);
+  
+  if (strrchr (value, '&') 
+      || strrchr (value, '<') 
+      || strrchr (value, '\''))
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE);
+
+  guththila_xml_pull_parser_writeToBuffer (env, p," ");
+  guththila_xml_pull_parser_writeToBuffer (env, p,local_name);
+  guththila_xml_pull_parser_writeToBuffer (env, p," = \'");
+  guththila_xml_pull_parser_writeToBuffer (env, p,value);
+  guththila_xml_pull_parser_writeToBuffer (env, p,"\'");
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEmptyElement (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *empty_element)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  p->xsw->start_element_open = 0;
+  p->xsw->empty_element_open = 1;
+  guththila_xml_pull_parser_writeStartElement (env, p,empty_element);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeDefaultNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *namespace_uri)
+{
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  else
+    {
+     
+      if (guththila_xml_pull_parser_checkDefaultNamespace (env, p,namespace_uri))
+	{
+	  guththila_xml_pull_parser_doWriteDefaultNamespace (env, p,namespace_uri);
+	}
+    }
+}
+
+
+int
+guththila_xml_pull_parser_checkDefaultNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *ns_uri)
+{
+  int size;
+  int ii;
+  void *element;
+  guththila_namespace_t *ns;
+ size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+  if (size)
+    {
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->namespace, env, size - ii);
+	  if (element)
+	    {
+	      ns = (guththila_namespace_t *)element;
+	      if (ns)
+		{
+		  if (!ns->length || !strcmp (ns->uri, ns_uri))
+		    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		}
+	    }
+	}
+      return 1;
+
+    }
+  else
+    return 1;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteDefaultNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *ns_uri)
+{
+guththila_namespace_t *ns = (guththila_namespace_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_namespace_t));
+  ns->name = NULL;
+  ns->length = 0;
+  ns->uri = ns_uri;
+  ns->lengthuri = strlen (ns_uri);
+  AXIS2_STACK_PUSH (p->xsw->namespace, env, (AXIS2_EXTERN void *)ns);
+
+  guththila_xml_pull_parser_writeToBuffer (env, p," ");
+  guththila_xml_pull_parser_writeToBuffer (env, p,"xmlns");
+  guththila_xml_pull_parser_writeToBuffer (env, p," = \'");
+  guththila_xml_pull_parser_writeToBuffer (env, p,ns_uri);
+  guththila_xml_pull_parser_writeToBuffer (env, p,"\'");
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
+{
+  if (!prefix || !strcmp(prefix, "xmlns"))
+    guththila_xml_pull_parser_doWriteDefaultNamespace (env, p,uri);
+  
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  else
+    {
+      if (guththila_xml_pull_parser_checkPrefixValidity (env, p,prefix, uri))
+	guththila_xml_pull_parser_doWriteNamespace (env, p,prefix, uri);
+    }
+
+}
+
+
+int 
+guththila_xml_pull_parser_checkPrefixValidity (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
+{
+  int size;
+  int ii;
+  void *element;
+  guththila_namespace_t *ns;
+  size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+  if (size)
+    {
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->namespace, env, size - ii);
+	  if (element)
+	    {
+	      ns = (guththila_namespace_t *)element;
+	      if (ns->name)
+		{
+		  if (!strcmp (ns->name, prefix))
+		    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		}
+	      if (uri)
+		{
+		  if (ns->uri)
+		    {
+		      if (!strcmp (ns->uri, uri))
+			guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		    }
+		}
+	    }
+	}
+      return 1;
+    }
+  else
+    return 1;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
+{
+  guththila_namespace_t *ns = (guththila_namespace_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_namespace_t));
+  ns->name = prefix;
+  ns->length = strlen (prefix);
+  ns->uri = uri;
+  ns->lengthuri = strlen (uri);
+  AXIS2_STACK_PUSH (p->xsw->namespace, env, (AXIS2_EXTERN void *)ns);
+  
+  guththila_xml_pull_parser_writeToBuffer (env, p," ");
+  guththila_xml_pull_parser_writeToBuffer (env, p,"xmlns:");
+  guththila_xml_pull_parser_writeToBuffer (env, p,prefix);
+  guththila_xml_pull_parser_writeToBuffer (env, p," = \'");
+  guththila_xml_pull_parser_writeToBuffer (env, p,uri);
+  guththila_xml_pull_parser_writeToBuffer (env, p,"\'");
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeAttribute_with_prefix_and_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p,
+							 const char *prefix, const char *namespace,
+							 const char *local_name, const char *value)
+{
+  int size = 0;
+  void *element;
+  guththila_attribute_t *attr;
+  
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+
+  if (prefix && namespace)
+    guththila_xml_pull_parser_writeNamespace (env, p,(char *)prefix, (char *)namespace);
+
+  size = AXIS2_STACK_SIZE (p->xsw->attribute, env);
+  if (size)
+    {
+      int ii;
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->attribute, env, size - ii);
+	  if (element)
+	    {
+	      attr = (guththila_attribute_t *)element;
+	      /* We want to make sure that out checking attribute has
+		 the prefix otherwise we don't wan't to worry */
+	      if (attr->name && attr->prefix) 
+		{
+		  if (!strcmp((char *)attr->name, local_name) && !strcmp((char *)attr->prefix, prefix))
+		    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		  else
+		    {
+		      guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace (env, p,prefix, namespace, local_name, value);
+		      break;
+		    }
+		}
+	      else
+		{
+		  /* since att->prefix is null im going to write it here */
+		  guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace (env, p,prefix, namespace, local_name, value);
+		  break;
+		}
+	    }
+	}
+      
+    }
+  else
+    {
+      guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace (env, p,prefix, namespace, local_name, value);
+    }
+
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, 
+							   const char *prefix, const char *namespace_uri,
+							   const char *local_name, const char *value)
+{
+  guththila_attribute_t *attr = (guththila_attribute_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_attribute_t));
+  
+  if (prefix)
+    attr->prefix = (guththila_token_t *)prefix;
+  if (namespace_uri)
+    attr->namespace_uri = (guththila_token_t *)namespace_uri;
+  if (local_name)
+    attr->name = (guththila_token_t *)local_name;
+  if (value)
+    attr->value = (guththila_token_t *)value;
+
+  if (local_name && value)
+    {
+      AXIS2_STACK_PUSH (p->xsw->attribute, env, (AXIS2_EXTERN void *)attr);
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+
+  guththila_xml_pull_parser_checkNameValidity (env, p,(char *)local_name);
+  
+  if (strrchr (value, '&') 
+      || strrchr (value, '<') 
+      || strrchr (value, '\''))
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE);
+
+  guththila_xml_pull_parser_writeToBuffer (env, p," ");
+  if (prefix)
+    {
+      guththila_xml_pull_parser_writeToBuffer (env, p,prefix);
+      guththila_xml_pull_parser_writeToBuffer (env, p,":");
+    }
+  guththila_xml_pull_parser_writeToBuffer (env, p,local_name);
+  guththila_xml_pull_parser_writeToBuffer (env, p," = \'");
+  guththila_xml_pull_parser_writeToBuffer (env, p,value);
+  guththila_xml_pull_parser_writeToBuffer (env, p,"\'");
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeAttribute_with_prefix (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix,
+					   const char *local_name, const char *value)
+{
+  int size = 0;
+  void *element;
+  guththila_attribute_t *attr;
+
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  /* actually here we want exsisting prefix , that's why we check it
+     exsists or not. */
+  if (guththila_xml_pull_parser_isExsistingPrefix (env, p,prefix))
+    {
+      size = AXIS2_STACK_SIZE (p->xsw->attribute, env);
+      if (size)
+	{
+	  int ii;
+	  for (ii = 0; ii <= size; ii++)
+	    {
+	      element = AXIS2_STACK_GET_AT (p->xsw->attribute, env,  ii);
+	      if (element)
+		{
+		  attr = (guththila_attribute_t *)element;
+		  /* We want to make sure that out checking attribute has
+		     the prefix otherwise we don't wan't to worry */
+		  if (attr->name && attr->prefix) 
+		    {
+		      if (!strcmp((char *)attr->name, local_name) && !strcmp((char *)attr->prefix, prefix))
+			guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		      else
+			{
+			  guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+			  break;
+			}
+		    }
+		  else
+		    {
+		      /* since att->prefix is null im going to write it here */
+		      guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+		      break;
+		    }
+		}
+	    }
+      
+	}
+      else
+	{
+	  guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+	}
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_EXSISTING_PREFIX);
+
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_doWriteAttribute_with_prefix(axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix,
+					    const char *local_name, const char *value)
+{
+  guththila_xml_pull_parser_doWriteAttribute_with_prefix_and_namespace (env, p,prefix, NULL, local_name, value);
+}
+
+
+int
+guththila_xml_pull_parser_isExsistingPrefix (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix)
+{
+  int size;
+  int ii;
+  void *element;
+  guththila_namespace_t *ns;
+  size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+  if (size)
+    {
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->namespace, env, ii);
+	  if (element)
+	    {
+	      ns = (guththila_namespace_t *)element;
+	      if (ns->name)
+		{
+		  if (!strcmp (ns->name, prefix))
+		    return 1;
+		}
+	    }
+	}
+      return 0;
+    }
+  else
+    return 0;
+}
+
+
+int
+guththila_xml_pull_parser_isExsistingNamespaceUri (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *uri)
+{
+  int size;
+  int ii;
+  void *element;
+  guththila_namespace_t *ns;
+  size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+  if (size)
+    {
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->namespace, env , size - ii);
+	  if (element)
+	    {
+	      ns = (guththila_namespace_t *)element;
+	      if (ns->uri)
+		{
+		  if (!strcmp (ns->uri, uri))
+		    return 1;
+		}
+	    }
+	}
+      return 0;
+    }
+  else
+    return 0;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeAttribute_with_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *namespace,
+					      const char *local_name, const char *value)
+{
+  int size = 0;
+  void *element;
+  guththila_attribute_t *attr;
+  if (!p->xsw->start_element_open)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  /* actually here we want exsisting namespace , that's why we check it
+     exsists or not. */
+  if (guththila_xml_pull_parser_isExsistingNamespaceUri (env, p,namespace))
+    {
+      char *prefix;
+      prefix = guththila_xml_pull_parser_getPrefixForNamespace (env, p, namespace);
+      size = AXIS2_STACK_SIZE (p->xsw->attribute, env);
+      if (size)
+	{
+	  int ii;
+	  for (ii = 0; ii <= size; ii++)
+	    {
+	      element = AXIS2_STACK_GET_AT (p->xsw->attribute, env, size - ii);
+	      if (element)
+		{
+		  attr = (guththila_attribute_t *)element;
+		  /* We want to make sure that out checking attribute has
+		     the namespace otherwise we don't wan't to worry */
+		  if (attr->name && attr->prefix) 
+		    {
+		      if (!strcmp((char *)attr->name, local_name) && !strcmp((char *)attr->prefix, prefix))
+			guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		      else
+			{
+			  guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+			  break;
+			}
+		    }
+		  else
+		    {
+		      /* since att->prefix is null im going to write it here */
+		      guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+		      break;
+		    }
+		}
+	    }
+      
+	}
+      else
+	{
+	  guththila_xml_pull_parser_doWriteAttribute_with_prefix (env, p,prefix, local_name, value);
+	}
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_EXSISTING_URI);
+}
+
+
+char *
+guththila_xml_pull_parser_getPrefixForNamespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *namespace)
+{
+  int size;
+  int ii;
+  void *element;
+  guththila_namespace_t *ns;
+  size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+  if (size)
+    {
+      for (ii = 0; ii <= size; ii++)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->namespace, env, size - ii);
+	  if (element)
+	    {
+	      ns = (guththila_namespace_t *)element;
+	      if (ns->uri)
+		{
+		  if (!strcmp (ns->uri, namespace))
+		    return (char *)ns->name;
+		}
+	    }
+	}
+      return 0;
+    }
+  else
+    return 0;
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeStartElement_with_prefix_and_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix,
+							    const char *namespace_uri, const char *local_name)
+{
+  int size;
+  void *element;
+  char *start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+  if (!p || !local_name)
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+  else
+    {
+      guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+      guththila_xml_pull_parser_closeStartElement (env, p);
+     
+      if (prefix)
+	{
+	  strcat (start_element, prefix);
+	  strcat (start_element, ":");
+	  strcat (start_element, local_name);
+	} 
+      size = AXIS2_STACK_SIZE (p->xsw->element, env);
+      if (size)
+	{
+	  element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
+	  if (!strcmp ((char *)element, start_element))
+	    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	}
+
+      guththila_xml_pull_parser_checkNameValidity (env, p,start_element);
+      p->xsw->start_element_open = 1;
+      
+      if (!p->xsw->empty_element_open)
+	AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
+      guththila_xml_pull_parser_writeToBuffer (env, p,"<");
+      guththila_xml_pull_parser_writeToBuffer  (env, p,start_element);
+      guththila_xml_pull_parser_writeNamespace (env, p,(char *)prefix, (char *)namespace_uri);
+    }
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeStartElement_with_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *namespace_uri, const char *local_name)
+{
+  int size;
+  void *element;
+  char *start_element;
+  if (guththila_xml_pull_parser_isExsistingNamespaceUri (env, p,namespace_uri))
+    {
+      if (!p || !local_name)
+	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+      else
+	{
+	  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+	  guththila_xml_pull_parser_closeStartElement (env, p);
+	  char *prefix = guththila_xml_pull_parser_getPrefixForNamespace (env, p,namespace_uri);
+	  if (prefix)
+	    start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+	  else
+	    start_element = (char *) calloc ((strlen (local_name) +2), 1);
+     
+	  if (prefix)
+	    {
+	      strcat (start_element, prefix);
+	      strcat (start_element, ":");
+	      strcat (start_element, local_name);
+	    } 
+	  else
+	    strcat (start_element, local_name);
+	  size = AXIS2_STACK_SIZE (p->xsw->element, env);
+	  if (size)
+	    {
+	      element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
+	      if (!strcmp ((char *)element, start_element))
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	    }
+
+	  guththila_xml_pull_parser_checkNameValidity (env, p,start_element);
+	  p->xsw->start_element_open = 1;
+      
+	  if (!p->xsw->empty_element_open)
+	    AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
+	  guththila_xml_pull_parser_writeToBuffer (env, p,"<");
+	  guththila_xml_pull_parser_writeToBuffer  (env, p,start_element);
+	}
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_EXSISTING_URI);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeStartElement_with_prefix (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix, const char *local_name)
+{
+  int size;
+  void *element;
+  char *start_element = NULL;
+  if (guththila_xml_pull_parser_isExsistingPrefix (env, p,prefix))
+    {
+      if (!p || !local_name)
+	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+      else
+	{
+	  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+	  guththila_xml_pull_parser_closeStartElement (env, p);
+	  
+	  if (prefix)
+	    start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+	       
+	  if (prefix)
+	    {
+	      strcat (start_element, prefix);
+	      strcat (start_element, ":");
+	      strcat (start_element, local_name);
+	    } 
+	  size = AXIS2_STACK_SIZE (p->xsw->element, env);
+	  if (size)
+	    {
+	      element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
+	      if (!strcmp ((char *)element, start_element))
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	    }
+
+	  guththila_xml_pull_parser_checkNameValidity (env, p, start_element);
+	  p->xsw->start_element_open = 1;
+      
+	  if (!p->xsw->empty_element_open)
+	    AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
+	  guththila_xml_pull_parser_writeToBuffer (env, p,"<");
+	  guththila_xml_pull_parser_writeToBuffer  (env, p,start_element);
+	}
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_EXSISTING_PREFIX);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEmptyElement_with_prefix_and_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p,const char *prefix,
+							    const char *namespace_uri, const char *empty_element)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  p->xsw->start_element_open = 0;
+  p->xsw->empty_element_open = 1;
+  guththila_xml_pull_parser_writeStartElement_with_prefix_and_namespace (env, p,prefix, namespace_uri, empty_element);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEmptyElement_with_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *namespace_uri, const char *empty_element)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  p->xsw->start_element_open = 0;
+  p->xsw->empty_element_open = 1;
+  guththila_xml_pull_parser_writeStartElement_with_namespace (env, p,namespace_uri, empty_element);
+}
+
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEmptyElement_with_prefix (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *prefix, const char *empty_element)
+{
+  guththila_xml_pull_parser_checkXmlStreamWriter (env, p);
+  guththila_xml_pull_parser_closeStartElement (env, p);
+  p->xsw->start_element_open = 0;
+  p->xsw->empty_element_open = 1;
+  guththila_xml_pull_parser_writeStartElement_with_prefix(env, p,prefix, empty_element);
+}
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_open_depth_element (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  int size = AXIS2_STACK_SIZE (p->xsw->depth, env);
+  guththila_depth_t *d = (guththila_depth_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_depth_t));
+  if (size)
+    {
+      void *e = NULL;
+      e = AXIS2_STACK_GET (p->xsw->depth, env);
+      guththila_depth_t *l = (guththila_depth_t *)e;
+      d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+      d->first = l->first + l->count;
+      d->count = d->total - l->total;
+    }
+  else
+    {
+      d->first = 0;
+      d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+      d->count = d->total;
+      AXIS2_STACK_PUSH (p->xsw->depth, env, (void *)d);
+    }
+}
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_close_depth_element (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  void *e = AXIS2_STACK_POP (p->xsw->depth, env);
+  guththila_depth_t *d = (guththila_depth_t *)e;
+  void *elem = NULL;
+  guththila_namespace_t *ns = NULL;
+  if (d->count)
+    {
+      for (; d->count > 0; d->count --)
+	{
+	  elem = AXIS2_STACK_POP (p->xsw->namespace, env);
+	  ns = elem;
+	  if (ns)
+	    free (ns);
+	}
+    }
+}
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeEndDocument (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  if (p->xsw->start_element_open || p->xsw->empty_element_open)
+    guththila_xml_pull_parser_closeStartElement (env, p);
+  int ii = AXIS2_STACK_SIZE (p->xsw->element, env);
+  for (; ii > 0; ii --)
+    guththila_xml_pull_parser_writeEndElement (env, p);
+  guththila_xml_pull_parser_flush (env, p);
+}
+
+AXIS2_EXTERN void 
+guththila_xml_pull_parser_close (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  guththila_xml_pull_parser_flush (env, p);
+  fclose (((guththila_writer_impl_t *)p->xsw->writer)->outputstream);
+}
+
+AXIS2_EXTERN void
+guththila_xml_pull_parser_writeLine (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *local_name, char *characters)
+{
+  guththila_xml_pull_parser_writeStartElement (env, p,local_name);
+  guththila_xml_pull_parser_writeCharacters (env, p,characters);
+  guththila_xml_pull_parser_writeEndElement (env, p);
+  guththila_xml_pull_parser_writeCharacters (env, p,"\n");
+}

Added: webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.h?rev=427511&view=auto
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.h (added)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.h Tue Aug  1 03:03:17 2006
@@ -0,0 +1,44 @@
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed 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.
+ *
+ *	
+ * @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)	
+ */
+
+#ifndef XML_STREAMWRITER_H
+#define XML_STREAMWRITER_H
+#include "guththila_writer.h"
+#include "guththila_buffer.h"
+#include <axis2_env.h>
+#include <axis2_stack.h>
+
+typedef struct guththila_xml_writer_s
+{
+  axis2_stack_t *element;
+  axis2_stack_t *attribute;
+  axis2_stack_t *namespace;
+  axis2_stack_t *depth;
+  guththila_writer_t *writer;
+  guththila_buffer_t *writer_buffer;
+  int next;
+  int last;
+  int offset;
+  int start_element_open;
+  int empty_element_open;
+}guththila_xml_writer_t;
+
+
+
+#endif /* XML_STREAMWRITER_H */



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


Mime
View raw message