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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:21:10+00:00 2026-05-23T13:21:10+00:00

I have a problem parsing an xml, actually transforming it. The error I get

  • 0

I have a problem parsing an xml, actually transforming it.

The error I get is:

ERROR:  'Namespace for prefix 'SOAP-ENV' has not been declared.'
Jul 8, 2011 3:24:54 PM kumar.runs.start$2 run
SEVERE: null
javax.xml.transform.TransformerException: java.lang.RuntimeException: Namespace for prefix 'SOAP-ENV' has not been declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:716)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313).........

The code I use is:

    SAXParserFactory saxFactory = SAXParserFactory.newInstance(); 
    SAXParser parser = saxFactory.newSAXParser(); 
    XMLReader reader = new XMLTrimFilter(parser.getXMLReader()); 

    TransformerFactory factory = TransformerFactory.newInstance(); 
    Transformer transformer = factory.newTransformer(); 
    transformer.setOutputProperty(OutputKeys.INDENT, "no"); 
    DOMResult result = new DOMResult(); 
    SAXSource ss = new SAXSource(reader, is);
    transformer.transform(ss, result); 
    return (Document)result.getNode(); 

XMLTrimFilter is custom implementation, extends XMLFilterImpl.

Also I came across this:

A Bug

but it is a rather old issue.
Does anybody have an idea how to fix it?

Thanks!

[Edit:
the xml:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Header />
    <SOAP-ENV:Body>
            <swp:addOwnRet xmlns:swbep="urn:SWBEP">
                  <apples>33</apples>
                  <bucket>
                    <orange>5</orange>
                    <banana>5</banana>
                  </bucket>
            </swp:addOwnRet>
    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

]

Edit 2:

XMLTrimFilter:

package kumar.srcs;

import java.io.CharArrayWriter;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl;

public class XMLTrimFilter extends XMLFilterImpl{

private CharArrayWriter contents = new CharArrayWriter(); 

public XMLTrimFilter(XMLReader parent){ 
    super(parent); 
} 
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{ 
    writeContents(); 
    super.startElement(uri, localName, qName, atts); 
}

public void characters(char ch[], int start, int length){ 
    contents.write(ch, start, length); 
} 

public void endElement(String uri, String localName, String qName) throws SAXException{ 
    writeContents(); 
    super.endElement(uri, localName, qName); 
} 

public void ignorableWhitespace(char ch[], int start, int length){} 

private void writeContents() throws SAXException{ 
    char ch[] = contents.toCharArray(); 
    if(!isWhiteSpace(ch)) 
        super.characters(ch, 0, ch.length); 
    contents.reset(); 
} 

private boolean isWhiteSpace(char ch[]){ 
    for(int i = 0; i<ch.length; i++){ 
        if(!Character.isWhitespace(ch[i])) 
            return false; 
    } 
    return true; 
} 

}

  • 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-23T13:21:11+00:00Added an answer on May 23, 2026 at 1:21 pm

    We don’t have enough information, but the first two things I would suspect are:

    1. The input XML doesn’t declare the namespace properly; i.e. it is invalid XML.

    2. There is a bug in your custom XMLTrimFilter class.


    The Sun bug is against a really old version of JAXP and was fixed a long time ago. And it doesn’t much resemble your case … to me.


    The XML that you pasted is missing a namespace declaration, and will give errors if you try to parse it with a validating namespace aware XML parser. This could be the cause of your problems, though the error message doesn’t seem right. A more likely cause is your custom filter, IMO.

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

Sidebar

Related Questions

I have problem in parsing XML containing gsm packets through my .Net application.I want
I have problem with parsing XML. I parsed data of cities, Amsterdam & Den
i have a problem while building and running an iphone application.Im using xml parsing
i've been facing problem with xml parsing in chrome. so i've posted a question
I have been doing some XML parsing in my application. I used the following
I got a problem regarding parsing XML data. I have divided my program into
I have problem with my Java program. How I read xml -file which has
I have a problem with parsing xml by an android, a document that is
Ok, I have a very frustrating problem. I am parsing a webpage and need
I have a problem for parsing a rss feed using c#. I used to

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.