Re: [EP-tech] Building citations based on condition with Regular Expression
John Salter via Eprints-tech <[email protected]>
| Newsgroups | gmane.comp.web.eprints.devel |
|---|---|
| Message-ID | <EMEW3|f6a28398782ecd1610a45a405e803391v91Epe14eprints-tech-bounces|ecs.soton.ac.uk|DB6PR0302MB271178FCF0638B0A8837B0F5C49C0@DB6PR0302MB2711.eurprd03.prod.outlook.com> |
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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FEPScript&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=6WmaXySYkbA79f%2B9HbXwZUjyXB8z0EQvMVjE1gYotUw%3D&reserved=0 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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L11-L29&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=umpdLUMGwG5SmWltAyEefzVfazgXF0DsYUAJMbivVmI%3D&reserved=0 (documentation) https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L117-L149&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=KJrng0saNTF6Lr%2BL9VeE4ROkuonSW4MTgekvvu6HG7w%3D&reserved=0 (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: [email protected] [mailto:[email protected]] On Behalf Of Stefan Wellsandt via Eprints-tech Sent: 02 October 2019 14:27 To: [email protected] 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 *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech *** Archive: http://www.eprints.org/tech.php/ *** EPrints community wiki: http://wiki.eprints.org/ *** EPrints developers Forum: http://forum.eprints.org/