Check-in [e3d1c7f87c]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:e3d1c7f87cd97ef7bd89625bba6579f839a358ef
Date: 2008-11-14 16:38:24
User: stephan
Comment:fixed the buggy XML indention
Changes
hide diffs unified diffs patch

Changes to src/c11n_io_handler_expat.c

Old (8c2659da55349183) New (a76b051525747897)
1 #include "s11n.net/c11n/io/c11n_io.h" 1 #include "s11n.net/c11n/io/c11n_io.h"
2 #include "s11n.net/c11n/io/c11n_io_handler_expat.h" 2 #include "s11n.net/c11n/io/c11n_io_handler_expat.h"
3 #include "s11n.net/c11n/detail/memblob.h" 3 #include "s11n.net/c11n/detail/memblob.h"
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
80 hidden lines
86 IMPLDECL(false); 86 IMPLDECL(false);
87 if( !src || (!impl->stream || !impl->stream->api->isgood(impl->stream)) ) return false; 87 if( !src || (!impl->stream || !impl->stream->api->isgood(impl->stream)) ) return false;
88 #define W impl->stream->api->write 88 #define W impl->stream->api->write
89 #define WF c11n_stream_writef 89 #define WF c11n_stream_writef
90 c11n_stream * dest = impl->stream; 90 c11n_stream * dest = impl->stream;
91 | 91 char const * tabs = memblob_size(impl->tabs) ? memblob_bufferc( impl->tabs ) : "";
92 if( impl->indentLevel++ != 0 ) | 92 WF( dest, "%s<%s class='%s'>\n", tabs, c11n_node_get_name( src ), c11n_node_get_class(src), impl->indentLevel );
93 { |
94 memblob_append( impl->tabs, "\t", 1 ); |
95 //memblob_null_terminate( impl->tabs ); |
96 } |
97 char const * tabs = memblob_bufferc( impl->tabs ); |
98 if( ! tabs || !*tabs ) tabs = ""; |
99 |
100 WF( dest, "%s<%s class=\"%s\">\n", tabs, c11n_node_get_name( src ), c11n_node_get_class(src) ); |
101 #if 1 93 #if 1
102 c11n_prop_iter piter = c11n_node_prop_iter(src); 94 c11n_prop_iter piter = c11n_node_prop_iter(src);
103 while( c11n_prop_iter_isvalid( &piter ) ) | 95 if( c11n_prop_iter_isvalid( &piter ) )
104 { 96 {
105 c11n_const_string_t key = c11n_prop_iter_key( &piter ); | 97 while( c11n_prop_iter_isvalid( &piter ) )
106 c11n_const_string_t val = c11n_prop_iter_val( &piter ); |
107 memblob_truncate( impl->xlate, 0, 0 ); |
108 if( val ) |
109 { 98 {
110 c11n_io_escape_string( val, c11n_strlen( val ), expat_val_escapes, true, impl->xlate ); | 99 c11n_const_string_t key = c11n_prop_iter_key( &piter );
| 100 c11n_const_string_t val = c11n_prop_iter_val( &piter );
| 101 memblob_truncate( impl->xlate, 0, 0 );
| 102 if( val )
| 103 {
| 104 c11n_io_escape_string( val, c11n_strlen( val ), expat_val_escapes, true, impl->xlate );
| 105 }
| 106 WF( dest, "\t%s<%s>%s</%s>\n", tabs, key,
| 107 memblob_size(impl->xlate) ? memblob_bufferc(impl->xlate) : "",
| 108 key );
| 109 c11n_prop_iter_next(&piter);
111 } 110 }
112 WF( dest, "\t%s<%s>%s</%s>\n", tabs, key, <
113 memblob_size(impl->xlate) ? memblob_bufferc(impl->xlate) : "", <
114 key ); <
115 c11n_prop_iter_next(&piter); <
116 } 111 }
117 #endif 112 #endif
118 #if 1 113 #if 1
119 c11n_node_iter_c chi = c11n_node_children_iter_c( src ); 114 c11n_node_iter_c chi = c11n_node_children_iter_c( src );
120 while( c11n_node_iter_isvalid_c( &chi ) ) | 115 if( c11n_node_iter_isvalid_c( &chi ) )
121 { 116 {
122 if( ! expat_save_node( self, chi.node ) ) return false; | 117 ++impl->indentLevel;
123 c11n_node_iter_next_c(&chi); | 118 memblob_append( impl->tabs, "\t", 1 );
| 119 do
| 120 {
| 121 if( ! expat_save_node( self, chi.node ) ) return false;
| 122 c11n_node_iter_next_c(&chi);
| 123 } while( c11n_node_iter_isvalid_c( &chi ) );
| 124 --impl->indentLevel;
| 125 memblob_truncate( impl->tabs, impl->indentLevel, 0 );
124 } 126 }
125 #endif 127 #endif
126 --impl->indentLevel; <
127 memblob_truncate( impl->tabs, impl->indentLevel, 0 ); <
128 WF( dest, "%s</%s>\n", tabs, c11n_node_get_name( src ) ); 128 WF( dest, "%s</%s>\n", tabs, c11n_node_get_name( src ) );
129 #undef WF 129 #undef WF
130 #undef W 130 #undef W
131 //memblob_null_terminate( impl->tabs ); 131 //memblob_null_terminate( impl->tabs );
132 return true; 132 return true;
170 hidden lines
303 303
304 c11n_io_handler * c11n_io_handler_factory_expat( c11n_const_string_t ignored ) 304 c11n_io_handler * c11n_io_handler_factory_expat( c11n_const_string_t ignored )
305 { 305 {
306 return c11n_io_handler_create_expat(); 306 return c11n_io_handler_create_expat();
307 } 307 }