XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Karen LopezSubject: problem with Conditional Expressions
Author: Karen Lopez
Date: 30 Apr 2010 11:58 AM
Hi, I'm learning Xquery and I have some troubles to do the follow!

let $a := "1"
let $b := "2"

return

if ($a = "1")
then(
let $string := concat($a, "Some")
)
else()

if ($b = "2")
then(
let $string := concat($b, "Any")
)
else()

I need to validate the two variables with the two IFs and I canīt use ELSE IF because It isnot the same... How I can use various conditionals in a only return statement... thank you so much...

Postnext
(Deleted User) Subject: problem with Conditional Expressions
Author: (Deleted User)
Date: 30 Apr 2010 12:23 PM
Hi Karen,
in XQuery variables are immutable once they have been assigned. Could you explain what you are trying to achieve, so that we can suggest the correct approach?

Alberto

Postnext
Karen LopezSubject: problem with Conditional Expressions
Author: Karen Lopez
Date: 30 Apr 2010 12:43 PM
Hola Alberto, espero que hables espaņol que es mi idioma nativo, asi es mucho mas facil explicarlo...

quiero ir construyendo una cadena de caracteres segun 3 parametros, para irla construyendo necesito preguntar el valor de cada parametro es decir


param1
param2
param3

varExpresion

if (param1!= "") then varExpresion= concat (varExpresion,param1)

if (param2 != "")varExpresion= concat (varExpresion,param2)

if (param3 != "")varExpresion= concat (varExpresion,param3)

para al final retornar varExpresion con la union de todos los 3 parametros, si estos no son vacio..

Si me hice entender?? muchas gracias

Postnext
Karen LopezSubject: problem with Conditional Expressions
Author: Karen Lopez
Date: 30 Apr 2010 12:50 PM
the same explanation but in english!

I want to build a string with dynamic parameters, to do that I need to ask for each value of the 3 parameter like this:

param1
param2
param3

varExpresion

if (param1!= "") then varExpresion= concat (varExpresion,param1)

if (param2 != "") then varExpresion= concat (varExpresion,param2)

if (param3 != "")then varExpresion= concat (varExpresion,param3)

to finally return varExpresion with all of the 3 parameter if they exist

Did you understand?

Posttop
(Deleted User) Subject: problem with Conditional Expressions
Author: (Deleted User)
Date: 30 Apr 2010 12:52 PM
Hi Karen,
I hope my Spanish is good enough to understand the question...

If you want to concatenate several strings, it's just enough to do a long

concat($varExpression, $param1, $param2, $param3)

If they are empty, it's just like you didn't specify them as part of the concatenation.
In case you want to test for special values, you can add if() statements around the arguments, like in

concat($varExpression, if($param1!="xxx") then $param1 else (), if($param2!="xxx") then $param2 else (), if($param3!="xxx") then $param3 else ())

Hope this helps,
Alberto

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.