views:

66

answers:

1

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?

+2  A: 

Modify the xsl:output element to indicate you want HTML output and indenting:

<xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
markusk