How to declare Global variable of XQuery in XML

In this article we will discuss about how to declare and use the Global variables of XQuery.
  • 5676

Global variable are those variables which are declared at the top of any module and can be accessed by any part of the module. We can also use the concept of Global variables in  XQuery. We can declare variables outside the XQuery modules and can use it in any part of that XQuery module. We will use the declare keyword  to declare the variables and assign them any kind of value.

Here is the example of declaring and assigning the global variables in the XQuery module.

declare variable $message := ("message1","message2");


<?xml version="1.0" encoding="utf-8" ?>





There is another example of it.

 declare variable $mm := ();
declare variable $value := "Honesty";
declare variable $twice
:= (<example />, "Honesty");

In this example we have seen in the first line that a variable can be assigned even an empty value .i.e.( ). Here $twice[2] means second value of the twice variable has been accessed.


<?xml version="1.0" encoding="utf-8" ?>

Ask Your Question

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.