Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Wrong namespace URI for xml prefix

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Jim Downing <ojd20 AT cam.ac.uk>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Wrong namespace URI for xml prefix
  • Date: Tue, 11 Oct 2005 20:21:34 +0100

Elliotte Harold wrote:

Jim Downing wrote:

Hi all,

in trying to move from the default Builder to one that uses a ResolvingXMLReader I've come across an error I can't figure out. I'm pretty sure it's not a XOM problem, but unfortunately don't understand what's going on well enough to figure out where the problem _is_ arising.


As I recall, that library did not handle namespaces correctly. There may be a more recent version in CVS that does. If you can reduce it to a self-contained test case, I may be able to provide more detailed instructions.

The attached test case throws the exception.

The exception is thrown whether or not the catalog is enabled and present. Removing the <script/> element from the xhtml fragment makes the test pass. The exception trace: -

nu.xom.ParsingException: Wrong namespace URI for xml prefix:
at nu.xom.Builder.build(Builder.java:1142)
at nu.xom.Builder.build(Builder.java:1019)
at nu.xom.tests.ResolvingBuilderTest.testResolvingBuilder(ResolvingBuilderTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: nu.xom.NamespaceConflictException: Wrong namespace URI for xml prefix:
at nu.xom.Attribute._setNamespace(Attribute.java:495)
at nu.xom.Attribute.<init>(Attribute.java:168)
at nu.xom.NodeFactory.makeAttribute(NodeFactory.java:253)
at nu.xom.XOMHandler.startElement(XOMHandler.java:161)
at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
at org.apache.xml.resolver.tools.ResolvingXMLFilter.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:333)
at org.apache.xml.resolver.tools.ResolvingXMLFilter.parse(Unknown Source)
at nu.xom.Builder.build(Builder.java:1125)
... 17 more

Going through the self contained test case has (as per) helped me understand more: "Script" is the only element in the xhtml fragment whose description in the XHTML DTD contains an xml prefixed attribute (xml:space).

Thanks for the help,
jim

package nu.xom.tests;

import java.io.StringReader;

import nu.xom.Builder;

import org.apache.xml.resolver.tools.ResolvingXMLReader;

public class ResolvingBuilderTest extends XOMTestCase {

public ResolvingBuilderTest(String name) {
super(name);
}

public void testResolvingBuilder() throws Exception {
try {
String xhtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD
XHTML 1.0 Transitional//EN\" "
+
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\";>\n"
+ "<html
xmlns=\"http://www.w3.org/1999/xhtml\";>\n"
+ "<head>\n"
+ "<script type=\"text/javascript\"
src=\"js/fsmenu.js\">/* */</script>"
+ "<title>Test</title>\n"
+ "</head>\n"
+ "<body>\n"
+ "<div id=\"banner\"/>" +
"</body>\n" + "</html>";
StringReader in = new StringReader(xhtml);
// System.setProperty("xml.catalog.files",
"catalog.xml");
Builder builder = new Builder(new
ResolvingXMLReader());
builder.build(in);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}



Archive powered by MHonArc 2.6.24.

Top of Page