RE: [xsl] XSL 2.0 - value-of - xml:space="preserve"

Subject: RE: [xsl] XSL 2.0 - value-of - xml:space="preserve"
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Thu, 03 Apr 2008 23:00:05 -0400
But wait,

On Fri, 2008-04-04 at 10:50 +0800, Michael Kay wrote:
> Yes, this is expected. With xml:space="preserve", whitespace text nodes
> appearing in a sequence constructor are significant and are copied to the
> output, as if they were enclosed in xsl:text.

There is no whitespace between the '=<xsl:value-of/>;'
(and I specified separator="")

> 
> With XSLT 1.0 this code would technically be in error, because no text nodes
> are allowed as children of xsl:choose. 

It is not in an xsl:choose ?? Do you mean the text inside the
xsl:when/otherwise?

> However, many processors tolerated it
> (or failed to detect the error), and in 2.0 it has explicitly been made
> legal. However, I wouldn't ever advise using xml:space="preserve" in a
> stylesheet, the results are too confusing.

Well, writing (more than one line) javascript in an XML IDE is a pain,
so xml:space="preserve" allows for some amount of sanity...

still not getting it, uff... 

> 
> Michael Kay 
> http://www.saxonica.com/
> 
> > -----Original Message-----
> > From: Robert Koberg [mailto:rob@xxxxxxxxxx] 
> > Sent: 04 April 2008 10:42
> > To: xsl-list
> > Subject: [xsl] XSL 2.0 - value-of - xml:space="preserve"
> > 
> > Hi,
> > 
> > I have the following in a template. I have copied it directly 
> > from the template without removing indentation spaces (I 
> > don't use tabs):
> > 
> >       <script type="text/JavaScript" xml:space="preserve"> ...
> >         <xsl:variable name="acknowledge">
> >           <xsl:choose>
> >             <xsl:when test="$task-type=5">3</xsl:when>
> >             <xsl:otherwise>1</xsl:otherwise>
> >           </xsl:choose>
> >         </xsl:variable>
> >           document.getElementById("status").value=<xsl:value-of
> > separator="" select="$acknowledge"/>;
> > 
> >      </
> > 
> > The above produces:
> > 
> >           document.getElementById("status").value=
> >           1
> >         ;
> > 
> > This is being output with xsl:result-document:
> > 
> > <xsl:result-document href="{$out-path}" encoding="UTF-8" indent="no"
> > method="xml">
> > ...
> > 
> > The problem is the xml:space on the script element. If 
> > removed, it renders as (I) expected. If xml:space="preserve" 
> > is present on the script element, is the result above 
> > expected behavior?
> > 
> > thanks,
> > -Rob
> > 
> > p.s. I haven't looked into this too deeply, but I put an as 
> > attribute with a schema type (yes, I declared the namespace):
> > <xsl:variable name="acknowledge" as="xs:integer"> and my page 
> > rendered empty. ?

Current Thread