XSl: whitespaces

I need to make sure that the whitespaces of my inline XML elements have the whitespaces around them, and not inside them :

some text <i>text in italic</i> some text 

and not

some text<i> text in italic </i>some text or some text<i> text in italic</i> some text or some text <i>text in italic </i> some text 

And that some elements (paragraphes, titles) do not have whitespaces after the opening tag or before the closing tag:

<p>some text</p> 

and not

<p> some text</p><!--or--> <p> some text </p><!--or--> <p> some text</p> 

I tried xsl:strip-space on the following XML:

<book> <appendix>     <title>T<pc>itre</pc></title>     <subtitle> <i> some text </i> </subtitle>     <dev>     <sect1>     <title>R<pc>ésumé </pc></title>     <p> some text</p>         <sect2>             <title>S<pc>ome text</pc></title>             <p> some text </p>             <p> some text</p>         </sect2> </sect1> </dev> </appendix> 

but I do not quite understand how it works (on some elements it seems to work and not on others – works for subtitles but not for p-s with <xsl:strip-space elements="*"/>). And I know it would not solve my problem with inline elements. Is there any way to do this in XSLT ? I can see how I could find the spaces in inline elements with regex but not how to place them outside the element afterwards.

Thank you. Maria

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.