Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pretty-print functionality #2

Merged
merged 3 commits into from
May 10, 2014
Merged

added pretty-print functionality #2

merged 3 commits into from
May 10, 2014

Conversation

dirvens
Copy link
Contributor

@dirvens dirvens commented May 8, 2014

Added pretty-print functions so that in addition to the XmlWritable
toString, an indented "pretty-print" version of an XmlDocument could be
created. Allows the user to change the indent string.

Added pretty-print functions so that in addition to the XmlWritable
toString, an indented "pretty-print" version of an XmlDocument could be
created. Allows the user to change the indent string.
/**
* Write the this object in a 'pretty' format to a `buffer`.
*/
void prettyWriteTo(StringBuffer buffer, {String indent: ''});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a default implementation that delegates to 'writeTo' could avoid most overrides of this method. Alternatively the existing method with a named argument could maybe be reused?

@renggli
Copy link
Owner

renggli commented May 8, 2014

I've added some comments. Generally I'd like all functionally to be fully tested.

Also I am wondering how much automatic pretty printing XML is making sense at all? Doesn't that completely change the tree definition? It definitely does so for XHTML.

Added the ability to output a formatted XML document tree, with
indentation and newlines, when outputting children and siblings,
respectively.

As is the case with all 'pretty-print' capabilities of other libraries,
the document tree output is not the same. The resultant text if parsed
will have a tree that will contain more/less XmlText nodes than the
original tree.
Conflicts:
	lib/xml/nodes/branch.dart
	lib/xml/nodes/cdata.dart
	lib/xml/nodes/comment.dart
	lib/xml/nodes/doctype.dart
	lib/xml/nodes/element.dart
	lib/xml/nodes/processing.dart
	lib/xml/utils/writable.dart
@dirvens
Copy link
Contributor Author

dirvens commented May 9, 2014

I incorporated changes for most of the comments/suggestions you made. Had some issues with git not syncing up correctly; hence commit (673ce52) and a "merge branch" commit. However, the changes are all there, and have been tested with both XML data using the XmlBuilder, as well as real XML data.

As far as the pretty print not making sense - almost every useful XML library out there has that capability. I've used libraries in Flex, Python, Java, and C++ (both Xerces and Poco), and they all have it. So IMHO, that is necessary functionality if a XML library is to be maximally useful. You are correct in that it can/will change the tree definition; however, that is a well-known, usually acceptable side-effect. Having whitespace-only text nodes in most XML documents is usually ok; and the rendering/using application will often filter those out.

renggli added a commit that referenced this pull request May 10, 2014
added pretty-print functionality
@renggli renggli merged commit b68a39a into renggli:master May 10, 2014
@renggli
Copy link
Owner

renggli commented May 10, 2014

Thank you for the contribution I've merged it.

modulovalue added a commit to modulovalue/dart-xml that referenced this pull request Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants