1 /* This file has been automatically generated by builder part of the ferite distribution */
2 /* file: xml_XML_Element.c */
3 /* class: Element */
4
5 #include <ferite.h> /* we need this without a doubt */
6 #include "xml_header.h" /* this is the module header */
7
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_removeSelf_)8 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_removeSelf_ )
9 {
10 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
11 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
12
13 { /* Main function body. */
14 #line 1045 "xml.fec"
15
16
17 XMLDoc *tree = self->odata;
18 xmlNodePtr elem = NULL;
19
20 elem = tree->node;
21 tree->node = tree->node->next;
22
23 xmlUnlinkNode( elem );
24
25 }
26 FE_RETURN_VOID;
27 self = NULL;
28 super = NULL;
29 }
30
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getParent_)31 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getParent_ )
32 {
33 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
34 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
35
36 { /* Main function body. */
37 #line 662 "xml.fec"
38
39
40 XMLDoc *tree = self->odata;
41 if( tree->node->parent )
42 {
43 FeriteVariable *obj = NULL;
44 obj = create_element_node( script, tree->doc, tree->node->parent );
45 FE_RETURN_VAR( obj );
46 }
47 FE_RETURN_NULL_OBJECT;
48
49 }
50 FE_RETURN_VOID;
51 self = NULL;
52 super = NULL;
53 }
54
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getLastChild_)55 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getLastChild_ )
56 {
57 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
58 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
59
60 { /* Main function body. */
61 #line 644 "xml.fec"
62
63
64 XMLDoc *tree = self->odata;
65 if( tree->node->last )
66 {
67 FeriteVariable *obj = NULL;
68 obj = create_element_node( script, tree->doc, tree->node->last );
69 FE_RETURN_VAR( obj );
70 }
71 FE_RETURN_NULL_OBJECT;
72
73 }
74 FE_RETURN_VOID;
75 self = NULL;
76 super = NULL;
77 }
78
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getElementData_)79 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getElementData_ )
80 {
81 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
82 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
83
84 { /* Main function body. */
85 #line 462 "xml.fec"
86
87
88 FeriteString *str = NULL;
89 xmlChar *key = NULL;
90 XMLDoc *tree = self->odata;
91
92 key = xmlNodeGetContent(tree->node); /*xmlNodeListGetString(tree->doc, tree->node, 1);*/
93 if( key != NULL ) {
94 str = ferite_str_new( (char *)key, 0, FE_CHARSET_DEFAULT );
95 xmlFree( key );
96 }
97 FE_RETURN_STR( str, FE_TRUE );
98
99 }
100 FE_RETURN_VOID;
101 self = NULL;
102 super = NULL;
103 }
104
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_mergeAsPreviousSibling_o)105 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_mergeAsPreviousSibling_o )
106 {
107 FeriteObject *chk;
108 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
109 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
110
111 ferite_get_parameters( params, 1, &chk );
112
113 { /* Main function body. */
114 #line 1184 "xml.fec"
115
116
117 if( chk != NULL )
118 {
119 FeriteVariable *obj = NULL;
120 XMLDoc *tree = self->odata;
121 XMLDoc *chunk = chk->odata;
122 xmlNodePtr ret = NULL;
123
124 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
125 {
126 ret = xmlCopyNode( chunk->node, 1 );
127 if( ret != NULL ) {
128 xmlAddPrevSibling(tree->node, ret);
129 recursive_namespace_copy( ret, tree->node->parent );
130 obj = create_element_node( script, tree->doc, ret );
131 FE_RETURN_VAR( obj );
132 }
133 }
134 }
135 FE_RETURN_NULL_OBJECT;
136
137 }
138 FE_RETURN_VOID;
139 self = NULL;
140 super = NULL;
141 }
142
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addSibling_ss)143 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addSibling_ss )
144 {
145 FeriteString *name;
146 FeriteString *data;
147 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
148 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
149
150 ferite_get_parameters( params, 2, &name, &data );
151
152 { /* Main function body. */
153 #line 772 "xml.fec"
154
155 FeriteVariable *obj = NULL;
156 XMLDoc *tree = self->odata;
157 xmlNodePtr node = NULL;
158 xmlNodePtr ret = NULL;
159 xmlChar *value = NULL;
160
161 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
162 {
163 if( data->length )
164 value = (xmlChar*)data->data;
165
166 node = xmlNewDocNode( tree->doc, NULL, (xmlChar*)name->data, value );
167 if( node != NULL ) {
168 node->doc = tree->doc;
169 ret = xmlAddSibling( tree->node, node );
170 recursive_namespace_copy( ret, tree->node->parent );
171 obj = create_element_node( script, tree->doc, ret );
172 FE_RETURN_VAR( obj );
173 }
174 }
175 FE_RETURN_NULL_OBJECT;
176
177 }
178 FE_RETURN_VOID;
179 self = NULL;
180 super = NULL;
181 }
182
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_hasAttributes_)183 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_hasAttributes_ )
184 {
185 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
186 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
187
188 { /* Main function body. */
189 #line 514 "xml.fec"
190
191
192 XMLDoc *tree = self->odata;
193 FE_RETURN_LONG( tree->node->properties ? 1 : 0 );
194
195 }
196 FE_RETURN_VOID;
197 self = NULL;
198 super = NULL;
199 }
200
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getElementsByTagName_s)201 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getElementsByTagName_s )
202 {
203 FeriteString *name;
204 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
205 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
206
207 ferite_get_parameters( params, 1, &name );
208
209 { /* Main function body. */
210 #line 483 "xml.fec"
211
212
213 FeriteVariable *array = NULL;
214 FeriteVariable *obj = NULL;
215 xmlXPathObjectPtr res = NULL;
216 xmlNodeSetPtr cur = NULL;
217 register int i = 0;
218 XMLDoc *tree = self->odata;
219
220 res = get_nodes_with_name_xpath( tree, name );
221 switch ( res->type ) {
222 case XPATH_NODESET:
223 cur = res->nodesetval;
224 array = ferite_create_uarray_variable( script, "Nodes", FE_ARRAY_DEFAULT_SIZE, FE_STATIC );
225
226 for (i = 0 ; i < cur->nodeNr ; i++) {
227 obj = create_element_node( script, tree->doc, cur->nodeTab[i] );
228 ferite_uarray_add( script, VAUA( array ), obj, NULL, FE_ARRAY_ADD_AT_END );
229 }
230 break;
231 }
232 xmlXPathFreeObject( res );
233 FE_RETURN_VAR( array );
234
235 }
236 FE_RETURN_VOID;
237 self = NULL;
238 super = NULL;
239 }
240
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getElementName_)241 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getElementName_ )
242 {
243 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
244 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
245
246 { /* Main function body. */
247 #line 447 "xml.fec"
248
249
250 XMLDoc *tree = self->odata;
251 FeriteString *str = NULL;
252
253 str = ferite_str_new( (char *)tree->node->name, 0, FE_CHARSET_DEFAULT );
254 FE_RETURN_STR( str, FE_TRUE );
255
256 }
257 FE_RETURN_VOID;
258 self = NULL;
259 super = NULL;
260 }
261
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_mergeAsChild_o)262 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_mergeAsChild_o )
263 {
264 FeriteObject *chk;
265 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
266 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
267
268 ferite_get_parameters( params, 1, &chk );
269
270 { /* Main function body. */
271 #line 1094 "xml.fec"
272
273
274 if( chk != NULL )
275 {
276 FeriteVariable *obj = NULL;
277 XMLDoc *tree = self->odata;
278 XMLDoc *chunk = chk->odata;
279 xmlNodePtr ret = NULL;
280
281 ret = xmlCopyNode( chunk->node, 1 );
282 if( ret != NULL ) {
283 xmlAddChild(tree->node, ret);
284 recursive_namespace_copy( ret, tree->node );
285 obj = create_element_node( script, tree->doc, ret );
286 FE_RETURN_VAR( obj );
287 }
288 }
289 FE_RETURN_NULL_OBJECT;
290
291 }
292 FE_RETURN_VOID;
293 self = NULL;
294 super = NULL;
295 }
296
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getFirstChild_)297 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getFirstChild_ )
298 {
299 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
300 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
301
302 { /* Main function body. */
303 #line 626 "xml.fec"
304
305
306 XMLDoc *tree = self->odata;
307 if( tree->node->children )
308 {
309 FeriteVariable *obj = NULL;
310 obj = create_element_node( script, tree->doc, tree->node->children );
311 FE_RETURN_VAR( obj );
312 }
313 FE_RETURN_NULL_OBJECT;
314
315 }
316 FE_RETURN_VOID;
317 self = NULL;
318 super = NULL;
319 }
320
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_hasAttribute_s)321 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_hasAttribute_s )
322 {
323 FeriteString *name;
324 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
325 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
326
327 ferite_get_parameters( params, 1, &name );
328
329 { /* Main function body. */
330 #line 527 "xml.fec"
331
332
333 XMLDoc *tree = self->odata;
334 if( xmlHasProp( tree->node, (xmlChar*)name->data ) )
335 FE_RETURN_TRUE;
336 FE_RETURN_FALSE;
337
338 }
339 FE_RETURN_VOID;
340 self = NULL;
341 super = NULL;
342 }
343
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_removeElementsByTagName_s)344 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_removeElementsByTagName_s )
345 {
346 FeriteString *name;
347 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
348 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
349
350 ferite_get_parameters( params, 1, &name );
351
352 { /* Main function body. */
353 #line 1063 "xml.fec"
354
355
356 XMLDoc *tree = self->odata;
357 xmlXPathObjectPtr res = NULL;
358 xmlNodeSetPtr cur = NULL;
359 register int i = 0;
360
361 res = get_nodes_with_name_xpath( tree, name );
362 switch( res->type )
363 {
364 case XPATH_NODESET:
365 cur = res->nodesetval;
366
367 for (i = 0 ; i < cur->nodeNr ; i++) {
368 xmlUnlinkNode( cur->nodeTab[i] );
369 }
370 break;
371 }
372 xmlXPathFreeObject( res );
373 FE_RETURN_LONG( i );
374
375 }
376 FE_RETURN_VOID;
377 self = NULL;
378 super = NULL;
379 }
380
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_removeChildren_)381 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_removeChildren_ )
382 {
383 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
384 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
385
386 { /* Main function body. */
387 #line 999 "xml.fec"
388
389
390 XMLDoc *tree = self->odata;
391 xmlNodePtr elem = NULL;
392 int count = 0;
393
394 elem = tree->node->children;
395 while ( elem ) {
396 xmlUnlinkNode( elem );
397 count++;
398 elem = elem->next;
399 }
400
401 tree->node->children = tree->node->last = NULL;
402 FE_RETURN_LONG( count );
403
404 }
405 FE_RETURN_VOID;
406 self = NULL;
407 super = NULL;
408 }
409
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_setElementData_s)410 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_setElementData_s )
411 {
412 FeriteString *value;
413 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
414 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
415
416 ferite_get_parameters( params, 1, &value );
417
418 { /* Main function body. */
419 #line 945 "xml.fec"
420
421
422 XMLDoc *tree = self->odata;
423 xmlNodeSetContent( tree->node, (xmlChar*)value->data );
424
425 }
426 FE_RETURN_VOID;
427 self = NULL;
428 super = NULL;
429 }
430
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_mergeAsNextSibling_o)431 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_mergeAsNextSibling_o )
432 {
433 FeriteObject *chk;
434 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
435 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
436
437 ferite_get_parameters( params, 1, &chk );
438
439 { /* Main function body. */
440 #line 1153 "xml.fec"
441
442
443 if( chk != NULL )
444 {
445 FeriteVariable *obj = NULL;
446 XMLDoc *tree = self->odata;
447 XMLDoc *chunk = chk->odata;
448 xmlNodePtr ret = NULL;
449
450 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
451 {
452 ret = xmlCopyNode( chunk->node, 1 );
453 if( ret != NULL ) {
454 xmlAddNextSibling(tree->node, ret);
455 recursive_namespace_copy( ret, tree->node->parent );
456 obj = create_element_node( script, tree->doc, ret );
457 FE_RETURN_VAR( obj );
458 }
459 }
460 }
461 FE_RETURN_NULL_OBJECT;
462
463 }
464 FE_RETURN_VOID;
465 self = NULL;
466 super = NULL;
467 }
468
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_setElementName_s)469 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_setElementName_s )
470 {
471 FeriteString *name;
472 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
473 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
474
475 ferite_get_parameters( params, 1, &name );
476
477 { /* Main function body. */
478 #line 933 "xml.fec"
479
480
481 XMLDoc *tree = self->odata;
482 xmlNodeSetName(tree->node, (xmlChar*)name->data);
483
484 }
485 FE_RETURN_VOID;
486 self = NULL;
487 super = NULL;
488 }
489
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getNamespace_)490 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getNamespace_ )
491 {
492 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
493 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
494
495 { /* Main function body. */
496 #line 716 "xml.fec"
497
498
499 FeriteVariable *arr = NULL;
500 XMLDoc *tree = self->odata;
501 int i = 0;
502
503 arr = ferite_create_uarray_variable( script, "NamespaceList", FE_ARRAY_DEFAULT_SIZE, FE_STATIC );
504 if( tree->node->ns != NULL )
505 {
506 FeriteVariable *str = ferite_create_string_variable_from_ptr( script, "URL", (char *)(tree->node->ns->href),
507 0, FE_CHARSET_DEFAULT, FE_STATIC );
508 ferite_uarray_add( script, VAUA( arr ), str, (char *)(tree->node->ns->prefix), FE_ARRAY_ADD_AT_END );
509 }
510 FE_RETURN_VAR( arr );
511
512 }
513 FE_RETURN_VOID;
514 self = NULL;
515 super = NULL;
516 }
517
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getPreviousSibling_)518 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getPreviousSibling_ )
519 {
520 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
521 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
522
523 { /* Main function body. */
524 #line 680 "xml.fec"
525
526
527 XMLDoc *tree = self->odata;
528 if( tree->node->prev )
529 {
530 FeriteVariable *obj = NULL;
531 obj = create_element_node( script, tree->doc, tree->node->prev );
532 FE_RETURN_VAR( obj );
533 }
534 FE_RETURN_NULL_OBJECT;
535
536 }
537 FE_RETURN_VOID;
538 self = NULL;
539 super = NULL;
540 }
541
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getChildren_)542 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getChildren_ )
543 {
544 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
545 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
546
547 { /* Main function body. */
548 #line 603 "xml.fec"
549
550 FeriteVariable *obj;
551 FeriteVariable *array = NULL;
552 xmlNodePtr cur = NULL;
553 XMLDoc *tree = self->odata;
554
555 cur = tree->node->children;
556 array = ferite_create_uarray_variable( script, "Children", FE_ARRAY_DEFAULT_SIZE, FE_STATIC );
557
558 while ( cur ) {
559 obj = create_element_node( script, tree->doc, cur );
560 ferite_uarray_add( script, VAUA( array ), obj, NULL, FE_ARRAY_ADD_AT_END );
561 cur = cur->next;
562 }
563 FE_RETURN_VAR( array );
564
565 }
566 FE_RETURN_VOID;
567 self = NULL;
568 super = NULL;
569 }
570
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_mergeAsSibling_o)571 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_mergeAsSibling_o )
572 {
573 FeriteObject *chk;
574 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
575 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
576
577 ferite_get_parameters( params, 1, &chk );
578
579 { /* Main function body. */
580 #line 1122 "xml.fec"
581
582
583 if( chk != NULL )
584 {
585 FeriteVariable *obj = NULL;
586 XMLDoc *tree = self->odata;
587 XMLDoc *chunk = chk->odata;
588 xmlNodePtr ret = NULL;
589
590 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
591 {
592 ret = xmlCopyNode( chunk->node, 1 );
593 if( ret != NULL ) {
594 xmlAddSibling(tree->node, ret);
595 recursive_namespace_copy( ret, tree->node->parent );
596 obj = create_element_node( script, tree->doc, ret );
597 FE_RETURN_VAR( obj );
598 }
599 }
600 }
601 FE_RETURN_NULL_OBJECT;
602
603 }
604 FE_RETURN_VOID;
605 self = NULL;
606 super = NULL;
607 }
608
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_removeAttribute_s)609 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_removeAttribute_s )
610 {
611 FeriteString *name;
612 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
613 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
614
615 ferite_get_parameters( params, 1, &name );
616
617 { /* Main function body. */
618 #line 978 "xml.fec"
619
620
621 xmlAttrPtr attr = NULL;
622 XMLDoc *tree = self->odata;
623
624 attr = xmlHasProp( tree->node,(xmlChar*)name->data );
625
626 if( attr != NULL ) {
627 xmlUnlinkNode((xmlNodePtr)attr);
628 xmlFreeProp(attr);
629 FE_RETURN_TRUE;
630 }
631 FE_RETURN_FALSE;
632
633 }
634 FE_RETURN_VOID;
635 self = NULL;
636 super = NULL;
637 }
638
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getAttributeByName_s)639 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getAttributeByName_s )
640 {
641 FeriteString *attr;
642 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
643 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
644
645 ferite_get_parameters( params, 1, &attr );
646
647 { /* Main function body. */
648 #line 542 "xml.fec"
649
650 FeriteString *str = NULL;
651 xmlChar *value = NULL;
652 XMLDoc *tree = self->odata;
653
654 value = xmlGetProp( tree->node, (xmlChar*)attr->data );
655 if( value != NULL ) {
656 str = ferite_str_new( (char *)value, 0, FE_CHARSET_DEFAULT );
657 xmlFree( value );
658 }
659 FE_RETURN_STR( str, FE_TRUE );
660
661 }
662 FE_RETURN_VOID;
663 self = NULL;
664 super = NULL;
665 }
666
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_removeChildWithName_s)667 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_removeChildWithName_s )
668 {
669 FeriteString *name;
670 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
671 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
672
673 ferite_get_parameters( params, 1, &name );
674
675 { /* Main function body. */
676 #line 1023 "xml.fec"
677
678
679 XMLDoc *tree = self->odata;
680 xmlNodePtr elem = NULL;
681 int count = 0;
682
683 elem = tree->node->children;
684 while ( elem ) {
685 if(! strncmp( (char*)elem->name, name->data, name->length ) ) {
686 xmlUnlinkNode( elem );
687 count++;
688 }
689 elem = elem->next;
690 }
691 FE_RETURN_LONG( count );
692
693 }
694 FE_RETURN_VOID;
695 self = NULL;
696 super = NULL;
697 }
698
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addCDATASection_s)699 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addCDATASection_s )
700 {
701 FeriteString *cdata;
702 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
703 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
704
705 ferite_get_parameters( params, 1, &cdata );
706
707 { /* Main function body. */
708 #line 890 "xml.fec"
709
710
711 XMLDoc *tree = self->odata;
712 xmlNodePtr node = NULL, ret = NULL;
713
714 node = xmlNewCDataBlock( NULL , (xmlChar*)cdata->data, cdata->length );
715 if( node != NULL ) {
716 ret = xmlAddChild(tree->node, node);
717 recursive_namespace_copy( ret, tree->node );
718 FE_RETURN_TRUE;
719 }
720 FE_RETURN_FALSE;
721
722 }
723 FE_RETURN_VOID;
724 self = NULL;
725 super = NULL;
726 }
727
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getNextSibling_)728 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getNextSibling_ )
729 {
730 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
731 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
732
733 { /* Main function body. */
734 #line 698 "xml.fec"
735
736
737 XMLDoc *tree = self->odata;
738 if( tree->node->next )
739 {
740 FeriteVariable *obj = NULL;
741 obj = create_element_node( script, tree->doc, tree->node->next );
742 FE_RETURN_VAR( obj );
743 }
744 FE_RETURN_NULL_OBJECT;
745
746 }
747 FE_RETURN_VOID;
748 self = NULL;
749 super = NULL;
750 }
751
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_hasChildren_)752 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_hasChildren_ )
753 {
754 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
755 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
756
757 { /* Main function body. */
758 #line 591 "xml.fec"
759
760
761 XMLDoc *tree = self->odata;
762 FE_RETURN_LONG( tree->node->children ? 1 : 0 );
763
764 }
765 FE_RETURN_VOID;
766 self = NULL;
767 super = NULL;
768 }
769
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_destructor_)770 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_destructor_ )
771 {
772 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
773 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
774
775 { /* Main function body. */
776 #line 435 "xml.fec"
777
778
779 XMLDoc *tree = self->odata;
780 if(tree != NULL) ffree(tree);
781
782 }
783 FE_RETURN_VOID;
784 self = NULL;
785 super = NULL;
786 }
787
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_setAttribute_ss)788 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_setAttribute_ss )
789 {
790 FeriteString *name;
791 FeriteString *value;
792 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
793 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
794
795 ferite_get_parameters( params, 2, &name, &value );
796
797 { /* Main function body. */
798 #line 959 "xml.fec"
799
800
801 XMLDoc *tree = self->odata;
802 xmlAttrPtr attr = NULL;
803
804 if( xmlHasProp( tree->node, (xmlChar*)name->data ) ) {
805 xmlSetProp( tree->node, (xmlChar*)name->data, (xmlChar*)value->data );
806 } else {
807 attr = xmlNewProp( tree->node, (xmlChar*)name->data, (xmlChar*)value->data );
808 xmlAddChild( tree->node, (xmlNodePtr)attr );
809 }
810
811 }
812 FE_RETURN_VOID;
813 self = NULL;
814 super = NULL;
815 }
816
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addPI_ss)817 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addPI_ss )
818 {
819 FeriteString *name;
820 FeriteString *value;
821 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
822 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
823
824 ferite_get_parameters( params, 2, &name, &value );
825
826 { /* Main function body. */
827 #line 912 "xml.fec"
828
829
830 XMLDoc *tree = self->odata;
831 xmlNodePtr node = NULL;
832 xmlNodePtr ret = NULL;
833
834 node = xmlNewPI( (xmlChar*)name->data, (xmlChar*)value->data );
835 if( node != NULL ) {
836 ret = xmlAddChild(tree->node, node);
837 recursive_namespace_copy( ret, tree->node );
838 FE_RETURN_TRUE;
839 }
840 FE_RETURN_FALSE;
841
842 }
843 FE_RETURN_VOID;
844 self = NULL;
845 super = NULL;
846 }
847
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addPreviousSibling_ss)848 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addPreviousSibling_ss )
849 {
850 FeriteString *name;
851 FeriteString *data;
852 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
853 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
854
855 ferite_get_parameters( params, 2, &name, &data );
856
857 { /* Main function body. */
858 #line 838 "xml.fec"
859
860 FeriteVariable *obj = NULL;
861 XMLDoc *tree = self->odata;
862 xmlNodePtr node = NULL;
863 xmlNodePtr ret = NULL;
864 xmlChar *value = NULL;
865
866 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
867 {
868 if( data->length )
869 value = (xmlChar*)data->data;
870
871 node = xmlNewDocNode( tree->doc, NULL, (xmlChar*)name->data, value );
872 if( node != NULL ) {
873 node->doc = tree->doc;
874 ret = xmlAddPrevSibling( tree->node, node );
875 recursive_namespace_copy( ret, tree->node->parent );
876 obj = create_element_node( script, tree->doc, ret );
877 FE_RETURN_VAR( obj );
878 }
879 }
880 FE_RETURN_NULL_OBJECT;
881
882 }
883 FE_RETURN_VOID;
884 self = NULL;
885 super = NULL;
886 }
887
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_constructor_)888 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_constructor_ )
889 {
890 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
891 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
892
893 { /* Main function body. */
894 #line 429 "xml.fec"
895
896
897 XMLDoc *tree = fmalloc( sizeof(XMLDoc) );
898 self->odata = tree;
899
900 }
901 FE_RETURN_VOID;
902 self = NULL;
903 super = NULL;
904 }
905
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addChild_ss)906 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addChild_ss )
907 {
908 FeriteString *name;
909 FeriteString *data;
910 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
911 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
912
913 ferite_get_parameters( params, 2, &name, &data );
914
915 { /* Main function body. */
916 #line 742 "xml.fec"
917
918
919 FeriteVariable *obj = NULL;
920 XMLDoc *tree = self->odata;
921 xmlNodePtr node = NULL;
922 xmlNodePtr ret = NULL;
923 xmlChar *value = NULL;
924
925 if( data->length )
926 value = (xmlChar*)data->data;
927
928 node = xmlNewDocNode( tree->doc, NULL, (xmlChar*)name->data, value );
929 if( node != NULL ) {
930 ret = xmlAddChild( tree->node, node );
931 recursive_namespace_copy( ret, tree->node );
932 obj = create_element_node( script, tree->doc, ret );
933 FE_RETURN_VAR( obj );
934 }
935 FE_RETURN_NULL_OBJECT;
936
937 }
938 FE_RETURN_VOID;
939 self = NULL;
940 super = NULL;
941 }
942
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_toString_)943 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_toString_ )
944 {
945 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
946 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
947
948 { /* Main function body. */
949 #line 1213 "xml.fec"
950
951
952 XMLDoc *tree = self->odata;
953 FeriteVariable *v = NULL;
954
955 if( tree->doc )
956 {
957 xmlChar *xmlstring = NULL;
958 xmlNodePtr root = NULL;
959 int len;
960
961 xmlIndentTreeOutput = 1;
962
963 root = xmlDocGetRootElement( tree->doc );
964 xmlDocSetRootElement( tree->doc, tree->node );
965 xmlDocDumpMemoryEnc( tree->doc, &xmlstring, &len, NULL);
966 xmlDocSetRootElement( tree->doc, root );
967
968 v = fe_new_str_static( "xml", (char *)xmlstring, len, FE_CHARSET_DEFAULT );
969 xmlFree( xmlstring );
970 }
971 else
972 v = fe_new_str_static( "xml", "", 0, FE_CHARSET_DEFAULT );
973
974 FE_RETURN_VAR( v );
975
976 }
977 FE_RETURN_VOID;
978 self = NULL;
979 super = NULL;
980 }
981
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_getAttributes_)982 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_getAttributes_ )
983 {
984 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
985 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
986
987 { /* Main function body. */
988 #line 561 "xml.fec"
989
990
991 xmlAttrPtr attr = NULL;
992 xmlChar *key = NULL;
993 FeriteVariable *str = NULL;
994 FeriteVariable *array = NULL;
995 XMLDoc *tree = self->odata;
996
997 attr = tree->node->properties;
998 array = ferite_create_uarray_variable( script, "Attributes", FE_ARRAY_DEFAULT_SIZE, FE_STATIC );
999
1000 while ( attr != NULL ) {
1001 key = xmlGetProp(tree->node, attr->name);
1002
1003 str = ferite_create_string_variable_from_ptr( script, (char *)attr->name, (char *) key,
1004 0, FE_CHARSET_DEFAULT, FE_STATIC );
1005 ferite_uarray_add( script, VAUA( array ), str, (char*)attr->name, FE_ARRAY_ADD_AT_END );
1006 xmlFree( key );
1007
1008 attr = attr->next;
1009 }
1010 FE_RETURN_VAR( array );
1011
1012 }
1013 FE_RETURN_VOID;
1014 self = NULL;
1015 super = NULL;
1016 }
1017
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addComment_s)1018 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addComment_s )
1019 {
1020 FeriteString *comment;
1021 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
1022 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
1023
1024 ferite_get_parameters( params, 1, &comment );
1025
1026 { /* Main function body. */
1027 #line 869 "xml.fec"
1028
1029
1030 XMLDoc *tree = self->odata;
1031 xmlNodePtr node = NULL, ret = NULL;
1032
1033 node = xmlNewComment( (xmlChar*)comment->data );
1034 if( node != NULL ) {
1035 ret = xmlAddChild(tree->node, node);
1036 recursive_namespace_copy( ret, tree->node );
1037 FE_RETURN_TRUE;
1038 }
1039 FE_RETURN_FALSE;
1040
1041 }
1042 FE_RETURN_VOID;
1043 self = NULL;
1044 super = NULL;
1045 }
1046
FE_NATIVE_FUNCTION(ferite_xml_XML_Element_addNextSibling_ss)1047 FE_NATIVE_FUNCTION( ferite_xml_XML_Element_addNextSibling_ss )
1048 {
1049 FeriteString *name;
1050 FeriteString *data;
1051 FeriteObject *self = FE_CONTAINER_TO_OBJECT;
1052 FeriteObject *super = FE_CONTAINER_TO_OBJECT;
1053
1054 ferite_get_parameters( params, 2, &name, &data );
1055
1056 { /* Main function body. */
1057 #line 805 "xml.fec"
1058
1059 FeriteVariable *obj = NULL;
1060 XMLDoc *tree = self->odata;
1061 xmlNodePtr node = NULL;
1062 xmlNodePtr ret = NULL;
1063 xmlChar *value = NULL;
1064
1065 if( (void*)(tree->node->parent) != (void*)(tree->doc) )
1066 {
1067 if( data->length )
1068 value = (xmlChar*)data->data;
1069
1070 node = xmlNewDocNode( tree->doc, NULL, (xmlChar*)name->data, value );
1071 if( node != NULL ) {
1072 node->doc = tree->doc;
1073 ret = xmlAddNextSibling( tree->node, node );
1074 recursive_namespace_copy( ret, tree->node->parent );
1075 obj = create_element_node( script, tree->doc, ret );
1076 FE_RETURN_VAR( obj );
1077 }
1078 }
1079 FE_RETURN_NULL_OBJECT;
1080
1081 }
1082 FE_RETURN_VOID;
1083 self = NULL;
1084 super = NULL;
1085 }
1086
1087