00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "xml/xmlimpl.hpp"
00030 #include "xml/miscxml.hpp"
00031 #include "xml/parsexml.hpp"
00032 #include "xml/mngxml.hpp"
00033 #include "xml/storexml.hpp"
00034 #include "xml/declxml.hpp"
00035 #include "xml/sxml.hpp"
00036 #include "xml/sxs.hpp"
00037 #include "xml/persxml.h"
00038 #include "xml/dtdxml.h"
00039
00040 #include "base/common.hpp"
00041 #include "base/memory.hpp"
00042 #include "base/list.hpp"
00043 #include "base/map.hpp"
00044 #include "base/stack.hpp"
00045 #include "base/template.hpp"
00046 #include "base/keymaker.hpp"
00047 #include "base/string.hpp"
00048
00049 #include "ossock.h"
00050
00052 xml_factory::xml_factory()
00053 {
00054
00055 _sockStartup();
00056 }
00057
00058 xml_factory::~xml_factory()
00059 {
00060 _sockCleanup();
00061 }
00062
00063 xml_designer*
00064 xml_factory::get_xml_designer(size_t xml_size)
00065 {
00066 return new terimber::xml_designer_impl(xml_size);
00067 }
00068
00069 BEGIN_TERIMBER_NAMESPACE
00070 #pragma pack(4)
00071
00073 xml_designer_impl::xml_designer_impl(size_t block_size) :
00074 _xml_size(block_size <= os_def_size ? os_def_size : big_xml_size), _doc(_small_manager, _big_manager, block_size <= os_def_size ? os_def_size : big_xml_size, 0)
00075 {
00076 _cur_node = &_doc;
00077 _tmp_allocator = _small_manager.loan_object();
00078 }
00079
00080
00081 xml_designer_impl::~xml_designer_impl()
00082 {
00083 _small_manager.return_object(_tmp_allocator);
00084 }
00085
00086
00087 bool
00088 xml_designer_impl::load(const char* name, const char* grammar)
00089 {
00090 byte_source* in_xml = 0;
00091 byte_source* in_grammar = 0;
00092
00093 stream_input_common stream_xml(_small_manager, _big_manager, _xml_size, false);
00094 if (name && name[0])
00095 {
00096 xml_stream_attribute attr(name, true);
00097 if (!stream_xml.open(attr))
00098 {
00099 _error = "Can't open file ";
00100 _error += name;
00101 return false;
00102 }
00103
00104 in_xml = &stream_xml;
00105 }
00106
00107 stream_input_common stream_grammar(_small_manager, _big_manager, 0, false);
00108 if (grammar && grammar[0])
00109 {
00110 xml_stream_attribute attr(grammar, true);
00111 if (!stream_grammar.open(attr))
00112 {
00113 _error = "Can't open file ";
00114 _error += grammar;
00115 return false;
00116 }
00117
00118 in_grammar = &stream_grammar;
00119 }
00120
00121 return _load(in_xml, in_grammar);
00122 }
00123
00124 bool
00125 xml_designer_impl::load(const void* name, size_t length, const char* grammar)
00126 {
00127 byte_source* in_xml = 0;
00128 byte_source* in_grammar = 0;
00129
00130 stream_input_memory stream_xml((const ub1_t*)name, length, _small_manager, _big_manager, _xml_size, false);
00131 if (name && length)
00132 in_xml = &stream_xml;
00133
00134 stream_input_common stream_grammar(_small_manager, _big_manager, 0, false);
00135 if (grammar && grammar[0])
00136 {
00137 xml_stream_attribute attr(grammar, true);
00138 if (!stream_grammar.open(attr))
00139 {
00140 _error = "Can't open file ";
00141 _error += grammar;
00142 return false;
00143 }
00144
00145 in_grammar = &stream_grammar;
00146 }
00147
00148 return _load(in_xml, in_grammar);
00149 }
00150 bool
00151 xml_designer_impl::load(const char* name, const void* grammar, size_t grammar_length)
00152 {
00153 byte_source* in_xml = 0;
00154 byte_source* in_grammar = 0;
00155
00156 stream_input_common stream_xml(_small_manager, _big_manager, _xml_size, false);
00157 if (name && name[0])
00158 {
00159 xml_stream_attribute attr(name, true);
00160 if (!stream_xml.open(attr))
00161 {
00162 _error = "Can't open file ";
00163 _error += name;
00164 return false;
00165 }
00166
00167 in_xml = &stream_xml;
00168 }
00169
00170 stream_input_memory stream_grammar((const ub1_t*)grammar, grammar_length, _small_manager, _big_manager, 0, false);
00171 if (grammar && grammar_length)
00172 in_grammar = &stream_grammar;
00173
00174 return _load(in_xml, in_grammar);
00175 }
00176
00177 bool
00178 xml_designer_impl::load(const void* name, size_t length, const void* grammar, size_t grammar_length)
00179 {
00180 byte_source* in_xml = 0;
00181 byte_source* in_grammar = 0;
00182
00183 stream_input_memory stream_xml((const ub1_t*)name, length, _small_manager, _big_manager, _xml_size, false);
00184 if (name && length)
00185 in_xml = &stream_xml;
00186
00187 stream_input_memory stream_grammar((const ub1_t*)grammar, grammar_length, _small_manager, _big_manager, 0, false);
00188 if (grammar && grammar_length)
00189 in_grammar = &stream_grammar;
00190
00191 return _load(in_xml, in_grammar);
00192 }
00193
00194 const char*
00195 xml_designer_impl::error() const
00196 {
00197 return _error;
00198 }
00199
00200
00201 void
00202 xml_designer_impl::select_document() const
00203 {
00204 _cur_node = const_cast< xml_document* >(&_doc);
00205 }
00206
00207
00208 bool
00209 xml_designer_impl::select_root() const
00210 {
00211
00212 if (!_doc.get_root_element()._decl)
00213 return false;
00214
00215 _cur_node = const_cast< xml_element* >(&_doc.get_root_element());
00216 return true;
00217 }
00218
00219
00220 bool
00221 xml_designer_impl::has_children() const
00222 {
00223 return is_container() && xml_container::cast_to_container(_cur_node)->has_children();
00224 }
00225
00226 bool
00227 xml_designer_impl::select_first_child() const
00228 {
00229 if (!has_children())
00230 return false;
00231
00232 _cur_node = xml_container::cast_to_container(_cur_node)->_first_child;
00233 return true;
00234 }
00235
00236 bool
00237 xml_designer_impl::select_last_child() const
00238 {
00239 if (!has_children())
00240 return false;
00241
00242 _cur_node = xml_container::cast_to_container(_cur_node)->_last_child;
00243 return true;
00244 }
00245
00246
00247 bool
00248 xml_designer_impl::select_next_sibling() const
00249 {
00250 if (!_cur_node->_right)
00251 return false;
00252
00253 _cur_node = _cur_node->_right;
00254 return true;
00255 }
00256
00257
00258 bool
00259 xml_designer_impl::select_prev_sibling() const
00260 {
00261 if (!_cur_node->_left)
00262 return false;
00263
00264 _cur_node = _cur_node->_left;
00265 return true;
00266 }
00267
00268
00269 bool
00270 xml_designer_impl::select_parent() const
00271 {
00272 if (!_cur_node->_parent)
00273 return false;
00274
00275 _cur_node = _cur_node->_parent;
00276 return true;
00277 }
00278
00279
00280 bool
00281 xml_designer_impl::has_attributes() const
00282 {
00283 return is_element() && xml_element::cast_to_element(_cur_node)->has_attributes();
00284 }
00285
00286
00287 bool
00288 xml_designer_impl::select_first_attribute() const
00289 {
00290 if (!has_attributes())
00291 return false;
00292
00293 _cur_node = xml_element::cast_to_element(_cur_node)->_first_attr;
00294 return true;
00295 }
00296
00297 bool
00298 xml_designer_impl::select_last_attribute() const
00299 {
00300 if (!has_attributes())
00301 return false;
00302
00303 _cur_node = xml_element::cast_to_element(_cur_node)->_last_attr;
00304 return true;
00305 }
00306
00307 bool
00308 xml_designer_impl::select_attribute_by_name(const char* name) const
00309 {
00310 if (!has_attributes())
00311 return false;
00312
00313
00314 const namedNodeDecl* decl = _doc.find_attribute_decl(*xml_element::cast_to_element(_cur_node)->cast_decl(), name);
00315 if (!decl)
00316 return false;
00317 for (xml_tree_node* attr = xml_element::cast_to_element(_cur_node)->_first_attr; attr; attr = attr->_right)
00318 if (attr->_decl == decl)
00319 {
00320 _cur_node = attr;
00321 return true;
00322 }
00323
00324 return false;
00325 }
00326
00327
00328 xmlNodeType
00329 xml_designer_impl::get_type() const
00330 {
00331 return get_cur_type();
00332 }
00333
00334 const char*
00335 xml_designer_impl::get_name() const
00336 {
00337 switch (get_cur_type())
00338 {
00339 case DOCUMENT_NODE:
00340 case DOCUMENT_TYPE_NODE:
00341 return _doc.get_doc_name();
00342 case ELEMENT_NODE:
00343 case ATTRIBUTE_NODE:
00344 case PROCESSING_INSTRUCTION_NODE:
00345 return _cur_node->_decl->_name;
00346 default:
00347 return 0;
00348 }
00349 }
00350
00351 const char*
00352 xml_designer_impl::get_value() const
00353 {
00354 _tmp_allocator->reset();
00355 switch (get_cur_type())
00356 {
00357 case ATTRIBUTE_NODE:
00358
00359 return _cur_node->cast_to_attribute()->persist_attribute(xml_value_node::cast_to_node_value(_cur_node)->_value, _tmp_allocator);
00360 case TEXT_NODE:
00361 case PROCESSING_INSTRUCTION_NODE:
00362 case CDATA_SECTION_NODE:
00363 case COMMENT_NODE:
00364 return persist_value(vt_string, xml_value_node::cast_to_node_value(_cur_node)->_value, _tmp_allocator);
00365 default:
00366 return 0;
00367 }
00368 }
00369
00370
00371
00372
00373
00374
00375 const char*
00376 xml_designer_impl::get_xpath() const
00377 {
00378 if (!is_element())
00379 return 0;
00380
00381 _tmp_allocator->reset();
00382 _list< const string_t* > tmp_store;
00383 const xml_tree_node* node = _cur_node;
00384 const xml_tree_node* doc = &_doc;
00385
00386 while (node != doc)
00387 {
00388 tmp_store.push_front(*_tmp_allocator, &node->_decl->_name);
00389 node = node->_parent;
00390 }
00391
00392
00393 size_t len = 0;
00394 for (_list< const string_t* >::const_iterator iter = tmp_store.begin(); iter != tmp_store.end(); ++iter)
00395 len += (len ? 1 : 0) + (*iter)->length();
00396
00397
00398 char* dest = (char*)_tmp_allocator->allocate(len + 1);
00399 dest[len] = 0;
00400 size_t shift = 0;
00401 for (_list< const string_t* >::const_iterator iter1 = tmp_store.begin(); iter1 != tmp_store.end(); ++iter1)
00402 {
00403 if (shift)
00404 dest[shift++] = ch_forward_slash;
00405
00406 memcpy(dest + shift, (const char*)**iter1, (*iter1)->length());
00407 shift += (*iter1)->length();
00408 }
00409
00410 return dest;
00411 }
00412
00413
00414
00415 bool
00416 xml_designer_impl::select_xpath(const char* path) const
00417 {
00418 if (!path)
00419 return false;
00420
00421 _tmp_allocator->reset();
00422
00423 _list< const elementDecl* > tmp_store;
00424 const char* path_ = path;
00425 string_t tmp_name(0, _tmp_allocator);
00426 size_t length = 0;
00427 const elementDecl* decl = 0;
00428 xml_tree_node* node = 0;
00429
00430 while (*path_)
00431 {
00432 if (*path_ == ch_forward_slash || *path_ == ch_back_slash)
00433 {
00434 tmp_name.assign(path, length);
00435 decl = _doc.find_element_decl(tmp_name);
00436 if (!decl)
00437 {
00438 _error = "Can't find element ";
00439 _error += tmp_name;
00440 return false;
00441 }
00442
00443 tmp_store.push_back(*_tmp_allocator, decl);
00444 path += length + 1;
00445 path_ = path;
00446 length = 0;
00447 }
00448 else
00449 ++length, ++path_;
00450 }
00451
00452 if (length)
00453 {
00454 tmp_name.assign(path, length);
00455 decl = _doc.find_element_decl(tmp_name);
00456 if (!decl)
00457 {
00458 _error = "Can't find element ";
00459 _error += tmp_name;
00460 return false;
00461 }
00462
00463 tmp_store.push_back(*_tmp_allocator, decl);
00464 }
00465
00466
00467 node = _cur_node;
00468 if (!tmp_store.empty() && node->_decl != tmp_store.front())
00469 {
00470 _error = "Invalid path";
00471 return false;
00472 }
00473
00474 tmp_store.pop_front();
00475 while (!tmp_store.empty())
00476 {
00477
00478 for (node = static_cast< const xml_element* >(node)->_first_child; node; node = node->_right)
00479 {
00480 if (node->_decl->get_type() != ELEMENT_NODE)
00481 continue;
00482
00483 if (node->_decl == tmp_store.front())
00484 break;
00485 }
00486
00487 if (!node)
00488 {
00489 _error = "Invalid path";
00490 return false;
00491 }
00492
00493 tmp_store.pop_front();
00494 }
00495
00496
00497
00498 _cur_node = node;
00499 return true;
00500 }
00501
00502 bool
00503 xml_designer_impl::save(const char* name, bool add_doc_type) const
00504 {
00505 stream_output_file stream(_small_manager, _big_manager, _xml_size);
00506 if (!stream.open(name))
00507 {
00508 _error = "Can't open file ";
00509 _error += name;
00510 return false;
00511 }
00512
00513
00514 xml_persistor pr(stream, _doc, _small_manager, _big_manager, false, add_doc_type, _xml_size);
00515 if (!pr.persist())
00516 {
00517 stream.close();
00518 _error = pr.get_error();
00519 return false;
00520 }
00521
00522 stream.close();
00523 return true;
00524 }
00525
00526 bool
00527 xml_designer_impl::save(void* buffer, size_t& length, bool add_doc_type) const
00528 {
00529 memory_output_stream stream(_small_manager, _big_manager, _xml_size, (ub1_t*)buffer, length);
00530
00531 xml_persistor pr(stream, _doc, _small_manager, _big_manager, false, add_doc_type, _xml_size);
00532 if (!pr.persist() || stream.is_overflow())
00533 {
00534 _error = pr.get_error();
00535 length = stream.get_required_size();
00536 return false;
00537 }
00538
00539
00540 size_t length_ = length;
00541 length = stream.get_required_size();
00542
00543 return length_ >= length;
00544 }
00545
00546
00547
00548
00549
00550 bool
00551 xml_designer_impl::add_child(xmlNodeType type, const char* name, const char* value, bool dont_move)
00552 {
00553 return _import_node(type, name, value, false, false, dont_move);
00554 }
00555
00556 bool
00557 xml_designer_impl::insert_sibling(xmlNodeType type, const char* name, const char* value, bool dont_move)
00558 {
00559 return _import_node(type, name, value, true, false, dont_move);
00560 }
00561
00562 bool
00563 xml_designer_impl::append_sibling(xmlNodeType type, const char* name, const char* value, bool dont_move)
00564 {
00565 return _import_node(type, name, value, true, true, dont_move);
00566 }
00567
00568 bool
00569 xml_designer_impl::remove_node()
00570 {
00571
00572 switch (_cur_node->_decl->get_type())
00573 {
00574 case DOCUMENT_NODE:
00575 case DOCUMENT_TYPE_NODE:
00576
00577 _error = "Can't remove specified node";
00578 return false;
00579 case ATTRIBUTE_NODE:
00580 _cur_node = xml_element::cast_to_element(_cur_node->_parent)->remove_attribute(_cur_node);
00581 break;
00582 case ELEMENT_NODE:
00583
00584 if (_cur_node->_parent->_decl == _doc._decl)
00585
00586 _doc.clear_root();
00587
00588
00589 _cur_node = xml_container::cast_to_container(_cur_node->_parent)->remove_node(_cur_node);
00590 break;
00591 default:
00592 _cur_node = xml_container::cast_to_container(_cur_node->_parent)->remove_node(_cur_node);
00593 break;
00594 }
00595 return true;
00596 }
00597
00598
00599
00600
00601 bool
00602 xml_designer_impl::update_value(const char* value)
00603 {
00604 try
00605 {
00606 switch (_cur_node->_decl->get_type())
00607 {
00608 case ATTRIBUTE_NODE:
00609 _doc.update_attribute(xml_element::cast_to_element(_cur_node->_parent), xml_value_node::cast_to_node_value(_cur_node), value);
00610 break;
00611 case PROCESSING_INSTRUCTION_NODE:
00612 case TEXT_NODE:
00613 case CDATA_SECTION_NODE:
00614 case COMMENT_NODE:
00615 xml_value_node::cast_to_node_value(_cur_node)->_value.strVal = copy_string(value, _doc.get_data_allocator(), os_minus_one);
00616 break;
00617 default:
00618 _error = "Specified type is not supported";
00619 return false;
00620 }
00621 }
00622 catch (exception& x)
00623 {
00624 _error = x.what();
00625 return false;
00626 }
00627
00628 return true;
00629 }
00630
00631
00632 bool
00633 xml_designer_impl::merge(const xml_designer* nav, bool recursive)
00634 {
00635 switch (_cur_node->_decl->get_type())
00636 {
00637 case DOCUMENT_NODE:
00638
00639
00640 if (_doc.get_root_element()._decl)
00641 {
00642 _error = "The final document would have two root elements";
00643 return false;
00644 }
00645
00646
00647 if (nav->get_type() != ELEMENT_NODE)
00648 {
00649 _error = "Only element type is allowed when current documet is empty";
00650 return false;
00651 }
00652
00653 case ELEMENT_NODE:
00654
00655
00656 if (!add_child(nav->get_type(), nav->get_name(), nav->get_value(), false))
00657 return false;
00658
00659
00660 if (nav->get_type() == ELEMENT_NODE)
00661 {
00662
00663 if (nav->select_first_attribute())
00664 {
00665
00666 do
00667 {
00668
00669 if (!add_child(nav->get_type(), nav->get_name(), nav->get_value(), true))
00670 return false;
00671
00672
00673
00674
00675
00676 }
00677 while (nav->select_next_sibling());
00678
00679
00680
00681
00682 nav->select_parent();
00683
00684 }
00685
00686
00687 if (recursive && nav->select_first_child())
00688 {
00689
00690 do
00691 {
00692
00693 if (!merge(nav, true))
00694 return false;
00695
00696 }
00697 while (nav->select_next_sibling());
00698
00699
00700
00701 nav->select_parent();
00702
00703
00704
00705 }
00706 }
00707
00708
00709 select_parent();
00710
00711 break;
00712 default:
00713 _error = "Specified type is not supported";
00714 return false;
00715 };
00716
00717 return true;
00718 }
00719
00720
00721
00722
00723 bool
00724 xml_designer_impl::validate(bool recursive)
00725 {
00726 if (!is_element())
00727 {
00728 _error = "Only element can be validated";
00729 return false;
00730 }
00731
00732 try
00733 {
00734 _validate(xml_element::cast_to_element(_cur_node), recursive);
00735 }
00736 catch (exception& x)
00737 {
00738 _error = x.what();
00739 return false;
00740 }
00741
00742 return true;
00743 }
00744
00746 void
00747 xml_designer_impl::_validate(xml_element* el, bool recursive)
00748 {
00749
00750 _doc.validate(*el);
00751
00752 if (recursive)
00753 {
00754 for (xml_tree_node* child = el->_first_child; child; child = child->_right)
00755 if (child->_decl->get_type() != ELEMENT_NODE)
00756 continue;
00757 else
00758 _validate(xml_element::cast_to_element(child), recursive);
00759 }
00760 }
00761
00762 bool
00763 xml_designer_impl::_import_node(xmlNodeType type, const char* name, const char* value, bool sibling, bool after, bool dont_move)
00764 {
00765
00766
00767
00768 if (sibling && _cur_node->_decl->get_type() == DOCUMENT_NODE)
00769 {
00770 _error = "Document node can't have siblings";
00771 return false;
00772 }
00773
00774
00775 xml_tree_node* save_cur_node = _cur_node;
00776
00777 xmlNodeType xmltype = sibling ? _cur_node->_parent->_decl->get_type() : _cur_node->_decl->get_type();
00778 xml_tree_node* cur_node = sibling ? _cur_node->_parent : _cur_node;
00779 xml_tree_node* cur_sibling = sibling ? _cur_node : 0;
00780 char* dest = 0;
00781
00782 try
00783 {
00784 switch (type)
00785 {
00786 case DOCUMENT_NODE:
00787 case DOCUMENT_TYPE_NODE:
00788
00789 return false;
00790 case ELEMENT_NODE:
00791 switch (xmltype)
00792 {
00793 case DOCUMENT_NODE:
00794
00795 _cur_node = _doc.add_element(name, cur_sibling, after);
00796 return true;
00797 case ELEMENT_NODE:
00798 _doc.container_push(static_cast< xml_element* >(cur_node));
00799 _cur_node = _doc.add_element(name, cur_sibling, after);
00800 break;
00801 default:
00802 if (sibling)
00803 {
00804 _doc.container_push(static_cast< xml_element* >(cur_node));
00805 _cur_node = _doc.add_element(name, cur_sibling, after);
00806 }
00807 else
00808 {
00809 _error = "Specified type is not supported";
00810 return false;
00811 }
00812 break;
00813 }
00814 break;
00815 case ATTRIBUTE_NODE:
00816 if (xmltype != ELEMENT_NODE)
00817 {
00818 _error = "Attribute node is allowed only beneath element";
00819 return false;
00820 }
00821 _doc.container_push(static_cast< xml_element* >(cur_node));
00822 _cur_node = _doc.add_attribute(*static_cast< xml_element* >(cur_node), name, value, cur_sibling, after);
00823 break;
00824 case TEXT_NODE:
00825 if (xmltype != ELEMENT_NODE)
00826 {
00827 _error = "Text node is allowed only beneath element";
00828 return false;
00829 }
00830 _doc.container_push(static_cast< xml_element* >(cur_node));
00831 _cur_node = _doc.add_text(value, cur_sibling, after);
00832 break;
00833 case CDATA_SECTION_NODE:
00834 if (xmltype != ELEMENT_NODE)
00835 {
00836 _error = "Cdata section node is allowed only beneath element";
00837 return false;
00838 }
00839
00840 _doc.container_push(static_cast< xml_element* >(cur_node));
00841 _cur_node = _doc.add_cdata(value, cur_sibling, after);
00842 break;
00843 case PROCESSING_INSTRUCTION_NODE:
00844 if (xmltype != ELEMENT_NODE && xmltype != DOCUMENT_NODE)
00845 {
00846 _error = "Processing instruction node is allowed either beneath element or document node";
00847 return false;
00848 }
00849 _doc.container_push(static_cast< xml_element* >(cur_node));
00850 _cur_node = _doc.add_pi(name, value, cur_sibling, after);
00851 break;
00852 case COMMENT_NODE:
00853 if (xmltype != ELEMENT_NODE && xmltype != DOCUMENT_NODE)
00854 {
00855 _error = "Comment node is allowed either beneath element or document node";
00856 return false;
00857 }
00858 _doc.container_push(static_cast< xml_element* >(cur_node));
00859 _cur_node = _doc.add_comment(value, cur_sibling, after);
00860 break;
00861 default:
00862 assert(false);
00863 _error = "Specified type is not supported";
00864 return false;
00865 }
00866 }
00867 catch (exception& x)
00868 {
00869 _doc.container_pop();
00870 _error = x.what();
00871 return false;
00872 }
00873
00874 _doc.container_pop();
00875
00876 if (dont_move)
00877 _cur_node = save_cur_node;
00878
00879 return true;
00880 }
00881
00882 bool
00883 xml_designer_impl::_load(byte_source* stream, byte_source* grammar)
00884 {
00885 _doc.clear();
00886 _doc.add_escaped_symbols();
00887 _cur_node = &_doc;
00888
00889 if (grammar)
00890 {
00891
00892 dtd_processor dtd(*grammar, _doc, _small_manager, _big_manager, 0);
00893 try
00894 {
00895 _doc.container_start_doctype();
00896 dtd.parse();
00897 _doc.container_stop_doctype();
00898 }
00899 catch (exception& x)
00900 {
00901 _doc.clear();
00902 _doc.add_escaped_symbols();
00903 _error = x.what();
00904 return false;
00905 }
00906 }
00907
00908 if (stream)
00909 {
00910 xml_processor pr(*stream, _doc, _small_manager, _big_manager, _xml_size, false);
00911 if (!pr.parse())
00912 {
00913 _doc.clear();
00914 _doc.add_escaped_symbols();
00915 _error = pr.get_error();
00916 return false;
00917 }
00918 }
00919
00920 return true;
00921 }
00922
00923
00925 xml_parser_creator::xml_parser_creator()
00926 {
00927 }
00928
00929 xml_designer*
00930 xml_parser_creator::create(size_t n)
00931 {
00932 return _factory.get_xml_designer(n);
00933 }
00934
00935 void
00936 xml_parser_creator::destroy(xml_designer* obj)
00937 {
00938 if (obj)
00939 delete obj;
00940 }
00941
00943
00944 xml_designer*
00945 xml_designer_creator::create(size_t size)
00946 {
00947 xml_factory acc;
00948 return acc.get_xml_designer(size);
00949 }
00950
00951
00952 void
00953 xml_designer_creator::activate(xml_designer* obj, size_t)
00954 {
00955 obj->load(0, 0, 0, 0);
00956 }
00957
00958
00959 #pragma pack()
00960 END_TERIMBER_NAMESPACE
00961
00962