Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5957097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:21:08+00:00 2026-05-22T18:21:08+00:00

I need to perform a regular expression style replacement of querystrings from all the

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:21:09+00:00Added an answer on May 22, 2026 at 6:21 pm

    If you’re using XSLT 2.0, you can use tokenize():

      <xsl:template match="media:content">
        <xsl:value-of select="tokenize(@url,'\?')[1]"/>
      </xsl:template>
    

    Here’s another example of only changing the url attribute of media:content:

      <xsl:template match="media:content">
        <media:content url="{tokenize(@url,'\?')[1]}">
          <xsl:copy-of select="@*[not(name()='url')]"/>
          <xsl:apply-templates/>
        </media:content>
      </xsl:template>
    

    EDIT

    To handle all url attributes 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 description for testing. The attr attribute should be left untouched and the url attribute should be processed.

    XML

    <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>
        <!-- added some attributes for testing -->
        <description attr="don't delete me!" url="http://www.test.com/foo?anotherquerystring">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>
      </channel>
    </rss>
    

    XSLT

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
      <xsl:output indent="yes"/>
      <xsl:strip-space elements="*"/>
    
      <!--Identity Transform-->
      <xsl:template match="node()|@*">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="@url">
        <xsl:attribute name="url">
          <xsl:value-of select="tokenize(.,'\?')[1]"/>
        </xsl:attribute>
      </xsl:template>
    
    </xsl:stylesheet>
    

    OUTPUT (Using Saxon 9.3.0.5)

    <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>
          <!-- added some attributes for testing --><description attr="don't delete me!" url="http://www.test.com/foo">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"
                            type="video/mp4"
                            bitrate="1200"
                            height="848"
                            duration="169"
                            width="480">
                <media:title>How To Calculate Median</media:title>
            .. 
          </media:content>
          </item>
       </channel>
    </rss>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I need to write a regular expression to perform the following operations replace
I need to perform a filtered query from within a django template, to get
I need to perform a HTTP GET from PHP. More specifically, from within /index.php
I need to perform a LINQ query for both a time period from a
What steps I need to perform in order to convert asp.net 2 application from
I need to perform a simply query. Literally, all I need to perform is:
I need to perform some action when my application receives focus. I've tried hooking
I need to perform Diffs between Java strings. I would like to be able
I need to perform a complicated calculation. In my case it seemed most natural
I need to perform 9 different operations on a coordinate, depending on the position

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.