Comments (5)
It's not particularly hard to do x.toDOM().toprettyxml()
but yeah, I can see this might be worthwhile. I'll take a look after I deal with #26, but might not get to it for a while.
six.py: I didn't modify that line so you'd have to ask the authors, but it's probably just a leftover from it being a docstring in the past.
structures.py: fix queued. Thanks.
from pyxb.
I second that toprettyxml()
would be nice to have!
from pyxb.
After considering this carefully I'm going to decline the enhancement. The problem is that the existing toxml()
method combines arguments meant to control the conversion of the PyXB instance to a DOM structure, and to control the conversion of the DOM structure to XML text. It has only one argument that affects the DOM-to-XML step, and is essentially mandatory, so fits naturally as the first argument with the instance-to-DOM arguments which are rarely used following it.
In contrast toprettyxml()
introduces two additional options specific to the DOM-to-XML phase, and places them before the mandatory encoding
argument, which would make correct usage difficult when instance-to-DOM arguments are needed.
In short, at this point I sorta regret adding toxml()
as a short-hand in the first place, so am sticking to my original response that x.toDOM().toprettyxml()
is the recommended path.
from pyxb.
Maybe one could add an optional argument to toxml()
as in pretty=False
instead or that'd be problematic in some other way? Just wondering if you have also considered that...
from pyxb.
@zyv In fact, that's exactly how I started. But then, for pretty=True
to be fully useful, I'd have to also add the indent
and newl
arguments which as I noted are in an inconsistent order relative to the existing encoding
argument so they'd have to be keyword arguments too as there are already four parameters to toxml()
. At that point I noticed that both functions are only available in minidom and PyXB isn't supposed to be restricted to a particular DOM implementation.
So trying to graft it in just got too messy: the best solution IMO is to convert to DOM, then use the native functions provided by the DOM implementation.
from pyxb.
Related Issues (20)
- Simple content with fixed value and attributes are not handled properly HOT 2
- Preserve XSD annotations in bindings HOT 1
- AnyContent not definable
- "List index out of range" using bindings built by pyxbgen HOT 1
- Invalid XML can be generated with extension elements HOT 2
- "all" allows multiple occurrences of the same term HOT 1
- NamespaceUniquenessError in elementDeclaration HOT 3
- Marshalling of restricted dateTime ignores restriction pattern HOT 3
- Install without pre-defined bundles? HOT 2
- Support of Python 3.7+ HOT 3
- Support of Python 3.8. HOT 7
- UnboundElementError when trying to subclass HOT 3
- SimpleTypeValueError when trying createfromdocument for MD_Metadata
- XInclude processing HOT 3
- creating an instance of a union does not name the actual type in the resulting exception
- Multiple accepting paths for xs:any ##other element
- validateBinding, toDOM and toxml raise AbstractElementError on unpickled pyxb object with abstract element/substitutionGroup
- Test suite does not work HOT 2
- Running setup.py install for pyxb … error
- test_gYearMonth.Test_gYearMonth.testBasic and test_date.Test_date.testArguments fails, test_gMonthDay.Test_gMonthDay.testBasic errors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyxb.