0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

33 Commits

Author SHA1 Message Date
Arseny Kapoulkine
2e0ed8284b Remove extra space in an empty tag for format_raw
When using format_raw the space in the empty tag (<node />) is the only
character that does not have to be there; so format_raw almost results in
a minimal XML but not quite.

It's pretty unlikely that this is crucial for any users - the formatting
change should be benign, and it's better to improve format_raw than to add
yet another flag.

Fixes #87.
2016-04-14 00:30:24 -07:00
Arseny Kapoulkine
2a3435274f Refactor format_indent_attributes implementation
Fix code style and revert redundant parameters/whitespace changes.

Also remove format_each_attribute_on_new_line - we're only introducing one
extra formatting flag. The flag implies format_indent but does not include its
bitmask.

Also add a few more tests.

Fixes #14.
2015-04-13 21:49:08 -07:00
halex2005
5d66ae9fb9 add tests for aligning each attribute on next line 2015-04-14 00:56:42 +05:00
Arseny Kapoulkine
3da7d68617 Fix Travis CI build. 2015-04-11 22:52:41 -07:00
Arseny Kapoulkine
37467c13bf tests: Add a test for throwing from xml_writer::write
We currently don't allocate/modify any state so there are no issues with this.
2015-04-11 22:44:42 -07:00
Arseny Kapoulkine
ce974094ac tests: Fix test compilation
Rename PAGE_SIZE to page_size to avoid define conflict with Android SDK.
Minor fixes in several tests.
2015-03-21 00:14:53 -07:00
Arseny Kapoulkine
86410cd696 tests: Fix tests in wchar mode 2015-03-18 21:30:30 -07:00
Arseny Kapoulkine
5f996eba6d Do not emit surrounding whitespace for text nodes
Previously we omitted extra whitespace for single PCDATA/CDATA children, but in
mixed content there was extra indentation before/after text nodes.

One of the problems with that is that the text that you saved is not exactly
the same as the parsing result using default flags (parse_trim_pcdata helps).

Another problem is that parse-format cycles do not have a fixed point for mixed
content - the result expands indefinitely. Some XML libraries, like Python
minidom, have the same issue, but this is definitely a problem.

Pretty-printing mixed content is hard. It seems that the only other sensible
choice is to switch mixed content nodes to raw formatting. In a way the code in
this change is a weaker version of that - it removes indentation around text
nodes but still keeps it around element siblings/children.

Thus we can switch to mixed-raw formatting at some point later, which will be
a superset of the current behavior.

To do this we have to either switch at the first text node (.NET XmlDocument
does that), or scan the children of each element for a possible text node and
switch before we output the first child.

The former behavior seems non-intuitive (and a bit broken); unfortunately, the
latter behavior can cost up to 20% of the output time for trees *without* mixed
content.

Fixes #13.
2015-03-18 09:59:17 -07:00
Arseny Kapoulkine
604861e520 Escape ?> sequence in PI value during printing
This prevents malformed PI value from breaking the document structure.
2015-03-10 09:03:22 -07:00
Arseny Kapoulkine
650a4c6cca Use string::append in implementations of xml_writer
The current code is not optimal; since users actually read samples/tests
change them to use faster (and shorter!) code.
2015-01-24 08:20:42 -08:00
Arseny Kapoulkine
e9956ae3a6 Rename xml_document::load to load_string
This should completely eliminate the confusion between load and load_file.
Of course, for compatibility reasons we have to preserve the old variant -
it will be deprecated in a future version and subsequently removed.
2014-11-17 19:52:23 -08:00
Arseny Kapoulkine
6229138d80 Optimize node printing by using raw pointers
This lets us do fewer null pointer checks (making printing 2% faster with -O3)
and removes a lot of function calls (making printing 20% faster with -O0).
2014-10-27 22:29:14 -07:00
Arseny Kapoulkine
87d4f03187 tests: Add a test for printing comments that contain --
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1059 99668b35-9821-0410-8761-19e4c4f06640
2014-10-14 04:11:26 +00:00
Arseny Kapoulkine
f3b220ca4e tests: Fix MSVC6 compilation
Also fixes PUGIXML_NO_STL compilation and makes it possible to build with
any version of new Windows SDK.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1044 99668b35-9821-0410-8761-19e4c4f06640
2014-10-03 02:40:11 +00:00
Arseny Kapoulkine
53550424d9 tests: Fix PUGIXML_WCHAR_MODE build
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1017 99668b35-9821-0410-8761-19e4c4f06640
2014-09-21 21:52:24 +00:00
Arseny Kapoulkine
27109cd626 tests: Add test for custom indentation strings
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1016 99668b35-9821-0410-8761-19e4c4f06640
2014-09-21 21:52:19 +00:00
Arseny Kapoulkine
3abba14e72 tests: Add a test for stackless write.
This test previously caused a stack overflow on x86/MSVC.

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1015 99668b35-9821-0410-8761-19e4c4f06640
2014-09-21 21:52:13 +00:00
Arseny Kapoulkine
47c15ad949 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
2014-02-11 06:45:27 +00:00
arseny.kapoulkine@gmail.com
04629118db tests: Android compilation fixes
git-svn-id: http://pugixml.googlecode.com/svn/trunk@846 99668b35-9821-0410-8761-19e4c4f06640
2012-03-06 08:49:58 +00:00
arseny.kapoulkine@gmail.com
fdc03d39ab tests: Fixed compilation errors for BadaSDK
git-svn-id: http://pugixml.googlecode.com/svn/trunk@839 99668b35-9821-0410-8761-19e4c4f06640
2012-03-06 06:13:10 +00:00
arseny.kapoulkine
a0769dfe38 Introduced encoding_latin1 support (conversion on loading, conversion on saving, encoding name in declaration in document::save)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@829 99668b35-9821-0410-8761-19e4c4f06640
2011-12-20 09:45:10 +00:00
arseny.kapoulkine
7757503d72 Added format_no_escapes flag
git-svn-id: http://pugixml.googlecode.com/svn/trunk@819 99668b35-9821-0410-8761-19e4c4f06640
2011-09-10 03:05:29 +00:00
arseny.kapoulkine
a18385e1e0 If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@770 99668b35-9821-0410-8761-19e4c4f06640
2010-10-19 15:38:10 +00:00
arseny.kapoulkine
630be2edb3 tests: Added node_doctype and parse_doctype tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@757 99668b35-9821-0410-8761-19e4c4f06640
2010-09-26 19:01:36 +00:00
arseny.kapoulkine
4f6ecee14c tests: More miscellaneous tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@619 99668b35-9821-0410-8761-19e4c4f06640
2010-08-02 20:16:53 +00:00
arseny.kapoulkine
6b69701cdd tests: Added more CDATA writing tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@617 99668b35-9821-0410-8761-19e4c4f06640
2010-07-22 13:13:31 +00:00
arseny.kapoulkine
7d24b9b565 Set svn:eol-style to native for all text files
git-svn-id: http://pugixml.googlecode.com/svn/trunk@607 99668b35-9821-0410-8761-19e4c4f06640
2010-07-19 09:57:32 +00:00
arseny.kapoulkine
97a761615f tests: Extended wchar_t mode tests (broken UTF16 test, some tests were erroneously utf8-only), added final Xalan tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@475 99668b35-9821-0410-8761-19e4c4f06640
2010-05-30 20:17:05 +00:00
arseny.kapoulkine
7c01cf8df3 Nodes/attributes with empty names now are printed as :anonymous
git-svn-id: http://pugixml.googlecode.com/svn/trunk@441 99668b35-9821-0410-8761-19e4c4f06640
2010-05-21 05:50:53 +00:00
arseny.kapoulkine
f542c5ebb8 Integrated changes from unicode branch to trunk
git-svn-id: http://pugixml.googlecode.com/svn/trunk@383 99668b35-9821-0410-8761-19e4c4f06640
2010-05-06 20:28:36 +00:00
arseny.kapoulkine
fc602fd375 tests: Supported all pugixml compilation modes
git-svn-id: http://pugixml.googlecode.com/svn/trunk@191 99668b35-9821-0410-8761-19e4c4f06640
2009-10-29 07:17:30 +00:00
arseny.kapoulkine
c026597234 tests: Added more tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@162 99668b35-9821-0410-8761-19e4c4f06640
2009-10-20 20:25:35 +00:00
arseny.kapoulkine
80d778d053 tests: Refactored checking macros, added writing tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@152 99668b35-9821-0410-8761-19e4c4f06640
2009-10-12 16:26:18 +00:00