Re: how to make "well-formated" xml file from xslt
> I concur with this as in a practical scenario, the new-line > character is especially troublesome, not worth the pain it creates > across multi-platform and multi-project systems. I would say if you > want to see a well indented output copy the response onto an editor > and use their auto indent feature or just view it off the IE. > But could you clarify as to what your requirement is. > > Regards > > AmitGhaste At the risk of incurring the wrath of those who really don't think XML should ever be reformatted, I'll point out that the xmlformat tool allows you to reformat XML, with control over where whitespace can or cannot be injected. (It also doesn't change entity references, but that's another issue.) http://www.kitebird.com/software/xmlformat/ > -----Original Message----- > From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] > Sent: Friday, February 27, 2004 7:31 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: how to make "well-formated" xml file from > xslt > > At 2004-02-27 03:50 -0800, Ha Nguyen wrote: > >I write an xslt file to transform an xml to another > >xml file. > > The processor is obliged to serialize the result tree without any > "formatting" ... that is, it is supposed to put out only as many > text > characters as there are characters in text nodes. The "formatting" > inside > of tags is arbitrary. > > >The output xml file is ugly i.e every tag > >are aligned at the same level. > >Ex: > ><Diagram> > ><Graph> > ><Node> > >.... > ></Node> > ></Graph> > ></Diagram> > > Sounds like your transform must be inserting some newlines of some > kind ... > I would have expected: > > <Diagram><Graph><Node>....</Node></Graph></Diagram> > > >How to make it look like "normal" xml file ? > > My teenage daughter has a saying "'normal' is a setting on a dryer" > ... I > don't believe there is such a thing as a "normal xml file" just as > there is > no such thing as a "normal teenager". > > Did you mean "an indented XML file"? > > <Diagram> > <Graph> > <Node> > .... > </Node> > </Graph> > </Diagram> > > This is not at all "normal" as it has arbitrary whitespace injected > into > the document at places where you may or may not expect. > > It happens that XSLT offers implementers the option of supporting > indentation when the user requests indentation using: > > <xsl:output indent="yes"/> > > However ... there are no guidelines for the indentation and a > processor can > do whatever it wants when you ask. The processor is even allowed to > do > what you see already: start every element on a new line. > > I counsel my students to only ever use indentation for diagnostics > and > never for production work because you have no idea what whitespace > is being > added to your document to achieve the indentation and you may > corrupt > downstream processes. > > I hope this helps. > > ...................... Ken > > -- > US XSL training: Washington,DC March 15; San Francisco,CA March 22 > World-wide on-site corporate, government & user group XML training > G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx > Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ > Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) > Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format