Trying to format a JEXL location scheme for publishing

Hi folks,

Quick question;

Our original implementation (using the old 5.7 publishing mechanism, content lists generated by the XML engine and all) of the publisher uses a custom Java exit (created for us during our original PSO engagement) on the location generators in rxs_Support_pub to force all published URLs into alphanumeric lower case, with anything not alphanumeric being forced into becoming a hyphen, so you’d get the following effect….

standard publish path;
/Department and Programs/Patient Care/Doctors&Nurses/Index.html

would become;
/department-and-programs/patient-care/doctors-nurses/index.html

Now, we need this functionality for our new WWW implementation, but we want to use the new publishing mechanism, so no more rxs_Support_pub, no more java exits, and welcome to JEXL.

I’ve found a Roll-Your-Own-JEXL-Expression tutorial on the forum ( http://forum.percussion.com/showthread.php?t=2051&highlight=jexl ) and I’m hacking away at that to see if I can’t build myself something to do what I need out of my original PSO source code (which I carefully kept, but which needs a bit of refactoring.)

However, that’s going to take me quite some time so I thought I’d fire off a quick post to see if there was something premade that I could steal to do the job. I don’t imagine we’re the first customer to need slightly specific URL munging…

I did have a dig through the PSO toolkit javadocs without much success.

Heck, for all I know there’s already plenty of JEXL available to me already to do what I need, and I’ve just failed to find the documentation… I can be surprisingly dumb like that…

Any and all help much appreciated…

Cheers

Dermot Conner

As far as I know, once you get your filename/path into a variable (e.g. $filename = $sys.item.Property(‘rx:displaytitle’).String) you can manipulate it using any instance methods of java.lang.String. Since Java 1.4, that includes regular expressions.

Hi Dermot

You need to use .replaceAll(regex, replacement) and .toLowerCase() in order to acheive your desired filename.

$filename = $sys.item.getProperty("rx:displaytitle").String
$fullpath = $sys.pub_path + $filename
$transformed = $fullpath.replaceAll('<(.|
)+?>','-').toLowerCase()

The regex will remove all punctuation and replace it with a hyphen. You may have to play around with it to get the results you want.

Cheers
James

Fantastic, thanks muchly.

For the record (and anyone else in the same position searching the forum), this is a simplified version of what worked in the end…


$filename = $sys.template.prefix + 'item' + $sys.item.getProperty('rx:sys_contentid').String; $fullpath = $sys.pub_path + $filename; $transformed = $fullpath.replaceAll('[^a-zA-Z0-9/]','-').toLowerCase(); $transformed + '.html';

Cheers

Dermot