pretty-print

Sort xml attributes for pretty print using javax.xml.transform.Transformer

旧街凉风 提交于 2019-12-01 08:28:46
问题 Is there a way I could tell the xml transformer to sort alphabetically all the attributes for the tags of a given XML? So lets say... <MyTag paramter1="lol" andTheOtherThing="potato"/> Would turn into <MyTag andTheOtherThing="potato" paramter1="lol"/> I saw how to format it from the examples I found here and here, but sorting the tag attributes would be the last issue I have. I was hoping there was something like: transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer

Cxx-prettyprint (for standard containers) defines its output operators inside namespace std - is this a standard violation?

为君一笑 提交于 2019-12-01 08:19:28
问题 I have been successfully using cxx-prettyprint: A C++ Container Pretty-Printer to log container values. (See also Pretty-print C++ STL containers) It's working like a charm on our VS-2005 (VC8) compiler. (with the prettyprint98.hpp header) While studying its interoperability with Boost.Format, I found to my surprise that it simply works out of the box, when other questions suggest it shouldn't because ADL should fail for a user provided output operator. Looking into the cxx-pp header I found

gdb python api: is it possible to make a call to a class/struct method

馋奶兔 提交于 2019-12-01 04:45:36
问题 In Python, I have a a variable var of type gdb.Value that corresponds to a C++ struct. The struct has a method void foo() . I can evaluate this expression var['foo'] . But var['foo']\() will complain saying RuntimeError: Value is not callable (not TYPE_CODE_FUNC) I believe the value type will be gdb.TYPE_CODE_METHOD (not sure, but var['foo'].type.code returns 16 ) in my case. So I guess the question is: Does python API support calls to class methods, and if not, is there a workaround? Thanks!

GDB pretty printing ImportError: No module named 'printers'

强颜欢笑 提交于 2019-12-01 02:02:03
问题 I'm trying to add pretty printing for STL in my GDB on Ubuntu 14.04. Some details on the tools: OS: Ubuntu 14.04 gdb version: 7.7 python version: 2.7.6 python3 version: 3.4.0 But after I setup exactly as what the instruction said. I still get the following errors: Traceback (most recent call last): File "<string>", line 3, in <module> File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/__init__.py", line 19, in <module> from printers import register_libstdcxx_printers ImportError: No

Pretty printing math in C# desktop application

Deadly 提交于 2019-11-30 20:46:53
What is the best method of printing math equations in a C# (winforms) desktop application? The format for the source is not important; I can generate almost anything with a little effort. What is important is that it should be relatively high performance and low overhead (I know, I'm only supposed to pick 2 of { performance, size, features } but I want all 3.) Things I have considered: LaTeX via System.Process() -> dvipng. Problem: even a minimal LaTeX instal is about 200 MB. Considering that my app is currently ~400k I think this is a bit excessive. Some sort of JS-based math rendering

How do I pretty-print JSON in Delphi?

假装没事ソ 提交于 2019-11-30 13:49:43
I am looking for a function that will take a string of JSON as input and format it with line breaks and indentations (tabs). Example: I have input line: {"menu": {"header": "JSON viewer", "items": [{"id": "Delphi"},{"id": "Pascal", "label": "Nice tree format"}, null]}} And want to get a readable result as text: { "menu":{ "header":"JSON viewer", "items":[ { "id":"Delphi" }, { "id":"Pascal", "label":"Nice tree format" }, null ] } } I found a lot of examples for PHP and C#, but not for Delphi. Could someone help with such a function? Update - Solution with SuperObject: function FormatJson

How do I pretty-print existing JSON data with Java? [closed]

孤街浪徒 提交于 2019-11-30 10:47:02
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 months ago . I have a compact JSON string, and I want to format it nicely in Java without having to deserialize it first -- e.g. just like jsonlint.org does it. Are there any libraries out there that provides this? A similar solution for XML would also be nice. 回答1: I think for pretty-printing something, it's very helpful

MSXML from C++ - pretty print / indent newly created documents

雨燕双飞 提交于 2019-11-30 09:52:59
I'm writing out XML files using the MSXML parser, with a wrapper I downloaded from here: http://www.codeproject.com/KB/XML/JW_CXml.aspx . Works great except that when I create a new document from code (so not load from file and modify), the result is all in one big line. I'd like elements to be indented nicely so that I can read it easily in a text editor. Googling shows many people with the same question - asked around 2001 or so. Replies usually say 'apply an XSL transformation' or 'add your own whitespace nodes'. Especially the last one makes me go %( so I'm hoping that in 2008 there's an

Empty lines while using minidom.toprettyxml

穿精又带淫゛_ 提交于 2019-11-30 08:35:53
I've been using a minidom.toprettyxml for prettify my xml file. When I'm creating XML file and using this method, all works grate, but if I use it after I've modified the xml file (for examp I've added an additional nodes) and then I'm writing it back to XML, I'm getting empty lines, each time I'm updating it, I'm getting more and more empty lines... my code : file.write(prettify(xmlRoot)) def prettify(elem): rough_string = xml.tostring(elem, 'utf-8') //xml as ElementTree reparsed = mini.parseString(rough_string) //mini as minidom return reparsed.toprettyxml(indent=" ") and the result : <?xml

pprint(): how to use double quotes to display strings?

徘徊边缘 提交于 2019-11-30 08:06:33
问题 If I print a dictionary using pprint, it always wraps strings around single quotes ( ' ): >>> from pprint import pprint >>> pprint({'AAA': 1, 'BBB': 2, 'CCC': 3}) {'AAA': 1, 'BBB': 2, 'CCC': 3} Is there any way to tell pprint to use double quotes ( " ) instead? I would like to have the following behaviour: >>> from pprint import pprint >>> pprint({'AAA': 1, 'BBB': 2, 'CCC': 3}) {"AAA": 1, "BBB": 2, "CCC": 3} 回答1: It looks like you are trying to produce JSON; if so, use the json module: >>>