Difference between revisions of "EPScript/Data Types"

From EPrints Documentation
Jump to: navigation, search
(Added extra primitive data types)
Line 1: Line 1:
 
{{EPScript}}
 
{{EPScript}}
 
This is an introduction.
 
  
 
= Data Types =
 
= Data Types =
 
+
EPScript has various data types, both primitive (strings, integers and booleans) and [[Data Objects]] for the various concepts that can be represented within an EPrints repository.
xxx
+
 
== Primitive Types ==
 
== Primitive Types ==
  
=== Strings and characters ===  
+
=== String ===  
 
+
'''STRING''' is contained within either double quotes ("") or single quotes (<nowiki>''</nowiki>). There is no difference between the two, but it may be easier to use one sort when inside an XML attribute. For example:
These are contained within either double quotes ("") or single quotes (<nowiki>''</nowiki>). There is no difference between the two, but it may be easier to use one sort when inside an XML attribute. For example:
 
  
 
{{codesample|
 
{{codesample|
Line 21: Line 18:
  
 
=== Integers ===
 
=== Integers ===
 +
'''INTEGER'' is defined as a string of numbers from 0-9, e.g. 300. Leading zeros do not have any effect, and decimal values are currently not supported.
 +
 +
=== Booleans ===
 +
'''BOOLEAN''' is either true or false.
 +
 +
=== Dates ===
 +
'''DATE'' is defined as a string that conforms to the ISO date format (e.g. <tt>2022-02-20</tt>),
  
Integers are defined as a string of numbers from 0-9, e.g. 300. Leading zeros do not have any effect, and decimal values are currently not supported.
 
  
 
== Data Objects ==
 
== Data Objects ==
 
 
Data Objects include most of the key EPrints objects - whether an EPrint itself, documents related to the EPrint, or a user. EPScript treats all of these data objects the same, with a simple approach to retrieve properties. When an EPScript is executed, a 'main' object is supplied. In the case of a citation file, this will be the item for which the citation is being created. For a workflow, this will be the object on which the workflow acts (e.g. an EPrint or a user). Properties of main objects can be accessed using a shortened approach - the following example is from a user workflow, so the usertype property is available:
 
Data Objects include most of the key EPrints objects - whether an EPrint itself, documents related to the EPrint, or a user. EPScript treats all of these data objects the same, with a simple approach to retrieve properties. When an EPScript is executed, a 'main' object is supplied. In the case of a citation file, this will be the item for which the citation is being created. For a workflow, this will be the object on which the workflow acts (e.g. an EPrint or a user). Properties of main objects can be accessed using a shortened approach - the following example is from a user workflow, so the usertype property is available:
  

Revision as of 15:19, 20 February 2022

EPScript

Data Types

EPScript has various data types, both primitive (strings, integers and booleans) and Data Objects for the various concepts that can be represented within an EPrints repository.

Primitive Types

String

STRING is contained within either double quotes ("") or single quotes (''). There is no difference between the two, but it may be easier to use one sort when inside an XML attribute. For example:


<when test="type = 'patent'">
...
</when>


Integers

'INTEGER is defined as a string of numbers from 0-9, e.g. 300. Leading zeros do not have any effect, and decimal values are currently not supported.

Booleans

BOOLEAN is either true or false.

Dates

'DATE is defined as a string that conforms to the ISO date format (e.g. 2022-02-20),


Data Objects

Data Objects include most of the key EPrints objects - whether an EPrint itself, documents related to the EPrint, or a user. EPScript treats all of these data objects the same, with a simple approach to retrieve properties. When an EPScript is executed, a 'main' object is supplied. In the case of a citation file, this will be the item for which the citation is being created. For a workflow, this will be the object on which the workflow acts (e.g. an EPrint or a user). Properties of main objects can be accessed using a shortened approach - the following example is from a user workflow, so the usertype property is available:

<if test="usertype = 'editor'">
...
</if>


There are cases, however, where two or more data objects may be provided - such as an EPrint and a user. Here the main object can still be accessed in the short form, but other objects use a dollar notation. In this example, the EPrint is available as $eprint:


<if test="$eprint.ispublished.one_of('unpub', 'submitted', 'inpress')"> (<print expr="$eprint.ispublished" />)</if>