You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Simon <si...@yahoo.com> on 2001/06/11 14:25:37 UTC

XSL question

It's off-topic, but here's a question:

assuming the following xsl template

<xsl:template name="someTemplate">

  <xsl:call-template name="callMe">
    <xsl:with-param
name="location">/section/data/stuff</xsl:with-param>
  </xsl:call-template>

</xsl:template>


<xsl:template name="callMe">
  <xsl:param name="location"/>

  <xsl:for-each select="$location">
    <!-- some content -->

  </xsl:for-each>
</xsl:template>


---- what's wrong; the "location" parameter is passed
correctly and can be debugged using a value-of
instruction, however if I want to use it within a
for-each, it isn't allowed for some reason - why?

.s


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: XSL question

Posted by Simon <si...@yahoo.com>.
thanks dude

.s

--- "Thomas B. Passin" <tp...@mitretek.org> wrote: >
I believe that the problem is this:  You set the
> parameter to a string, not
> a node-set.  The xsl:for-each needs a node set, not
> a string.
> 
> Change your xsl:with-param instruction so that it is
> an empty element with a
> select attribute and everything should work fine:
> 
> <xsl:with-param name='...' select='a/b/c'/>
> 
> Next time, ask on the xslt list:
> 
> <xs...@lists.mulberrytech.com>
> 
> Tom P
> 
> [Simon]
> 
> ---- what's wrong; the "location" parameter is
> passed
> correctly and can be debugged using a value-of
> instruction, however if I want to use it within a
> for-each, it isn't allowed for some reason - why?
> 
> 
> 
> 
>
---------------------------------------------------------------------
> In case of troubles, e-mail:    
> webmaster@xml.apache.org
> To unsubscribe, e-mail:         
> general-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> general-help@xml.apache.org
> 


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: XSL question

Posted by "Thomas B. Passin" <tp...@mitretek.org>.
I believe that the problem is this:  You set the parameter to a string, not
a node-set.  The xsl:for-each needs a node set, not a string.

Change your xsl:with-param instruction so that it is an empty element with a
select attribute and everything should work fine:

<xsl:with-param name='...' select='a/b/c'/>

Next time, ask on the xslt list:

<xs...@lists.mulberrytech.com>

Tom P

[Simon]

---- what's wrong; the "location" parameter is passed
correctly and can be debugged using a value-of
instruction, however if I want to use it within a
for-each, it isn't allowed for some reason - why?




---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: XSL question

Posted by jason heddings <Ja...@Sun.COM>.
Simon-

There are two things here that I can see:

First, when using a "select" attribute (anywhere in XSL to my knowedge),
the value is not resolved before processing.  Meaning the processor will
not first substitue the value of $location and then run the for each. 

Secondly, the purpose of the "select" parameter is to build a node set
to operate on.  If you pass a string as its value, the processor will
look for a node with the given XPath expression in that string.

You may try to accomplish the problem in the following way:

<xsl:template name="someTemplate">

  <xsl:call-template name="callMe">
    <xsl:with-param
name="location-set" select="/section/data/stuff" />
  </xsl:call-template>

</xsl:template>


...which will pass the node set to your template instead of the text
value.

You may also try xalan-dev@xml.apache.org (they are far smarter than I)

HTH,
--jah
 

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      \\\|///                 Jason Heddings             ((
     \\ ~ ~ //                303.272.5166 (x75166)    C|~~|
     (/ @ @ /)                Jason.Heddings@Sun.COM    `__'
 ~~oOOo~(_)~oOOo~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: XSL question

Posted by Filkorn Roman <Ro...@swh.sk>.
Hi,

I think this should be asked on xalan-j-user@zml.apache.org
(XSLT questions) - there is far more people to ask..


> <xsl:template name="someTemplate">
>
>   <xsl:call-template name="callMe">
>     <xsl:with-param
> name="location">/section/data/stuff</xsl:with-param>
>   </xsl:call-template>
>
> </xsl:template>
>
>
> <xsl:template name="callMe">
>   <xsl:param name="location"/>
>
>   <xsl:for-each select="$location">
>     <!-- some content -->
>
>   </xsl:for-each>
> </xsl:template>
>
>
> ---- what's wrong; the "location" parameter is passed
> correctly and can be debugged using a value-of
> instruction, however if I want to use it within a
> for-each, it isn't allowed for some reason - why?
>

I don't know it exactly, but I have had similar problem and this is what I
think:

for-each takes a 'node-set-expression' in atribute 'select', and it does it
in one step -- so one and only thing is that '$location' is transformed into
the parameter value ('/selection/data/stuff', in this case).
There is an extending function node-set() (or similar, look at the spec.) in
Xalan2. So:

>   <xsl:for-each select="node-set($location)">
>     <!-- some content -->
>
>   </xsl:for-each>

will return a node-set for your expression.

It worked for me (but it was a time ago), so please check for details for
yourself. I hope this will help you.

Bye,

Roman


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org