Re: [xsl] xsl:output/@indent="yes" and *[@xml:space="preserve"]

Subject: Re: [xsl] xsl:output/@indent="yes" and *[@xml:space="preserve"]
From: Tobias Reif <tobiasreif@xxxxxxxxxxxxx>
Date: Wed, 05 Feb 2003 15:29:08 +0100
David Carlisle wrote:

I also would like to specify pretty-printing for the whole output doc (indent="yes"), but disallow it for the contents of a set of elements.

your wish is granted:
As the original poster and Michael correctly commented (and I
incorrectly forgot) You can suppress the effects of indent="yes"
by setting xml:space="preserve" on selected elements in the output.
(Modulo the fact that it doesn't work in saxon at the moment, hence this

That's what I'm doing all over my XSLTs, but it gets quirky in some situations: I'm generating "HTML compatible" XHTML, where I don't want to have xml:space attrs. Sometimes that's no problem because it can be set on an enclosing XSLT element, but that also brings problems (xsl:attribute after a preserved ws only node).

If I could specify that all is to be indented except a list of elements, then I would have to write much less code, and not worry too much about ws in the output anymore.

Whitespace is complex; there are the input, transformation, and output documents, the XML spec, the XSLT spec, etc. If the result of all this is fed to browsers ranging from very old to current, then stuff gets quirky.
In my current project most stuff is solved, but two issues remain which are not show-stopping ones (everything works as it should, but):
* the XSLT code could be cleaner
* the pretty-printing could be way prettier (it's turned off for now)
I need to learn more about ways to achieve what I want, but a simple solution giving me all this in one or two lines (eg xsl:indent-all-but elements="") would sure be welcome. Perhaps I'm missing an existing solution.

And since I'm working with Saxon, so I'm also looking forward to a fixed release.



XSL-List info and archive:

Current Thread