Re: xsp-request:get-parameter into xsl:variable problem

2003-06-30 Thread Christian Haul
On 29.Jun.2003 -- 09:50 PM, C Bram Dit Saint Amand wrote:
 This is an extract from request_attributes.xsl, a logicsheet which is
 called by some_page.xsp
 
 xsl:template match=request-attributes:get/webaction
 xsl:variable name=webaction-valuexsp-request:get-parameter
 name=webaction//xsl:variable
 xsl:if test=contains($webaction-value, 'add_to_favourites_session')
 and contains('add_to_favourites_session', $webaction-value)

$webaction-value most likely contains some XSP or Java code at the
time the logicsheet is applied -- which is when the XSP is translated
to Java servlet sourcecode *not* which every request!

So you may not use XSL to check for run time values in a
logicsheet. You need to use Java instead.

 esql:connection
   esql:poolperso-mysql/esql:pool
   esql:execute-query
 esql:queryINSERT INTO FavouritesBasketSession(SessionID,
 URL) VALUES('xsp-session:get-id/', 'xsp-request:get-attribute
 name=relative-url/');/esql:query
   /esql:execute-query
 /esql:connection
 /xsl:if /xsl:template
 
 
 When I access some_page.xsp?webaction=add_to_favourites_session, the
 template is executed: the xsl:variable is created, but what is inside
 the xsl:if *isn't* executed, which suggests that there is a problem with
 the xsl:variable. For information, displaying the variable's content
 with xsl:copy-of works (it correctly displays
 'add_to_favourites_session'), but with xsl:value-of it doesn't display
 anything.

Indeed, since it effectively copies the XSP / Java code used to read
the request attribute. It does not, however, copy the _value_ of that
attribute. 

Chris.
-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: xsp-request:get-parameter into xsl:variable problem

2003-06-29 Thread Fran├žois Parlant
I'm not an expert (sorry) so this is only a suggestion

1)  some whitespaces might interfere between the string
'add_to_favourites_session' and the value of the $webaction-value variable.
I would suggest a formula more like ;

normalize-space($query)

 xsl:if test=contains(normalize-space($webaction-value),
'add_to_favourites_session')
and contains('add_to_favourites_session',
normalize-space($webaction-value))

...just to make sure.


2) In xsl, calling a variable by xsl:value-of only selects the string part
of the nodes (the text()). It means that if the variable is more than simple
text and include nodes around it or inside it (it's called a node-set or
nodeset because it contains tags and text, hope I'm not making too much
mistakes saying that), only the text will appear when asking for
xsl:value-of.

xsl-copy-of on the other hand, copies all what is inside the variable, nodes
(tags) and text and attributes ...

The best referenc is at the xsl FAQ (in the variable  page):
http://www.dpawson.co.uk/xsl/sect2/N8090.html#d8123e583

Solution (if that is the problem, which is not sure at all):
Most xsl processor have a node-set or nodeset function which is an
extension of the xsl specification. For xalan it's xalan:nodeset, but you've
got some for saxon or xt. (beware, you've got to add the specific namespace
of your processor on top of your page for this tags to be executed)

This stuff enable you to check parts by parts the inside of the variable,
for exemple calling by templates for each part (nodes attributes and text)

Hope it helps, but I guess you might want better information. The xsl list
is very active.

XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Fran├žois Parlant


- Original Message - 
From: C Bram Dit Saint Amand [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, June 29, 2003 10:50 PM
Subject: xsp-request:get-parameter into xsl:variable problem


 This is an extract from request_attributes.xsl, a logicsheet which is
 called by some_page.xsp

 
 xsl:template match=request-attributes:get/webaction
 xsl:variable name=webaction-valuexsp-request:get-parameter
 name=webaction//xsl:variable
 xsl:if test=contains($webaction-value, 'add_to_favourites_session')
 and contains('add_to_favourites_session', $webaction-value)
 esql:connection
   esql:poolperso-mysql/esql:pool
   esql:execute-query
 esql:queryINSERT INTO FavouritesBasketSession(SessionID,
 URL) VALUES('xsp-session:get-id/', 'xsp-request:get-attribute
 name=relative-url/');/esql:query
   /esql:execute-query
 /esql:connection
 /xsl:if /xsl:template
 


 When I access some_page.xsp?webaction=add_to_favourites_session, the
 template is executed: the xsl:variable is created, but what is inside
 the xsl:if *isn't* executed, which suggests that there is a problem with
 the xsl:variable. For information, displaying the variable's content
 with xsl:copy-of works (it correctly displays
 'add_to_favourites_session'), but with xsl:value-of it doesn't display
 anything.


 The questions:
 --
 - Why doesn't it work?
 - I'm a Cocoon newbie, so if you have any comments on my code (how to
 write it better), I'm open to suggestions.


 Thanks in advance.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]