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

  • SEARCH
  • Home
  • 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 674153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:40:28+00:00 2026-05-14T00:40:28+00:00

Hi I want to work around a ‘bug’ in certain RSS-feeds , which use

  • 0

Hi I want to work around a ‘bug’ in certain RSS-feeds, which use an incorrect namespace for the mediaRSS module. I tried to do it by manipulating the DOM programmatically, but using XSLT seems more flexible to me.

Example:

<media:thumbnail xmlns:media="http://search.yahoo.com/mrss" url="http://www.suedkurier.de/storage/pic/dpa/infoline/brennpunkte/4311018_0_merkelxI_24280028_original.large-4-3-800-199-0-3131-2202.jpg" />
<media:thumbnail url="http://www.suedkurier.de/storage/pic/dpa/infoline/brennpunkte/4311018_0_merkelxI_24280028_original.large-4-3-800-199-0-3131-2202.jpg" />

Where the namespace must be http://search.yahoo.com/mrss/ (mind the slash).

This is my stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="//*[namespace-uri()='http://search.yahoo.com/mrss']">
        <xsl:element name="{local-name()}" namespace="http://search.yahoo.com/mrss/" >
            <xsl:apply-templates select="@*|*|text()" />
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Unfortunately the result of the transformation is an invalid XML and my RSS-Parser (ROME Library) does not parse the feed anymore:

java.lang.IllegalStateException: Root element not set
    at org.jdom.Document.getRootElement(Document.java:218)
    at com.sun.syndication.io.impl.RSS090Parser.isMyType(RSS090Parser.java:58)
    at com.sun.syndication.io.impl.FeedParsers.getParserFor(FeedParsers.java:72)
    at com.sun.syndication.io.WireFeedInput.build(WireFeedInput.java:273)
    at com.sun.syndication.io.WireFeedInput.build(WireFeedInput.java:251)
    ... 8 more

What is wrong with my stylesheet?

  • 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-14T00:40:28+00:00Added an answer on May 14, 2026 at 12:40 am

    You have half of the solution in your stylesheet.

    You have put in a template to match (and correct) the elements with the wrong Media RSS namespace, but you don’t have anything to match the other elements/attributes in the RSS feed.

    The built-in template rules are matching the rest of the document nodes, which will only copy the text nodes into the output. That does not preserve the original RSS feed’s XML and produces output that is not valid RSS XML structure.

    Adding an identity transform template will ensure that the other nodes and attributes get copied into the output and will preserve the document content/structure.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <!--identity transform that will copy matched node/attribute to the output and apply templates for it's children and attached attributes-->
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="@*|*|text()" />
            </xsl:copy>
        </xsl:template>
    
        <!--Specialized template to match on elements with the incorrect namespace and generate a new element-->
        <xsl:template match="//*[namespace-uri()='http://search.yahoo.com/mrss']">
            <xsl:element name="{local-name()}" namespace="http://search.yahoo.com/mrss/" >
                <xsl:apply-templates select="@*|*|text()" />
            </xsl:element>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I personally don't use FxCop yet. We want to work out the unit testing
the company I work for want to use a hosted payment form to charge
I want to work around the fact that my WCF servicelayer can not handle
I've recently started work on a new project using PHP5 and want to use
Want my FireFox at work to be in sync with my FireFox at my
I work on a large project and want to disable the Eclipse compiler warning
I work on relatively sensitive code that we wouldn't want falling into the wrong
I want to create a game that will work both locally and online. My
I want Vim 's completion menu to work more like the one in Visual
I work in VBA, and want to parse a string eg <PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

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.