The Bishop script

This document explains the basics of the Bishop language. Once you have read this document, use the Bishop Language Reference to aid your Bishop development.

Hello World!

Bishop is a XML based language, ie it's syntax is defined in a dtd. This Bishop script:

<bishop>
  <object name="str" type="java.lang.String" export="true">
    <in name="message" type="java.lang.String" default-value="hello world"/>
  </object>
  <view template="demo.wm"/>
</bishop>
	  

In combination with this WebMacro template:

<html>
<head>
  <title>demo</title>
</head>
<body>
  Bishop says: $str
</body>
</html>
	  

Will generate the following html code:

<html>
<head>
  <title>demo</title>
</head>
<body>
  Bishop says: hello world
</body>
</html>
	  

Object management

The code above creates and object name str of the type java.lang.String (ie a normal Java String), and initalize it to the value of the variable "message" if defined, or to "hello world" if undefined.

Objects are created with the <object> directive. The scope of the object can be either local to the current script, global to the user's session and/or be present in the view. What scope that is defined for a certain object is defined in its <object> tag. If it is static, then the object is available in the session. If has the property export set to true, then it is available to the view. All objects are available in the current scope.

The Bishop language is a scoped language. This means that a scope has access to all the objects defined in itself and it parents. Compare to this java code:

public class SampleClass
{
	protected String a = "a";

	public void method1()
	{
		String b = "b";
		String c = a + b;
	}

	public void method2()
	{
		String d = a + b;
	}
}
	    

This will not compile since when the String d is defined as a + b, b is not known in method2's scope. The same is true for a Bishop script.

Objects can also be created using the <out> directive in combination with a <invoke>. Ie the result of a method invokation can be stored in an object. The scope of an out variable are the same for a "common" object (one that is created with <object>)

Objects are deleted using the <delete> directive, ie:

<bishop>
  <delete name="str">
</bishop>
	    

Will delete the object "str".

Control flow

The Bishop language has two directives for flow control: <if> and <import>

The <if> can verify if a variable is accessible in the current scope and validate its value against a specifed value. Bishop does support <else> if the condition to <if> is false.

<import> is similar to a method call in Java. With <import> is it possible to load and execute other Bishop scripts.

Exception handling

It is possible to catch an exception that is thrown by a method in the model in a Bishop script. If a scope if Bishop code is included in a <try> and <catch> directive, all exceptions thrown by the model will be caught in a matching <catch> block.

View management

Bishop's view management is described in here.

Model interaction

Bishops model interaction directives are described here


[home] | [introduction] | [webmacro] | [model interaction] | [developer's guide] | [architecture] | [reference] | [terms and definitions]