简体   繁体   中英

Combine lxml XSLT pretty_print with strip-space

I'm cleaning up some gross XML, and so I've had pretty_print = True set in the call to etree.tostring() on my lxml output of the XSL transform. However, that left me with a few junk whitespace nodes from the original input, so I added

<xsl:strip-space elements="*"/>

...but that completely collapses all whitespace, ignoring pretty print. Is there an easy way to make strip-space just apply to the input, and still get lxml to apply pretty print?

Do it in two steps? First strip the spaces, then pretty-print?

Just a thought.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM