I need to perform a regular expression style replacement of querystrings from all the attributes in an MRSS RSS feed, stripping them down to just the url. I’ve tried a few things here using suggests from here: XSLT Replace function not found but to no avail
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
<atom:link href="http://www.videojug.com/user/metacafefamilyandeducation/subscriptions.mrss" type="application/rss+xml" rel="self" />
<title>How to and instructional videos from Videojug.com</title>
<description>Award-winning Videojug.com has over 50k professionally-made instructional videos.</description>
<link>http://www.videojug.com</link>
<item>
<title>How To Calculate Median</title>
<media:content url="http://direct.someurl.com/54/543178dd-11a7-4b8d-764c-ff0008cd2e95/how-to-calculate-median__VJ480PENG.mp4?somequerystring" type="video/mp4" bitrate="1200" height="848" duration="169" width="480">
<media:title>How To Calculate Median</media:title>
..
</media:content>
</item>
any suggestions really helpful
If you’re using XSLT 2.0, you can use
tokenize():Here’s another example of only changing the
urlattribute ofmedia:content:EDIT
To handle all
urlattributes in your instance, and leave everything else unchanged, use an identity transform and only override it with a template for@url.Here’s a modified version of your sample XML. I’ve added two attributes to
descriptionfor testing. Theattrattribute should be left untouched and theurlattribute should be processed.XML
XSLT
OUTPUT (Using Saxon 9.3.0.5)