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 679097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:13:20+00:00 2026-05-14T01:13:20+00:00

I am trying to detetct/work around this bug in RSS elements. That means I

  • 0

I am trying to detetct/work around this bug in RSS elements.
That means I have to find a wrong namespace-declaration and change its
value to the correct namespace. E.g:

xmlns:media="http://search.yahoo.com/mrss" 

must be:

xmlns:media="http://search.yahoo.com/mrss/" 

How can I achive that given a org.w3c.Document?

I meanwile found out how to get all elements of a certain namespace:

        XPathFactory xpf = XPathFactory.newInstance();
        XPath xpath = xpf.newXPath();
        XPathExpression expr = xpath.compile("//*[namespace-uri()='http://search.yahoo.com/mrss']");


        Object result = expr.evaluate(d, XPathConstants.NODESET);
        if (result != null) {
            NodeList nodes = (NodeList) result;
            for(int node=0;node<nodes.getLength();node++)
            {
                Node n = nodes.item(node);
                this.log.warn("Found old mediaRSS namespace declaration: "+n.getTextContent());
            }

        } 

So now I have to figure out how to change the namespace of a Node via JAXP.

  • 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-14T01:13:21+00:00Added an answer on May 14, 2026 at 1:13 am

    Just for the sake of completeness:

    Java Code:

    Document d = out.outputW3CDom(converted);
                DOMSource oldDocument = new DOMSource(d);
                DOMResult newDocument = new DOMResult();
                TransformerFactory tf = TransformerFactory.newInstance();
                StreamSource xsltsource = new StreamSource(
                        getStream(MEDIA_RSS_TRANSFORM_XSL));
                Transformer transformer = tf.newTransformer(xsltsource);
                transformer.transform(oldDocument, newDocument);
    
    private InputStream getStream(String fileName) {
        InputStream xslStream = Thread.currentThread().getContextClassLoader()
                    .getResourceAsStream("/" + fileName);
        if (xslStream == null) {
            xslStream = Thread.currentThread().getContextClassLoader()      .getResourceAsStream(fileName);
            }
            return xslStream;
        }
    

    Stylesheet:

    <?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>
    

    Special thanks to Mads Hansen for his help with the XSLT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to work with several documents that all have various encodings -
I have spent the last several hours trying to get this to work and
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
I am trying to detect which web in sharepoint that the user is looking
I'm trying to figure out a way to detect files that are not opened
Trying to get my css / C# functions to look like this: body {
So the problem that I am having appears to be a bug that occurs
Today I have seen this weird magic NTFS system supports: each file can have
I am playing around with xCode and was trying to create a small app
I have a few divs that are created using PHP. The anchor within the

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.