Viola!

After several attempts at several different methods I found the most simplest solution with a combination of your last suggestion and something I found in a article somewhere else.

What happens is that the processor will strip all nodes containing only whitespace (chars in the set {0x09, 0x0a, 0x0d, 0x20}), as excepted so nothing new here..... What we need to do is preserve them and then properly translate them from 	 etc. to their unescaped equivalents. Again nothing new here but how do we achieve this when there are several methods that do not work?  With a pipelines similar to the below:

<map:generate type="serverpages" src=""/>
<map:transform src="">
         <map:parameter name="assetsCacheServer" value="{config:assetsCacheServer}"/>
         <map:parameter name="resourceCacheServer" value="{config:resourceCacheServer}"/>
         <map:parameter name="area" value="{page-envelope:area}"/>
         <map:parameter name="root" value="{request:contextPath}/{page-envelope:publication-id}/{page-envelope:area}"/>
</map:transform>
<map:transform src=""/>
<map:serialize type="xhtml"/>

So, there a 2 things that need to be done. (please refer to my first post for all lib versions)

1. The first stylesheet (xslt/lenya-dyn/wiredmag2xhtml.xsl) transforms our generated xml.  It contains the proper style of indentation we desire.  In the xsl root node *you need to declare* xml:space="preserve" like so:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XML/Transform
  xml:space="preserve">
.....

2. The second style sheet prepares our output for the front ends.  The thing you need to do here is *define a template that properly escapes your whitespace chars*.  Otherwise you'll end up with tons of &#9;'s and extra newlines where you don't want them

<xsl:template match="text()">
        <xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:template>
<xsl:template match="comment()">
        <xsl:copy/>
</xsl:template>

Thats it.  In the above solution you do not need to "turn on" indentation or make a styleheet that does the indentation for you but simply make sure that whitespace is preserved during transformation and then properly unescapsed by another stylesheet before being serialized.


HTH,
-Justin


Joerg Heinicke wrote:
On 24.04.2006 17:18, Justin Hannus wrote:

These are all the things I've read in several different places and tried several times with not luck :-(
1. <xsl:output> does not work.
2. <?cocoon-format?> pi's did not work or were just too hard to configure for indenting with little or no documentation.

It's known that these both don't work.

3. Adding <indent>yes</indent> to XMLSerializer config does not do anything.

That one should work in general. But from my experience you never get a really nicely indented XML from just setting this option. The only thing working is IMO setting it to <indent>no</indent> and to write a format.xsl doing the indentation (i.e. handling white spaces), which is not that complicated.

Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 

Justin Hannus
Software Engineer | Infrastructure | Lycos Inc.
[EMAIL PROTECTED], www.lycos.com
[781] 370 2988


Reply via email to