Xerces 2.4 / namespace error

Discussion in 'Java' started by edwinek, Oct 8, 2003.

  1. edwinek

    edwinek Guest

    While trying to migrate an application from Websphere 3.5 to Websphere
    5, I encountered a weird problem. When reading an XML file into a
    DOMResult object, I get the following error:

    org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create
    or change an object in a way which is incorrect with regard to
    namespaces.
    at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:354)
    at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1042)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
    Source)
    ....

    The source:

    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;

    import org.apache.tools.ant.filters.*;
    import org.apache.xerces.impl.*;
    import org.w3c.dom.*;

    ....

    Version version = new Version();
    System.out.println("Version: "+version.getVersion());
    DOMResult domResult = new DOMResult();
    try {
    Transformer identityTransformer =
    TransformerFactory.newInstance().newTransformer();
    String xml =
    "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
    + "<validation:config xmlns:validation=\"http://domain.nl\">"
    + " <validation:resourceManager attr=\"someattr\>"
    + "</validation:config>";

    InputStream inputStream = new StringInputStream(xml);
    identityTransformer.transform(new StreamSource(inputStream),
    domResult);
    } catch (Exception e) {
    e.printStackTrace();
    }

    This doesn't happen using 1.x versions of Xalan and Xerces, but does
    with the IBM versions and the latest versions from Apache. So it seems
    to be a version 1/version 2 issue. Any ideas on how to solve this
    problem?

    Regards,
    Edwin
     
    edwinek, Oct 8, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cvissy
    Replies:
    0
    Views:
    623
    cvissy
    Nov 16, 2004
  2. S ML
    Replies:
    0
    Views:
    436
  3. VanOrton
    Replies:
    2
    Views:
    2,568
    VanOrton
    Nov 30, 2005
  4. jacksu
    Replies:
    18
    Views:
    8,348
  5. -saarland.de
    Replies:
    1
    Views:
    571
    Joe Kesselman
    Nov 21, 2006
Loading...

Share This Page