xsl-list
[Top] [All Lists]

Re: [xsl] Question on space normalization in serialization

2015-09-01 18:59:04
On Tue, 1 Sep 2015, David Carlisle 
d(_dot_)p(_dot_)carlisle(_at_)gmail(_dot_)com wrote:

[explaining that what I saw was the result of attribute value normalization by the parser]

Of course... and would have been obvious to me if I were processing XML containing "data" instead of working on XML containing "code". Sometimes I forget that XSLT is actually XML before it is anything else. Thanks!

David

On 1 September 2015 at 22:16, David Sewell dsewell(_at_)virginia(_dot_)edu
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
I am probably forgetting something basic in the XSLT specs about how string
variables are created and evaluated, but I was experimenting with including
CSS rules within an XSLT stylesheet and then writing them at run time along
with the output of my transformation via xsl:result-document. I discovered
that if I put the CSS into a string variable using the @select attribute,
linefeeds are not preserved in the output; but if I put the CSS text into a
sequence constructor, the linefeeds are preserved in the output. What's the
underlying reason, assuming this isn't implementation-dependent? (I'm
testing with Saxon; XSLT 2 and 3 produce identical results.)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
  exclude-result-prefixes="xs"
  version="2.0">
  <xsl:variable name="CSS1" as="xs:string" select="'
    p { color:pink; }
    a { font-family: fantasy}
    '"/>
  <xsl:variable name="CSS2" as="xs:string">
    p { color:pink; }
    a { font-family: fantasy}
  </xsl:variable>
  <xsl:template name="main">
    <xsl:result-document href="test1.css" method="text">
      <xsl:value-of select="$CSS1"/>
    </xsl:result-document>
    <xsl:result-document href="test2.css" method="text">
      <xsl:value-of select="$CSS2"/>
    </xsl:result-document>
  </xsl:template>
</xsl:stylesheet>

--
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400318, Charlottesville, VA 22904-4314 USA
Email: dsewell(_at_)virginia(_dot_)edu   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
--------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: -list/1090027
or by email: --~--


--
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400314, Charlottesville, VA 22904-4314 USA
Email: dsewell(_at_)virginia(_dot_)edu   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>