You guess right. But so far, I had to start programlisting contents and
the like at the very first column of my XML source, which indeed spoiled
readability tremendously. If there is a solution to keep XML source
indentation and yet have indentation in the transformed result relative
to the first source line, I would greatly appreciate to hear about it, too.
Patrick
Gabor Hojtsy schrieb:
>>>The normalize-space() function in XSL removes leading
>>>and trailing spaces, and replaces internal sequences
>>>of whitespace with a single space character.
>>
>>If its many elements, then an identity transform with
>><xsl:strip-space elements="*"/>
>>does the same job.
>>Replace * with as many elements as needed
>>or use...
>><xsl:preserve-space elements="pre"/> or whatever.
>>Can be used in combination.
>
>
> This does not solve our problems. Here is a fragment:
>
> <programlisting role="php">
> <![CDATA[
> <html>
> <head>
> <title>PHP Test</title>
> </head>
> <body>
> <?php echo "<p>Hello World</p>"; ?>
> </body>
> </html>
> ]]>
> </programlisting>
>
> This will effectively output a code with the leading spaces (the newlines
> after the programlisting tag and after the <![CDATA[ tag) present, and with
> the trailing newlines also present. We would not like to put the <![CDATA[
> and the programlisting and the first line of the example on the same line to
> avoid this, for readability reasons. But we would not like to get those
> newlines on the output.
>
> <xsl:strip-space> is to strip whitespace-only text nodes, AFAIK, which is not
> the case here. normalize-space() will remove any multiple spaces, which will
> highly distract the formatting of the example above. So none of these are
> solutions. As I said, we would like to strip of the leading and trailing
> spaces, and nothing else. Others, using <programlisting> must have been faced
> the same problem, I guess...