Show last authors
1 === Overview ===
2
3 The SetXmlVar function is used to define and set xml as variables within a scenario. Variables can be classified as either global or local, each serving distinct purposes within the execution of scenarios.
4
5 {{code language="XML"}}
6 SetXmlVar(variable_name, value, global=False)
7
8 {{/code}}
9
10 * variable_name: The name of the variable to be set.
11 * value: The value to assign to the variable.
12 * global (optional): A boolean flag indicating whether the variable should be global. Defaults to False.
13
14 === Parameters ===
15
16 * **variable_name**: (Type: string) The unique identifier for the variable.
17 * **value**: (Type: any) The value to assign to the variable.
18 * **global**: (Type: boolean, Optional) Specifies whether the variable is global or local. Defaults to False.
19
20 === Usage ===
21
22 ==== Example 1: Setting a Local Variable ====
23
24 {{code language="XML"}}
25 <xsl:stylesheet
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:ixf="http://www.ixPath.com/Function"
28 xmlns:xs="http://www.w3.org/2001/XMLSchema"
29 xmlns:ix="localFunction"
30 xmlns:fn="http://www.w3.org/2005/xpath-functions" version="2.0">
31 <xsl:output method="xml" indent="yes"></xsl:output>
32 <!-- Beginning of the Translation -->
33 <xsl:template match="/">
34 <xsl:variable name="varrr">
35 <Tracking>
36 <MyTrk>
37 <Num>2023</Num>
38 </MyTrk>
39 <MyTrk>
40 <Num>2024</Num>
41 </MyTrk>
42 </Tracking>
43 </xsl:variable>
44 <ixDOC>
45 <xsl:value-of select="ixf:SetXmlVar('xmlVar',$varrr)"></xsl:value-of>
46 </ixDOC>
47 </xsl:template>
48 </xsl:stylesheet>
49 {{/code}}
50
51
52 === Retrieving Variable Values ===
53
54 To retrieve the value of a variable, use the GetXmlVar function:
55
56 {{code language="XML"}}
57 <xsl:value-of select="ixf:GetXmlVar('variable_name')"></xsl:value-of>
58 {{/code}}
59
60 **variable_name**: The name of the variable whose value you want to retrieve as an xml.
61
62 === Note ===
63
64 If global is set to true, the variable will be considered global. Omitting the global parameter or setting it to false makes the variable local.
65
66 === Conclusion ===
67
68 The SetXmlVar function provides a flexible way to manage xml asĀ  variables within scenarios, allowing you to control their scope and access them as needed.
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian