| Roxen/6.2.236-git | ||
Roxen Interactive RXML Help
<if></if>
The <if> tag is used to conditionally include its contents. <else> or <elseif> can be used afterwards to include alternative content if the test is false.
The tag itself is useless without its plugins. Its main functionality is to provide a framework for the plugins. It is mandatory to add a plugin as one attribute. The other provided attributes are 'and', 'or' and 'not', used for combining different plugins with logical operations.
Note: Since XML mandates that tag attributes must be unique, it's not possible to use the same plugin more than once with a logical operator. E.g. this will not work:
<if variable='var.x' and='' variable='var.y'> This does not work. </if>You have to use more than one tag in such cases. The example above can be rewritten like this to work:
<if variable='var.x'> <if variable='var.y'> This works. </if> </if>The If plugins are sorted according to their function into five categories: Eval, Match, State, Utils and SiteBuilder.
Eval plugins
The Eval category is the one corresponding to the regular tests made in programming languages, and perhaps the most used. They evaluate expressions containing variables, entities, strings etc and are a sort of multi-use plugins.
<if variable='var.foo > 0' and='' match='var.bar is No'> ... </if>
<if variable='var.foo > 0' not=''> &var.foo; is less than 0 </if><else> &var.foo; is greater than 0 </else>The tests are made up either of a single operand or two operands separated by an operator surrounded by single spaces. The value of the single or left hand operand is determined by the If plugin.
If there is only a single operand then the test is successful if it has a value different from the integer 0. I.e. all string values, including the empty string "" and the string "0", make the test succeed.
If there is an operator then the right hand is treated as a literal value (with some exceptions described below). Valid operators are "=", "==", "is", "!=", "<", ">", "<=", and ">=".
<set variable='var.x' value='6'/> <if variable='var.x > 5'>More than one hand</if>More than one hand The three operators "=", "==" and "is" all test for equality. They can furthermore do pattern matching with the right operand. If it doesn't match the left one directly then it's interpreted as a glob pattern with "*" and "?". If it still doesn't match then it's split on "," and each part is tried as a glob pattern to see if any one matches.
In a glob pattern, "*" means match zero or more arbitrary characters, and "?" means match exactly one arbitrary character. Thus "t*f??" will match "trainfoo" as well as "tfoo" but not "trainfork" or "tfo". It is not possible to use regexps together with any of the if-plugins.
<set variable='var.name' value='Sesame'/> <if variable='var.name is e*,*e'>"&var.name;" begins or ends with an 'e'.</if>"Sesame" begins or ends with an 'e'. Match plugins
The Match category contains plugins that match contents of something, e.g. an IP package header, with arguments given to the plugin as a string or a list of strings.
Your domain <if ip='130.236.*'> is </if> <else> isn't </else> liu.se.Your domain isn't liu.se. State plugins
State plugins check which of the possible states something is in, e.g. if a flag is set or not, if something is supported or not, if something is defined or not etc.
Your browser <if supports='javascript'> supports Javascript version &client.javascript; </if> <else>doesn't support Javascript</else>.Your browser supports Javascript version 1.5 . Utils plugins
Utils are additonal plugins specialized for certain tests, e.g. date and time tests.
<if time='1700' after=''> Are you still at work? </if> <elseif time='0900' before=''> Wow, you work early! </elseif> <else> Somewhere between 9 to 5. </else>SiteBuilder plugins
SiteBuilder plugins requires a Roxen Platform SiteBuilder installed to work. They are adding test capabilities to web pages contained in a SiteBuilder administrated site.
This tag is cache static (see the <cache> tag) if the compatibility level is set to 2.5 or higher.
Attributes
- not
Inverts the result (true->false, false->true).
- or
If any criterion is met the result is true.
- and
If all criterions are met the result is true. And is default.
If plugin Match
Case sensitive version of the <if match> plugin.
If plugin Variable
Case sensitive version of the <if variable> plugin.
No documentation available for "plugin accept".
No documentation available for "plugin client".
If plugin clientvar
Evaluates expressions with client specific values. This is an Eval plugin.
Attributes
- clientvar
- clientvar=variable [is value]
This attribute is required.Choose which variable to evaluate against. Valid operators are '=', '==', 'is', '!=', '<' and '>'.
- height - The presentation area height in pixels.
- javascript - The highest version of javascript supported.
- robot - The name of the web robot.
- width - The presentation area width in pixels.
If plugin config
Has the config been set by use of the <aconf> tag? This is a State plugin.
Attributes
- config
- config=name
This attribute is required.
If plugin cookie
Does the cookie exist and if a value is given, does it contain that value? This is an Eval plugin.
Attributes
- cookie
- cookie=name[ is value]
This attribute is required.
No documentation available for "plugin date".
No documentation available for "plugin debug".
If plugin defined
Tests if a certain RXML define is defined by use of the <define> tag, and in that case tests its value. This is an Eval plugin.
Attributes
- defined
- defined=define
This attribute is required.Choose what define to test.
The define should be provided as type�name-of-define, i.e. the type and the name separated by a NUL (ASCII 0) character. Currently there are two alternatives:
tag�name-of-define
if�name-of-define
<define tag="hello-world">Hello world</define> <define container="say-hello">Hello, <contents/></define> <define if="person">Matt</define> <if defined="tag�hello-world"> <div><hello-world/>!!</div> </if> <if defined="tag�say-hello"> <div><say-hello>Matt</say-hello></div> </if> <if defined="if�person"> <div> <if person="Matt">Yes, it's Matt!</if> <else>No Matt</else> </div> </if> <if defined="tag�non-defined-thing"><non-defined-thing/></if> <else><div><non-defined-thing/> is not defined</div></else> Hello world!!Hello, MattYes, it's Matt!<non-defined-thing/> is not definedIf plugin domain
Does the user's computer's DNS name match any of the patterns? Note that domain names are resolved asynchronously, and that the first time someone accesses a page, the domain name will probably not have been resolved. This is a Match plugin.
Attributes
- domain
- domain=pattern1[,pattern2,...]
This attribute is required.Choose what pattern to test.
No documentation available for "plugin exists".
If plugin expr
This plugin evaluates an expression and returns true if the result is anything but an integer or floating point zero.
Attributes
- expr
- expr=expression
The expression to test. See the expr attribute to <set> for a description of the syntax.
No documentation available for "plugin false".
No documentation available for "plugin group".
No documentation available for "plugin host".
No documentation available for "plugin internal-exists".
If plugin ip
Does the users computers IP address match any of the patterns? This plugin replaces the Host plugin of earlier RXML versions. This is a Match plugin.
Attributes
- ip
- ip=pattern1[,pattern2,...]
This attribute is required.Choose what IP-adress pattern to test.
No documentation available for "plugin language".
If plugin match
Evaluates patterns. More information can be found in the <If tags tutorial>. Match is an Eval plugin.
Attributes
- match
- match=pattern
This attribute is required.Choose what pattern to test. The pattern could be any expression.
Note! The pattern content is treated as strings. Compare how <if variable> tag works.
<set variable='var.ten' value='10' /> <if match='&var.ten; is 10'>true</if> <else>false</else>true No documentation available for "plugin module".
No documentation available for "plugin module-debug".
No documentation available for "plugin name".
No documentation available for "plugin nserious".
If plugin pragma
Compares the HTTP header pragma with a string. This is a State plugin.
Attributes
- pragma
- pragma=string
This attribute is required.Choose what pragma to test.
<if pragma='no-cache'>The page has been reloaded!</if> <else>Reload this page!</else>Reload this page! If plugin prestate
Are all of the specified prestate options present in the URL? This is a State plugin.
Attributes
- prestate
- prestate=option1[,option2,...]
This attribute is required.Choose what prestate to test.
No documentation available for "plugin referrer".
If plugin scope
Does the scope exists.
Attributes
- scope
- scope=name
This attribute is required.Specify scope to test for existence.
If plugin sizeof
Compares the size of a variable with a number. This is an Eval plugin.
<set variable="var.x" value="hello"/> <set variable="var.y" value=""/> <if sizeof="var.x == 5">Five</if> <if sizeof="var.y > 0">Nonempty</if>Five If plugin supports
Does the browser support this feature? This is a State plugin.
Attributes
- supports
- supports=feature
This attribute is required.
Choose what supports feature to test.
The following features are supported:
- activex - The browser handles activeX contents.
- align - The browser supports the align attribute in its tags.
- autogunzip - The browser can decode a gzipped file on the fly.
- backgrounds - The browser supports backgrounds according to the HTML3 specifications.
- bigsmall - The browser supports the <big> and <small> tags.
- center - The browser supports the <center> tag.
- cookies - The browser can receive cookies.
- divisions - The browser supports <div> tags.
- div - Same as divisions.
- font - The browser supports the font tag.
- fontcolor - The browser can change color of individual characters.
- forms - The browser supports forms according to the HTML 2.0 and 3.0 specifications.
- frames - The browser supports frames.
- gifinline - The browser can show GIF images inlined.
- html - This is a HTML browser (as opposed to e.g. a WAP browser).
- imagealign - The browser supports align=left and align=right in images.
- images - The browser can display images.
- java - The browser supports Java applets.
- javascript - The browser supports javascripts.
- jpeginline - The browser can show JPEG images inlined.
- js_global_event - The browser supports a global event object e.g. netscape 4.
- js_image_object - The browser supports the javascript image object.
- js_inner_html - The browser supports the javascript propperty innerHTML.
- layer - The browser supports the layer tag.
- mailto - The browser supports mailto URLs.
- math - The <math> tag is correctly displayed by the browser.
- msie - This is a Microsoft Internet Explorer browser.
- noscript - The browser honours the <noscript> tag (by showing its contents only when javascript is not on).
- phone - The client is a phone.
- pjpeginline - The browser can handle progressive JPEG images, .pjpeg, inline.
- pnginline - The browser can handle PNG images inlined.
- pull - The browser handles Client Pull.
- push - The browser handles Server Push.
- robot - The request really comes from a web robot, not an actual browser.
- ssl - The browser handles secure sockets layer.
- stylesheets - The browser supports stylesheets.
- supsub - The browser handles <sup> and <sub> tags correctly.
- tables - The browser handles tables according to the HTML3.0 specification.
- tablecolor - It is possible to set the background color in the browser.
- tableimages - It is possible to set a backgroud image in a table in the browser.
- trade - The browser supports the ™ entity.
- unknown - The browser is not known, hence the supports classes can not be trusted.
- vrml - The browser supports VRML.
- wbmp - The browser supports Wireless Bitmap Picture Format.
- wml - The browser supports Wireless Markup Language 1.1.
No documentation available for "plugin test-license".
No documentation available for "plugin time".
No documentation available for "plugin true".
If plugin type-from-data
Compares if the variable's data is known content type and tries to match that content type with the content type pattern.
This test is currently only capable of recognizing several common image formats. If the content format isn't recognized then the fallback content type in the Content Types module is tested against the pattern. That type is "application/octet-stream" by default. That also means that if the variable content is unknown and there is nothing to test the content type from, it will always return true:
<set variable='var.fake-image' value='fakedata here'/> <if type-from-data='var.fake-image'>It is an image</if>It is an image While the correct way would be:
<set variable='var.fake-image' value='fakedata here'/> <if type-from-data='var.fake-image is application/octet-stream'> Not known content type! </if>Not known content type! This is an Eval plugin.
Related tags: <if#type-from-filename>, <cimg>, <guess-content-type>, <emit#dir>.
<nocache> <form method='post' enctype='multipart/form-data'> <input type='file' name='image' /> <input type='submit' name='upload' /> </form> <if variable='form.image' and='' sizeof='form.image < 2048000'> File is less than 2MB <if type-from-data='form.image is image/*'> It's an image! </if> <elseif type-from-filename='form.image is text/*'> It is a text file of some sort. </elseif> <elseif type-from-filename='form.image is application/msword,application/pdf'> The image is a MS word- or pdf file. </elseif> <elseif type-from-filename='form.image is application/octet-stream'> Invalid content type, type is unknown! </elseif> </if> <else>File larger than 2MB</else> </nocache>If plugin type-from-filename
Compares if the variable contains a path that match the content type pattern.
This is an Eval plugin.
Related tags: <if#type-from-data>, <cimg>, <guess-content-type>, <emit#dir>.
See a lengthier example under <if#type-from-data>.
<set variable='var.path' value='/a-path/to somthing/wordfile.doc'/> <if type-from-filename='var.path is application/msword'> It is a word document. </if> <else> It is other document type that I do not want. </else>It is a word document. No documentation available for "plugin user".
If plugin variable
Does the variable exist and have a non-null value? And optionally, does its content match the pattern? This is an Eval plugin.
Attributes
- variable
- variable=name[ operator pattern]
This attribute is required.Choose variable to test. Valid operators are '=', '==', 'is', '!=', '<' and '>'.
Examples of how this Eval plugin exists in <if> documentation and the <If tags tutorial>.
No documentation available for "plugin variable-exists".