Skip over navigation

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.

If plugin ac-identity-exists

Check if the given identity exists.

<if ac-identity-exists='www'> User exists. </if>

If plugin accept

Returns true if the browser accepts certain content types as specified by it's Accept-header, for example image/jpeg or text/html. If browser states that it accepts */* that is not taken in to account as this is always untrue. This is a Match plugin.

Attributes

accept
accept=type1[,type2,...]
This attribute is required.

If plugin access-path

Test what access a user has to a directory or file protection point.

Attributes

access-path
access-path=path

The protection point to test. If there is no protection point on the given path, the path is searched towards the root for the controlling protection point.

identity
identity={handle, id}

The identity to check the permission for. If omitted, the currently logged on user is used.

none

The check will be true if the user has no permission to the protection point.

read

The check will be true if the user has read permission to the protection point.

write

The check will be true if the user has write permission to the protection point.

Note that the none, read and write attributes can be combined. <if access-path='/foo' read='' write=''/> could be used to give access to everyone that has either read or write access to the protection point /foo.

If plugin client

Compares the user agent string with a pattern. This is a Match plugin.

Attributes

client
client=
This attribute is required.

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.

If plugin date

Is the date yyyymmdd? The attributes before, after and inclusive modifies the behavior. This is a Utils plugin.

Attributes

date
date={yyyymmdd , yyyy-mm-dd}
This attribute is required.

Choose what date to test.

after

The date after todays date.

before

The date before todays date.

inclusive

Adds todays date to after and before.

<if date='19991231' before='' inclusive=''> - 19991231 </if> <else> 20000101 - </else>
20000101 -

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.

If 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.

If plugin exists

Returns true if the named page is viewable. A nonviewable page is e.g. a file that matches the internal files patterns in the filesystem module. If the path does not begin with /, it is assumed to be a URL relative to the directory containing the page with the <if>-statement. 'Magic' files like /internal-roxen-unit will evaluate as true. This is a State plugin.

To check if a path supplied via e.g. a form exists you could combine the -exists plugin with e.g. the sizeof-plugin:

<if exists='&form.path;' and='' sizeof='form.path > 0'> The path &form.path; exists in the virtual filesystem. </if>

Attributes

exists
exists=path
This attribute is required.

Choose what path in the virtual filesystem to test.

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.

If plugin false

This will always be true if the truth value is set to be false. Equivalent with <else>. This is a State plugin.

Attributes

false
This attribute is required.

Show contents if truth value is true.

If plugin forum-banned

Returns true if the given IP number matches any of the currently banned patterns.

Attributes

forum-banned
forum-banned=string

The IP number to test.

If plugin group

Checks if the current user is a member of the group according the groupfile. This is a Utils plugin.

Attributes

group
group=name
This attribute is required.

Choose what group to test.

groupfile
groupfile=path
This attribute is required.

Specify where the groupfile is located.

No documentation available for "plugin host".

If plugin internal-exists

Returns true if the named page exists. If the page at the given path is nonviewable, e.g. matches the internal files patterns in the filesystem module, it will still be detected by this if plugin. If the path does not begin with /, it is assumed to be a URL relative to the directory containing the page with the if statement. 'Magic' files like /internal-roxen-unit will evaluate as true. This is a State plugin.

Attributes

internal-exists
internal-exists=path
This attribute is required.

Choose what path in the virtual filesystem to test.

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 is-valid-timezone".

If plugin language

Does the client prefer one of the languages listed, as specified by the Accept-Language header? This is a Match plugin.

Attributes

language
language=language1[,language2,...]
This attribute is required.

Choose what language to test.

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

If plugin module

Returns true if the selected module is enabled in the current server. This is useful when you are developing RXML applications that you plan to move to other servers, to ensure that all required modules are added. This is a State plugin.

Attributes

module
module=name

The "real" name of the module to look for, i.e. its filename without extension and without directory path.

No documentation available for "plugin module-debug".

No documentation available for "plugin name".

No documentation available for "plugin nserious".

If plugin poll-voted

Test if the given client has voted on the poll previously. Will always return false if client logging is not enabled.

Attributes

poll-voted
This attribute is required.

String identifying the client as given to <poll-update>

poll-id
This attribute is required.

ID of the poll.

poll-votes-limit

Allow this many votes from the client before returning true. Default is 10 since if &client.ip; is used there can still be multiple valid clients behind the same IP.

poll-time-limit

Only count votes made within this many minutes.

If plugin ppoint

Test if a user has access to a RXML protection point. The RXML protection points can be listed, created and edited under the configuration tab.

Attributes

ppoint
ppoint=RXML protection point

The protection point to test.

none

The check will be true if the user has no permission to the protection point.

read

The check will be true if the user has read permission to the protection point.

write

The check will be true if the user has write permission to the protection point.

case
case=insensitive

If the attribute case='insensitive' is present, and there was a RXML protection point with the same name (not considering its capitalization) then the permission check will be performed on that protection point.

Note that the none, read and write attributes can be combined. <if ppoint='foo' read='' write=''/> could be used to give access to everyone that has either read or write access to the RXML protection point foo.

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.

If plugin referrer

Does the referrer header match any of the patterns? This is a Match plugin.

Attributes

referrer
referrer=pattern1[,pattern2,...]
This attribute is required.

Choose what pattern to test.

If plugin sb-user-op

Checks if a authenticated user has the permissions to perform a operation on a specified file or directory. Note: If the attribute path is omitted the current selected file is used by default.

To better manage errors, use this plugin together with <sb-error>.

Note: This tag should be used together with <sb-edit-area>sb-edit-area.

Attributes

sb-user-op
sb-user-op=operation
This attribute is required.

Check if the user has the permissions to perform this operation.

OperationCheck if user may

newfile

add a new file

newdir

add a new directory

set_metadata

change metadata

move

move/rename a file or directory

copy

copy a file or directory

commit

commit local files

delete

delete a file or directory

log

view/show revision log

view

view a file

revert

revert a file to an old revision

path
path=absolute or relative path to a file or directory

Check if the user may perform a operation on this file. If this attribute is ommited, the current file will be used.

<if sb-user-op="delete" path="&var.filename;"> &var.filename; may be deleted by you. </if>

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 &trade; 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".

If plugin time

Is the time hhmm, hh:mm, yyyy-mm-dd or yyyy-mm-ddThh:mm? The attributes before, after, inclusive and until modifies the behavior. This is a Utils plugin.

Attributes

time
time={hhmm, yyyy-mm-dd, yyyy-mm-ddThh:mm}
This attribute is required.

Choose what time to test.

after

The time after present time.

before

The time before present time.

until
until={hhmm, yyyy-mm-dd, yyyy-mm-ddThh:mm}

Gives true for the time range between present time and the time value of 'until'.

inclusive

Adds present time to after and before.

<if time='1200' before='' inclusive=''> ante meridiem </if> <else> post meridiem </else>

If plugin true

This will always be true if the truth value is set to be true. Equivalent with <then>. This is a State plugin.

Attributes

true
This attribute is required.

Show contents if truth value is false.

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.

If plugin user

Has the user been authenticated as one of these users? If any is given as argument, any authenticated user will do. This is a Utils plugin.

Attributes

user
user={name1[,name2,...], any}
This attribute is required.

Specify which users to test.

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>.

If plugin variable-exists

Does the given variable exist? I.e. is it bound to any value, be it null or something else?

The difference from the <if variable> plugin is that this one returns true for variables with a null value (typically produced by the <emit source="sql"> for columns containing an SQL NULL value).

Compatibility note: When the compatibility level is 4.5 or lower, <emit source="sql"> assigns the undefined value for SQL NULLs instead of a proper null value. This test is therefore false for such values too unless the compatibility level is higher than 4.5.

Attributes

variable
variable=name
This attribute is required.

Name of the variable to test.