Re: Indenting XML

On Fri, 21 Apr 2000, Mike Depot wrote:

> I realize XML support isn't all there yet, but I've got a simple
> situation that I was hoping tidy would help with.  All I'm
> looking for is to indent a simple (well-formed but not valid)
> xml file.  I'm using this config:
> 
> indent: yes
> input-xml: yes
> output-xml: yes
> new-blocklevel-tags: DATABASE, TABLE
> new-inline-tags: FIELD
> 
> and here's a sample of the xml:
> 
> <?xml version="1.0" standalone="yes"?>
> <DATABASE VERSION='1.0'>
> Database definition here.
> <TABLE NAME="table1">
> Table definition here.
> <FIELD NAME="field1" TYPE="INTEGER">
> Field 1 Description
> </FIELD>
> <FIELD NAME="field2" TYPE="CHAR(50)">
> Field 2 Description
> </FIELD>
> </TABLE>
> </DATABASE>
> 
> After running tidy, I still don't get the indenting.

The reason is that your content model for each of the elements
appears to be mixed. This inference is made when text occurs as
the immediate child of an element. Tidy won't indent the content
for elements with mixed content.

Perhaps this rule is too harsh? Another possibility would be
indent all element content for indent: yes and to apply the
current rule only for indent: auto

What do people think?

Regards,

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

Received on Friday, 21 April 2000 12:48:42 UTC