EPrints Technical Mailing List Archive

Message: #07987


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Building citations based on condition with Regular Expression


Hi Stefan,

You're right - it doesn't.

 

I don't think there is a simple way to achieve what you are trying to do with the EPScript methods available:

https://wiki.eprints.org/w/EPScript

 

If you look in EPrints::Script::Compiler::tokenise you'll see the different characters that EPScript expects - it doesn't include RegExps.

 

You could inject a method to EPrints::Script::Compiled that returns a boolean for use in a test, or even rendered xhtml.

I used this approach here:

https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L11-L29 (documentation)

https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L117-L149 (method added to EPrints::Script::Compiled)

 

Let me know if that helps - or if you want some more explanation.

You *could* inject a method that took a RegExp as a parameter - you would need to be careful about compiling the regex from this string if you do!

 

Cheers,

John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Stefan Wellsandt via Eprints-tech
Sent: 02 October 2019 14:27
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Building citations based on condition with Regular _expression_

 

Hello,

 

I want to use a regular _expression_ to assemble a part in a citation. This script (see below) throws me an error – I assume the EprintsScript does not know RegExp.

<when test="type.one_of('conference_item','editor_conference_proceeding')">

    In: Proceedings of the

    <choose>

               <when test="event_title =~ \International\">

                               <if test="event_title"><print expr="event_title"/></if>

               </when>

               <otherwise>

                               <if test="event_type"><print expr="event_type"/></if> on <if test="event_title"><print expr="event_title"/></if>

               </otherwise>

    </choose>

  </when>

 

 

What is the easiest way to fix this problem?

 

Best regards

Stefan