Re: Pretty printing XML

On Thu, 28 Oct 1999, Jelks Cabaniss wrote:

> I tried the Oct. 22 Tidy on this snippet to check it's XML
> "pretty printing" capabilities:
> 
> 	<doc>
> 	<fee><fi><fo><foo>foo stuff</foo></fo></fi></fee>
> 	</doc>
> 
> Here are the relevant config options, followed by Tidy's output:
> 
> 	input-xml: yes
> 	output-xml: yes
> 	indent: auto
> 	add-xml-pi: no
> 	new-inline-tags: foo
> 	new-blocklevel-tags: doc, fee, fi, fo
> 
> 	<doc>
> 	  <fee>
> 	    <fi>
> 	      <fo>
> 	        <foo>
> 	          foo stuff
> 	        </foo>
> 	      </fo>
> 	    </fi>
> 	  </fee>
> 	</doc>
> 
> Shouldn't it be:
> 
> 	<doc>
> 	  <fee>
> 	    <fi>
> 	      <fo><foo>foo stuff</foo></fo>
> 	    </fi>
> 	  </fee>
> 	</doc>
> 

That would make sense, yes. When Tidy sees that the input is in XML
it doesn't bother with the tag dictionary. It uses PPrintXMLTree
rather than PPrintTree for pretty printing. It should be easy enough
to get PPrintXMLTree to check the dictionary though. Note that it
would then "know" that p should always be treated in this way, which
may not be the right thing to do.

Regards,

-- Dave Raggett <dsr@w3.org> http://www.w3.org/People/Raggett
tel/fax: +44 122 578 3011 (or 2521) +44 385 320 444 (mobile)
World Wide Web Consortium (on assignment from HP Labs)

Received on Wednesday, 10 November 1999 14:50:54 UTC