cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: Order of execution of different namespace tags when using xsp?
Date Wed, 12 Jul 2000 18:49:12 GMT
On 12 Jul 2000, Kjell M. Myksvoll wrote:

> Hello,
> 
> I have made myself a small taglib called "ls" for accessing a corba
> service. This taglib is used by the following complete xml-page:
> 
>   <?xml version="1.0" encoding="ISO-8859-1"?>
> 
>   <?cocoon-process type="xsp"?>
>   <?cocoon-process type="xslt"?>
>   <?xml-stylesheet href="test-ls-html.xsl" type="text/xsl"?>
> 
>   <xsp:page
>     language="java"
>     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>     xmlns:request="http://www.apache.org/1999/XSP/Request"
>     xmlns:ls="http://fou.telenor.com/ls"
>   >
> 
>   <page>
>    <ls:setTerminalId><request:get-query-string /></ls:setTerminalId>
> 
>    <terminal>Terminal = <ls:getTerminalId /></terminal>
>    <location>
>     Cell ID   = <ls:getCellId   />
>     UTM North = <ls:getUTMNorth />
>     UTM East  = <ls:getUTMEast  />
>     UTM Zone  = <ls:getUTMZone  />
>    </location>
>   </page>
> 
>   </xsp:page>
> 
> The problem is that I have to set a value before accessing the corba
> service (via the taglib). This is what I tried to do with the
> expression
> 
>   <ls:setTerminalId><request:get-query-string /></ls:setTerminalId>
> 
> above. Unfortunatly this does not works, as the "request" part are
> replaced with space (or rather nothing), leading to error in the
> resulting java code.

what you want to do in your logicsheet is something like this:

<xsl:apply-templates select="ls:setTerminalId/*"/>

instead of

<xsl:apply-templates select="ls:setTerminalId"/>

If the element in question might have text, or might have elements from
other logicsheets, and you don't know which or what, you might try
something like this:

<xsl:call-template name="get-nested-string">
 <xsl:with-param name="content" select="ls:setTerminalId"/>
</xsl:call-template>

<xsl:template name="get-nested-string">
 <xsl:param name="content"/>
 ""
 <xsl:for-each select="$content/node()">
  <xsl:choose>
   <xsl:when test="name(.)">
    + <xsl:apply-templates select="."/>
   </xsl:when>
   <xsl:otherwise>
    + "<xsl:value-of select="."/>"
   </xsl:otherwise>
  </xsl:choose>
 </xsl:for-each>
</xsl:template>

(partially based on the get-nested-string method ricardo wrote for the sql
logicsheet, in turn based on the get-nested-content method ricardo wrote
for all of the other logicsheets)

i just struggled through this issue for a site of mine. it's not
immediately intuitive, but after a while you'll grok it.

honestly, this is the only thing that really worries me about XSP - some
things that you would think would be really simple are in fact subtly
tricky - never impossible, mind, just nonintuitive. i guess that's where
we need more and better docs. hey, someone was working on an XSP tutorial
but it never got linked off of cocoon's site. can the party responsible
repost the link and i'll add it to the web site myself? merci.

- donald


Mime
View raw message