[oXygen-user] Whitespace-only text nodes in XSLT

Jirka Kosek
Fri Jun 26 01:41:45 CDT 2015


On 26.6.2015 5:49, George Bina wrote:
> I think that is removed by step 3 in
> http://www.w3.org/TR/xslt20/#stylesheet-stripping

Exactly. One has to keep in mind that rules for whitespace stripping are
different for input XML documents and for XSLT stylesheets. Usually this
works in an intuitive way, but once XML data are put inside XSLT
stylesheet it can produce unexpected behaviour.

In Wendell's case, easy fix would be using xml:space="preserve":

<xsl:variable name="mixed" as="element()">
    <mixed xml:space="preserve">Here is mixed content, including

      <one>children</one>
      <two>with nothing</two>

      but whitespace between them.</mixed>
  </xsl:variable>

Also please note that xml:space can't be put on xsl:variable in this
case as text node before <mixed> would break type annotation.

			Jirka

-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail:       http://xmlguru.cz
------------------------------------------------------------------
     Professional XML and Web consulting and training services
DocBook/DITA customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
------------------------------------------------------------------
    Bringing you XML Prague conference    http://xmlprague.cz
------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: OpenPGP digital signature
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20150626/e3309f9c/attachment.sig>


More information about the oXygen-user mailing list