XML Pretty Printer Missing 2 Key Edge Cases
Posted
by viatropos
on Stack Overflow
See other posts from Stack Overflow
or by viatropos
Published on 2010-04-12T07:32:10Z
Indexed on
2010/04/12
7:43 UTC
Read the original article
Hit count: 327
Using this xslt file found on this blog to pretty print xml using Nokogiri, everything almost works, but to the point where I can't use it for HTML.
First, if a node is empty, it turns it into a self closing node, so:
<textarea></textarea>
gets converted to
<textarea/>
But that messes up the html tree when rendered.
Second, if the node just has text, the text isn't tabbed, and the closing node isn't tabbed, so:
<li>
<label>some text</label>
</li>
becomes:
<li>
<label>some text
</label>
</li>
...but it would ideally be:
<li>
<label>
some text
</label>
</li>
Does anyone who's pro at XSLT know a quick fix for this?
© Stack Overflow or respective owner