Difference between revisions of "EPrints Control Format"

From EPrints Documentation
Jump to: navigation, search
m
Line 9: Line 9:
  
 
  <epc:print expr='expression' opt='key=value;key2=value2'/>
 
  <epc:print expr='expression' opt='key=value;key2=value2'/>
 
  
 
  &lt;cite:citation xmlns="http://www.w3.org/1999/xhtml"
 
  &lt;cite:citation xmlns="http://www.w3.org/1999/xhtml"
Line 19: Line 18:
 
Outputs the result of the expression in the 'expr' attribute.  
 
Outputs the result of the expression in the 'expr' attribute.  
  
Expressions can include:
+
Rendering options may be passed in the opt attribute using a key=value form, with semicolons separating multiple options.
 
 
$config{xxx} - a value from the configuration.
 
  
$current_user - the current user, e.g., $current_user{username}
+
Any [[EPScript]] expression can be used. The most simple is just 'eprintid','userid' etc. You can also use values from the configuration files by using '$config{base_url}'.
  
$current_lang - the id of the current language (such as 'en')
+
=== print in attributes ===
  
$item - the current item (usually an eprint, but not always, e.g., in citations or workflows for user objects), e.g., $item{eprintid}. If you just use {eprintid} it is a shortcut for {$item{eprintid}}
+
Sometimes you may wish to insert a value into an XML attribute. eg. the "href" part of an anchor. Rather than a complicated system, but correct XML, we decide to go for something a bit more readable. Any {} pair in an XML attribute will be treated as a epc:print.
  
Rendering options may be passed in the opt attribute using a key=value form, with semicolons separating multiple options.
+
So you can do something like
  
 +
<nowiki><a href="http://eprints.badger.edu/cgi/myscript.pl?eprintid={eprintid}">run myscript on this eprint</a></nowiki>
  
 
=== epc:phrase ===
 
=== epc:phrase ===

Revision as of 18:58, 23 May 2007

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


XML Configuration: EPScript - Control Format (EPC) - Citation - Workflow - Phrase - Template - XPAGE (static pages)


EPrints Control

Output Tags

epc:print

<epc:print expr='expression' opt='key=value;key2=value2'/>
<cite:citation xmlns="http://www.w3.org/1999/xhtml"
          xmlns:cite="http://eprints.org/ep3/citation"
          xmlns:epc="http://eprints.org/ep3/control">
    <epc:print expr="$item.citation('default')" />
</cite:citation> 

Outputs the result of the expression in the 'expr' attribute.

Rendering options may be passed in the opt attribute using a key=value form, with semicolons separating multiple options.

Any EPScript expression can be used. The most simple is just 'eprintid','userid' etc. You can also use values from the configuration files by using '$config{base_url}'.

print in attributes

Sometimes you may wish to insert a value into an XML attribute. eg. the "href" part of an anchor. Rather than a complicated system, but correct XML, we decide to go for something a bit more readable. Any {} pair in an XML attribute will be treated as a epc:print.

So you can do something like

<a href="http://eprints.badger.edu/cgi/myscript.pl?eprintid={eprintid}">run myscript on this eprint</a>

epc:phrase

<epc:phrase ref='phraseid'>
  <epc:param name='somepin'>Content</epc:param>
</epc:phrase>

Outputs the content of the phrase refered to by 'ref'. Any necessary parameters may be set using the <epc:param> tag, with the contents inserted into the pin with the name corresponding to the name attribute.

Conditional Tags

epc:if

<epc:if test='expr'>
...
</epc:if>

Outputs any XHTML content and evaluates any EPrints Control structures within the epc:if block if the expression in the test attribute is true.

epc:choose

<epc:choose>
  <epc:when test='expr'> 
  ...
  </epc:when>
  <epc:when test='expr2'> 
  ...
  </epc:when>
  <epc:otherwise>
  ...
  </epc:otherwise>
</epc:choose>

epc:choose allows for the construction of a complex conditional. Each epc:when block's 'test' attribute is evaluated, and the content of the block is returned if the result is true. If no expressions return true, the optional epc:otherwise block is returned. Note that no subsequent epc:when blocks are evaluated once the first block to return true is reached.