|
|
|
||||||
Description |
|
||||||
|
The <case_> tag is the component of the <switch_> statement and provides a convenient way to check a condition and execute various instructions depending on the result of the comparison. |
|
||||||
Example |
|
||||||
|
<?xml version="1.0" encoding="utf-8"?> . . . <switch_ input="this.address.zipcode"> <case_ value="31-526"> <text>Kraków (Kraków-Śródmieście)</text> </case_> <case_ value="45-573"> <text>Wrocław</text> </case_> <case_ input="this.post_address.zipcode"> <text>There is the same postcode in both the address checked and the shipping address</text> </case_> <default_> <text>I don’t know this code</text> </default_> </switch_> . . . |
|
||||||
|
|
|
||||||
|
The code compares the value of the this.address.zipcode variable with the value in the value attribute. If the two values match then the code from the next line after the </case_> tag is executed. The code checks the following condition: this.address.zipcode = this.post_address.zipcode If there is the value = 59-220 in the object this.address.zipcode then the text Legnica will be displayed here. If there is the value = 45-573 in the object this.address.zipcode then the text Wroclaw will be displayed here. If there is the value other than 59-220 or 45-573 in the object this.address.zipcode then the following text will be displayed: I don’t know this code. |
|
||||||
Visual output |
|
||||||
|
|
|
||||||
Attributes |
|
||||||
|
|
||||||
Child elements permitted |
|
||||||
|
Any child element may become the child element of the <case_> element |
|
||||||
Parent elements permitted |
|
||||||
|
|
||||||
Comments and remarks |
|
||||||
|
The <case_> element must not be placed outside the <switch_> element. |
|
||||||
|
|
|
||||||
|
|
|
