{ "info": { "author": "P. Andreas Moeller", "author_email": "kontakt@pamoller.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Topic :: Text Processing :: Markup :: XML" ], "description": "============\nxmlformatter\n============\n\n`xmlformatter `_ is an Open Source Python package, which provides formatting of XML documents. *It is the replacement for the Python 2 package XmlFormatter, which has been removed from PyPi completely (see Notes)*. xmlformatter differs from others formatters by *handling whitespaces by a distinct set of formatting rules* - formatting element content by a object style and mixed content by a text style. You may find xmlformatter useful for corrections and presentations. In addition xmlformatter comes with a wrapper script named xmlformat.\n\n================\nFormatting Rules\n================\n\nxmlformatter treats the element content from the following example as a object. The elements are associated with containers, like complex, or properties names, like real and imaginary. Text nodes are associated with property values, like 4.4E+12. Leading and trailing whitespaces are meaningless in this scenario like sequences of whitespaces. Leading and trailing whitespaces will be remove, sequences of whitespaces will be collapsed.\n\n::\n\n \n 4.4E+12\n 5.4E-11\n \n \n\nThe element content from the example above can be formatted by xmlformat:\n\n::\n\n $ xmlformat ele.xml\n\nThe following output shows the formatted XML document. xmlformatter has removed leading and trailing whitespaces from the text nodes and has indented the child elements equal. This formatting style is called object style.\n\n::\n\n \n 4.4E+12\n 5.4E-11\n \n\nxmlformatter treats the mixed content from the following example as a literal text with some markup. The outer element enclose poem encloses the text. The inline element em gives a text snippet a special meaning. Leading and trailing whitespaces enclosed by inline elements are misplaced. They will be adopted by the previous or following text node. Note: xmlformatter may insert a text node if necessary. Even sequences of whitespaces will be collapsed:\n\n::\n\n Es war einmal und ist nicht mehr...\n\nThe following output shows the formatted XML document. xmlfromatter has removed leading and trailing whitespaces and has collapsed sequences of whitespaces. This formatting style is called text style.\n\n::\n\n Es war einmal und ist nicht mehr...\n\nBoth styles are used while formatting a XML document. The formatting rules are: \n\nA: Surrounding whitespaces are removed from element content. \n\nB: Leading whitespaces are removed from element content. \n\nC: Trailing whitespaces are removed from element content. \n\nD: Leading whitespaces of inline elements are put to preceding text (or inserted) if necessary within mixed content. \n\nE: Trailing whitespaces of inline elements are put to following text (or inserted) if necessary within mixed content. \n\nF: Sequences of whitespaces (n>2) are replaced by a single blank \" \" within element and mixed content. \n\nG: Linebreak and whitespace are used to indent elements within elements content.\n\nThe following example shows the described whitespaces by their labels within a XML document:\n\n::\n\n AAAA\n AAAABBBB4.4E+12CCCAAAA\n AAAABBBBEsDDDDwar einmal und istEEEEnicht mehrF\n FFFFein riesengro\u00dferDDDDTeddyb\u00e4r,F \n der a\u00dfFFFFdie MilchEEEEund trank das BrotFFFF\n und als er starb da war erEEEEtot.CCCCAAAA\n \n\nThe following output shows the formatted XML document:\n\n::\n\n \n 4.4E+12\n Es war einmal und ist nicht mehr ein riesengro\u00dfer Teddyb\u00e4r, der a\u00df die Milchund trank das Brot und als er starb da war er tot.\n \n\n=====\nClass\n=====\n\n::\n\n class xmlformatter.Formatter(compress ::= False, indent ::= 2, indent_char ::= \" \", inline ::= True, encoding_input ::= None, encoding_output ::= None, preserve ::= [ ])\n\nThe Formatter class can be used to format XML documents in scripts. By default all parts of the XML document will formatted. All descendants of elements listed by preserve are left unformatted. Setting the boolean property compress to True suppresses the indenting given by the indent and indent_char properties. Without a value given to encoding_input xmlformatter trys to determine the encoding from the XML document. On failure it use UTF-8 as default. encoding_output advises xmlformatter to encode the output explicit by the given value. Otherwise xmlformatter use the inpurt encoding. Setting the boolean property inline to False suppresses inline formatting. By default element content will be formatted everywhere - also within mixed content. The following example shows the usage of the xmlfromatter class:\n\n::\n\n import xmlformatter\n \n formatter = xmlformatter.Formatter(indent=\"1\", indent_char=\"\\t\", encoding_output=\"ISO-8859-1\", preserve=[\"literal\"])\n formatter.format_file(\"/home/pa/doc.xml\")\n\nThe example formats the XML document in /home/pa/doc.xml, preserving the element literal, indenting by the tab character and output in ISO-8859-1 encoding.\n\n=======\nMembers\n=======\n\n::\n\n compress ::= False\n\nMinify the XML document.\n\n::\n\n correct ::= True\n\nApply formatting rules to whitespaces.\n\n::\n\n indent ::= 2\n\nIndent a child element in element content n-times by indent_char.\n\n::\n\n indent_char ::= \" \"\n\nIndent a child element by this string.\n\n::\n\n input_encoding ::= None\n\nAssume the XML document encoded by a not None value.\n\n::\n\n output_encoding ::= None\n\nEncode the formatted XML document by a not None value.\n\n::\n\n preserve ::= [ ]\n\nSkip formatting for all elements listed in preserve and all their descendants.\n\n=======\nMethods\n=======\n\n::\n\n format_file(path)\n\nFormat a XML document given by a path.\n\n::\n\n format_string(xmldoc)\n\nFormat a XML document given by a string.\n\n===\nCmd\n===\n\n::\n\n xmlformat [--preserve \"pre,literal\"] [--compress] [--indent num] [--indent-char char]\n [--outfile file] [--encoding enc] [--outencoding enc] [--disable-inlineformatting] \n [--dispable-correction] [--help] < --infile file | file | - >\n\nxmlformat can read from STDIN, like:\n\n::\n\n $ cat /home/pa/doc.xml | xmlformat -\n\n=====\nNotes\n=====\n\nRemove XmlFormatter before installing xmlformatter:\n\n::\n\n $ pip uninstall XmlFormatter\n\nAfter reinstallation replace the string \"formatter.formatter\" by \"formatter\", \"preserving\" by \"preserve\" and \"indentChar\" by \"indent_char\" inside your scripts carefully. To reach compatibility with XmlFormatter call xmlformat with --disable-inlineformatting or use inline=False in your scripts.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pamoller.com/xmlformatter.html", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "xmlformatter", "package_url": "https://pypi.org/project/xmlformatter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/xmlformatter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pamoller.com/xmlformatter.html" }, "release_url": "https://pypi.org/project/xmlformatter/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Format and compress XML documents", "version": "0.1.1" }, "last_serial": 985315, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a8d343583b543cdb20fb073d04184e14", "sha256": "3fa7ce1c43834ebaafb0a6d2f3df08a638bb85d32c15224fd9958296f1f95edd" }, "downloads": -1, "filename": "xmlformatter-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a8d343583b543cdb20fb073d04184e14", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14133, "upload_time": "2014-01-28T18:58:25", "url": "https://files.pythonhosted.org/packages/a3/f7/e54251d55ae1d742d8ecb10420ee91bbbf1b0d6c6fe867ea9a7385935ce2/xmlformatter-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "af5cd269580026a460105e532082975d", "sha256": "1897b8c7868860d4b02c450d2f208391cb6f18bf60102ab0d89703b3088280e2" }, "downloads": -1, "filename": "xmlformatter-0.1.1.tar.gz", "has_sig": false, "md5_digest": "af5cd269580026a460105e532082975d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14146, "upload_time": "2014-01-29T16:52:23", "url": "https://files.pythonhosted.org/packages/ba/c6/6f958639e34957aa986041b4e474bbbf5135eeb59dcb788e41719175d48c/xmlformatter-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af5cd269580026a460105e532082975d", "sha256": "1897b8c7868860d4b02c450d2f208391cb6f18bf60102ab0d89703b3088280e2" }, "downloads": -1, "filename": "xmlformatter-0.1.1.tar.gz", "has_sig": false, "md5_digest": "af5cd269580026a460105e532082975d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14146, "upload_time": "2014-01-29T16:52:23", "url": "https://files.pythonhosted.org/packages/ba/c6/6f958639e34957aa986041b4e474bbbf5135eeb59dcb788e41719175d48c/xmlformatter-0.1.1.tar.gz" } ] }