xsl-list
[Top] [All Lists]

Re: [xsl] What's wrong with a variable inside a xsl:when ?

2007-06-20 07:05:23
So i didn't use the variable after defining it. And that was the error. And after i used in a xs:value i got what i wanted although i defined my variable inside a choose statement ;)


But thanks a lot for the help!
On 20.06.2007, at 15:44, Ronan Klyne wrote:

Norman Rosner wrote:
Yeah I did that



    <xsl:variable name="translation">
      <xsl:choose>
    <xsl:when test="$kind = 'ADJA'"><xsl:value-of
select="mt:lexicon_adjectives($lemma)"/></xsl:when>
    <xsl:when test="$kind = 'NN'"><xsl:value-of
select="mt:lexicon_noun($lemma)"/></xsl:when>
    <xsl:otherwise>[set the value here]</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>


and what I got from saxon was :

Warning: at xsl:variable on line 25 of
file:/Users/jeckyll/studium/au/project/norman/norman_neu.xsl:
SXWN9001: A variable with no following sibling instructions has no effect


but that sounds strange to me because i think i have sibling element in
my variable element or am i wrong?

thanks for help!

On 20.06.2007, at 15:25, cknell(_at_)onebox(_dot_)com wrote:

I need that variable inside my when element so i can use a different
function then inside
another when  element.

I don't understand this, but probably your notion that you need to do
this in the way you are trying to do it is wrong.

In general, with XSLT you need to set the value of a variable in a
manner that seems "inside out" as compared to procedural languages.

This is the general form:

<xsl:variable name="x">
  <xsl:choose>
    <xsl:when test="">[set the value here]</xsl:when>
    <xsl:otherwise>[set the value here]</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

--
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Norman Rosner <jeckyll(_at_)mac(_dot_)com>
Sent:     Wed, 20 Jun 2007 15:08:38 +0200
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] What's wrong with a variable inside a xsl:when ?

Hi Folks,

i have a problem with defining a variable inside a when element.

If i write it this way, so that the variable is outside everything is
fine with saxon.

   <xsl:function name="mt:check_the_next">
     <xsl:param name="kind"/>
     <xsl:param name="lemma"/>

     <xsl:variable name="translation_adja"
select="mt:lexicon_adjectives('texanisch')"/>

     <xsl:choose>
       <xsl:when test="$kind = 'ADJA'">
    .
    .
    .

   </xsl:function>

But if i write it this way,

   <xsl:function name="mt:check_the_next">
     <xsl:param name="kind"/>
     <xsl:param name="lemma"/>

     <xsl:choose>
       <xsl:when test="$kind = 'ADJA'">

          <xsl:variable name="translation_adja"
select="mt:lexicon_adjectives('texanisch')"/>
    .
    .
    .

   </xsl:function>


so that the variable is inside my when element saxon does nothing.
It just tells me the following:
Warning: at xsl:variable on line 22 of file:/Users/jeckyll/ studium/au/
project/norman/norman_neu.xsl:
SXWN9001: A variable with no following sibling instructions has no
effect


I don't know what to o because the failure that there are no siblings
is not correct i think because the value is choosen.

Pleas help me xsl-List members :) I need that variable inside my when
element so i can use a different function then inside another when
element.

What am i doing wrong ?


cheers,

norman


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



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



The message is warning that there is no element after the
</xsl:variable> - essentially that the variable is not being used.

If you follow the variable definition with something like <xsl:value-of
select="$translation"/>, then this warning will disappear.

        # r

--
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan(_dot_)klyne(_at_)groupbc(_dot_)com
www.groupbc.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>
--~--



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