[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Xsl:variable content should be empty

Subject: Re: Xsl:variable content should be empty
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 04 Apr 2007 11:43:50 +0200
Re:  Xsl:variable content should be empty
Alan Hale wrote:
<snip />

<xsl:variable name="link" select="file_link"> </xsl:variable>

<snip />

As you can see, I am trying to construct an html link from the filename
and path held in the <file_link> element.

This works fine when I call the stylesheet in-line or from Javascript in
Internet Explorer, but when I run it with the PHP XSL extension, it
generates a warning: Xsl:variable content should be empty since select
is present. It's only a warning and the output is still as expected, but
clearly I'm doing something wrong.

>From reading up it seems to me this IS an xslt issue rather than a PHP
one. I just don't understand it.


You read up well. The warning is wrong. However, there's a little truth in it ;)

You can use an xsl:variable with either a select or with more complex content:

<!-- with select -->
<xsl:variable name="x" select="file_link" />

<!-- with sequence constructor -->
<xsl:variable name="x"><xsl:value-of select="file_link" /></xsl:variable>

<!-- or more complex, like this: -->
<xsl:variable name="x">
   <xsl:for-each select="bla">
      <xsl:call-template name="xyz" />
      <xsl:apply-templates select="." />
   </xsl:for-each>
</xsl:variable>

<!-- or with text, like this (discouraged, use select to prevent document node to be created) -->
<xsl:variable name="x">Some text here</xsl:variable>


etc.

But you can't mix the two methods. You PHP XSL extension is a bit too strict. In XSLT, the following:

<xsl:variable name="x" select="file_link" > </xsl:variable>

should be regarded equal to:

<xsl:variable name="x" select="file_link" />


That is a lot of text for helping you to understand the issue at hand. To help PHP XSL a bit, you can remove the whitespace, or just make it an empty tag altogether (like above). Apparently the whitespace is regarded as a value, but PHP XSL shouldn't, really.


HTH,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.