xsl-list
[Top] [All Lists]

RE: [xsl] passing param using value-of

2012-02-17 10:50:05
Funny, you are all assuming the OP is using XSLT 2.0..

:-)

-----Oorspronkelijk bericht-----
Van: Wendell Piez [mailto:wapiez(_at_)mulberrytech(_dot_)com]
Verzonden: vrijdag 17 februari 2012 17:32
Aan: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Onderwerp: Re: [xsl] passing param using value-of

Hi again,

On 2/16/2012 6:03 PM, Andrew Welch wrote:
This works fine.

  <xsl:call-template name="myTemplate">
         <xsl:with-param name="arguments"
select="preceding-sibling::*">
         </xsl:with-param>
</xsl:call-template>

But this doesn't:

<xsl:call-template name="myTemplate">
         <xsl:with-param name="arguments">
              <xsl:value-of select="preceding-sibling::*" />
         </xsl:with-param>
  </xsl:call-template>

Why ? How do I use value-of to set the value of a parameter ?

xsl:value-of generates a (single) text node. Depending on the
parameter,
that may be okay (or maybe not), even if the cases when a text node
is good
but a simple string is not even better are fairly rare.

Don't forget in the 2nd option that it's a text node child of a
document node, whereas in the first option (using select) it's
sequence type is element()*  (i think)

Indeed. To spell this out:

<xsl:with-param name="arguments" select="preceding-sibling::*"/>

binds to $arguments a sequence of nodes, namely the preceding sibling
elements.

<xsl:with-param name="arguments">
   <xsl:value-of select="preceding-sibling::*" />
</xsl:with-param>

binds to $arguments a temporary tree with a single text node, whose
value is determined by evaluating "preceding-sibling::*".

Probably you want the first of these, not the second. But even if you
wanted a string, not a sequence of nodes, you could specify that more
directly and more efficiently by operating directly on the preceding
siblings (with a function that returns a string) instead of by using
xsl:value-of.

Cheers,
Wendell

--
=================================================================
=====
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
=================================================================
=====

--~------------------------------------------------------------------
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>
--~--

--~------------------------------------------------------------------
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>
--~--