xsl-list
[Top] [All Lists]

RE: top level xsl:param confusion

2004-09-30 15:02:59
Hi Robert,

To begin, the function false() always returns false.

Then, I know that if you use xsl:param with a select attribute, then you
must use an Xpath expression.

From this, it is only logical that your xsl:param behaves like that, i.e. to
false() which is false even with an empty string. 

See http://www.w3.org/TR/xslt#element-param

As an alternative, you may want to use

<xsl:variable name="permission" select="''"/>

And test later on if the string is empty or not.

HTH,
<prs/>

-----Original Message-----
From: Robert Koberg [mailto:rob(_at_)koberg(_dot_)com] 
Sent: Thursday, September 30, 2004 3:16 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] top level xsl:param confusion

Hi,


I have a top level param like so:

<xsl:param name="permission" select="false()"/>


Main Question:

Is the above top level xsl:param considered false even if it was passed an
empty string? I would expect it to be false only if the param was
*not* passed.


More info:

I send the param down to the transformation if a user has access to the
filesystem otherwise it is not sent. And if they have access I send the path
that they are restricted to as the value. Some example values are:

"" -- full project access
"foo" -- access restricted to the 'foo' folder "foo/bar" -- access
restricted to the 'foo/bar' folder

If they have no restriction I want the param value to be 'false()'

The problem (or my misunderstanding) is when I pass down the empty string
value - "". So the transformation sees there is a
/xsl:stylesheet/xsl:param[(_at_)name='permission'] - so it should not evaluate 
to
false(), right? However, it does in both Xalan and Saxon (the only two I
tried). I don't see anything in the spec that addresses this.

For example, the following chooses the otherwise when the param is sent to
the transformation as an empty string.

<xsl:choose>
   <!--<xsl:when test="boolean($permission)"> or -->
   <xsl:when test="$permission">
<!-- allow access -->
   </xsl:when>
   <xsl:otherwise>
<!-- no access -->
   </xsl:otherwise>
</xsl:choose>

thanks for any clarification,
-Rob

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


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