Link to home
Start Free TrialLog in
Avatar of kmartin7
kmartin7Flag for United States of America

asked on

normalize-space for entire document?

Does anyone have an idea how to use normalize-space for an entire document? I have a mixutre of element and mixed nodes, and keeping the mixed nodes proper has been difficult.

TIA
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="elements go here space seperated"/>

tends to work, in the preserve space you could put the mixed content elements, for whom space preservation is important
that ofcourse doesn't normalize the whitespace inside PCDATA streams
note that msxml and xml spy do the wrong thing with whitespace only text nodes

or you could make a multi-pass, with the second pass being an identity transform that normalize-spaces every text node
in XSLT2, you can easily add both passes inone stylesheet
(or you could do that using node-set() if your processor supports that)
Avatar of kmartin7

ASKER

Hi Geert,

For some reason, I have never been able to get that to work. I have tried it on different parsers with the same result each time. Here is a snippet. As you can see, we would like to remove all that extra space for the authors.

Thanks.
<para>Text and more text (
      
        
          
          
          <xref type="figure" idref="i0f3a011"></xref>) text and more text:
    
      
        
        
        </para>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah, it doesn't quite give us what we need. It is just a bad having all collapse. We are just going to use SS with the editor options and then run a series of find/replace to add spaces before and after certain instances.

Thanks anyway.

Kurt