Re: [xsl] Variable value change based on condition

Subject: Re: [xsl] Variable value change based on condition
From: sudheshna iyer <sudheshnaiyer@xxxxxxxxx>
Date: Tue, 5 Oct 2010 06:55:47 -0700 (PDT)
Thank you .
Input variables are nothing but the elements of input xml. I have
java program which I have to convert to xslt. 
 
I need to copy these input
variables(elements of input xml) to output variables based on some condition.
Conditions:
1. If all the 3 input variables(elements of input xml) are present
(element present with no blanks), map /InputXmlValue1 -> outputTempVar1, map
/InputXmlValue2 -> outputVar1 and map /InputXmlValue3 -> outputVar2.
2. If
there are only two input variables present (/InputXmlValue1, /InputXmlValue2),
map /InputXmlValue1 -> outputVar1 and map /InputXmlValue2 -> outputVar2.
3. If
there is only one input variable is present (//InputXmlValue1), map
/InputXmlValue1 -> outputVar1.   

So output variables get their values based
on input variable's presence (element being present and not empty). I am
trying to transform one xml to another. So input variables come from input
xml.
/InputXmlValue1 , /InputXmlValue2, /InputXmlValue3 are the values of the
elemnents in the incoming xml
====


--- On Tue, 10/5/10, David Carlisle
<davidc@xxxxxxxxx> wrote:

> From: David Carlisle <davidc@xxxxxxxxx>
>
Subject: Re: [xsl] Variable value change based on condition
> To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: "sudheshna iyer"
<sudheshnaiyer@xxxxxxxxx>
> Date: Tuesday, October 5, 2010, 9:09 AM
> On
05/10/2010 13:59, sudheshna iyer
> wrote:
> > Can this be achieved in xslt
1.0?
> > 
> > 
> 
> You just repeated your initial question.
> 
> XSLt doesn't
have "inout variables" and "output variables"
> I'm guessing that you mean,
respectively, parameters and
> variables, but it's hard to be sure.
> 
>
variables always have a value if declared so you need to
> say what value you
want for each of your three variables.
> 
> I'm guessing that you want, for
variable3 something like
> the first of input3,input2,input1 that is not
empty.
> 
> In XSLT2 that would be
> 
> <xsl:variable name="variable3"
>
select="($var3,$var2,$var1)[not(.='')][1]"/>
> 
> on xslt1 if you could use
>
> 
> 
> <xsl:variable name="variable3" >
> <xsl:choose>
> <xsl:when
test=not($var3='')"><xsl:value-of
> select="$var3"/></xsl:when>
> <xsl:when
test=not($var2='')"><xsl:value-of
> select="$var2"/></xsl:when>
>
<xsl:otherwise><xsl:value-of
> select="$var1"/></xsl:otherwise>
>
</xsl:choose>
> </xsl:variable>
> 
> 
> David
> 
>
________________________________________________________________________
> The
Numerical Algorithms Group Ltd is a company registered
> in England
> and
Wales with company number 1249803. The registered
> office is:
> Wilkinson
House, Jordan Hill Road, Oxford OX2 8DR, United
> Kingdom.
> 
> This e-mail
has been scanned for all viruses by Star. The
> service is
> powered by
MessageLabs.
>
________________________________________________________________________
> 
>
--~------------------------------------------------------------------
>
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@xxxxxxxxxxxxxxxxxxxxxx>
> --~--

Current Thread