RE: [xsl] losing significant whitespace-only text nodes in mixed content

Subject: RE: [xsl] losing significant whitespace-only text nodes in mixed content
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 15 Sep 2005 12:05:34 +0100
Just don't use MSXML. Every other processor preserves the whitespace
correctly.

If you must use MSXML, there are ways of preserving the whitespace if you
invoke it from an API, rather than through the xml-stylesheet processing
instruction. I forget the magic incantations.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: triangle@xxxxxxxxxxxx [mailto:triangle@xxxxxxxxxxxx] 
> Sent: 15 September 2005 11:44
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; 
> UNEXPECTED_DATA_AFTER_ADDRESS@.SYNTAX-ERROR
> Subject: [xsl] losing significant whitespace-only text nodes 
> in mixed content
> 
> Dear all,
> This is my first post: I've checked Dave Pawson's really 
> useful FAQ, and tested some
> of the theories here, plus I've checked the archive, but I 
> can't find an example of
> mixed content where there is only whitespace between two 
> child elements within the
> mixed content, so I'm resorting to posting to the list.
> 
> This is a simplified version of my input:
> <paragraph> Some text, <xref>Section 8</xref> 
> <bold>must</bold> be captured.</paragraph>
> 
> My problem is preserving the space between </xref> and <bold>.
> 
> I need to flatten the hierarchy within my mixed content as 
> the notion of mixed
> content does not exist in the destination (XML) app, so by 
> wrapping each text() node
> in an arbitrary <atom> tag I create:
> <paragraph>
>   <atom>Some text, </atom>
>   <xref>Section 8</xref>
>   <bold>must</bold>
>   <atom> be captured.</atom>
> </paragraph>
> 
> My problem is that I've lost a significant whitespace 
> character because it is the
> only content that appears between the <xref> and the <bold> 
> elements. When this
> renders I am left with "Section8must". I should pass through:
> 
> <paragraph>
>   <atom>Some text, </atom>
>   <xref>Section 8</xref>
>   <atom> </atom> <!-- maybe I need to translate this space to 
> an character entity too -->
>   <bold>must</bold>
>   <atom> be captured.</atom>
> </paragraph>
> 
> I have over-simplified this, but I've tried 
> <xsl:preserve-space> but that preserves
> leading and trailing spaces and converts CRs into whitespace, 
> and "normalize-space()"
> removes the leading space in " be captured", as well as not 
> preserving my significant
> whitespace either.
> 
> Does anyone have any ideas please?
> 
> Thanks in advance
> Francis
> 
> 
> --------------------------------------------------------------
> Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
> http://www.boltblue.com

Current Thread