Implement document fragment parsing.
Introduce a notable behavior change in default parsing mode: documents without a document element node are now considered invalid. This is technically a breaking change, however the amount of documents it affects is very small, all parsed data still persists, and lack of this check results in very confusing behavior in a number of cases. In order to be able to parse documents without an element node, a fragment parsing flag is introduced. Parsing a buffer in fragment mode treats the buffer as a fragment of a valid XML. As a consequence, top-level PCDATA is added to the tree; additionally, there are no restrictions on the number of nodes -- so documents without a document element are considered valid. Due to the way parsing works internally, load_buffer_inplace occasionally can not preserve the document contents if it's parsed in a fragment mode. While unfortunate, this problem is fundamental; since the use case is relatively obscure, hopefully documenting this shortcoming will be enough. git-svn-id: https://pugixml.googlecode.com/svn/trunk@980 99668b35-9821-0410-8761-19e4c4f06640
Showing
- src/pugixml.cpp 60 additions, 18 deletionssrc/pugixml.cpp
- src/pugixml.hpp 7 additions, 1 deletionsrc/pugixml.hpp
- tests/test_document.cpp 100 additions, 35 deletionstests/test_document.cpp
- tests/test_dom_modify.cpp 17 additions, 0 deletionstests/test_dom_modify.cpp
- tests/test_memory.cpp 1 addition, 1 deletiontests/test_memory.cpp
- tests/test_parse.cpp 163 additions, 31 deletionstests/test_parse.cpp
- tests/test_parse_doctype.cpp 8 additions, 8 deletionstests/test_parse_doctype.cpp
- tests/test_write.cpp 7 additions, 8 deletionstests/test_write.cpp
Loading
Please register or sign in to comment