xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Unexpected NamespaceConflictException when adding xsi:schemaLocation attribute
- From: lenards AT email.arizona.edu
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] Unexpected NamespaceConflictException when adding xsi:schemaLocation attribute
- Date: Tue, 29 Jul 2008 17:05:13 -0700
Hello,
I'm trying to define a xsi:schemaLocation attribute on a response document
that
I'm producing. The code adds the "xsi" namespace prior to adding the
qualified
xsi:schemaLocation attribute, but I still get a NamespaceConflictException.
My application is using xom-1.1. The stack trace doesn't include any of the
dependencies, so I'll just mention I'm using Xerces 2.7.1.
The code is extremely pedestrian to me:
---------------------------------------
Element root = new Element(ContentElements.ROOT_RESPONSE, NS);
root.addAttribute(new Attribute("xsi:schemaLocation",
"http://www.foo.org/transfer/content/0.6
http://services.foo.org/schema/content_0_6.xsd"));
---------------------------------------
The exception states: "Attribute prefixes must be declared."
And the nu.xom portion of the stacktrace is:
# nu.xom.Attribute._setNamespace(Attribute.java:516)
# nu.xom.Attribute.<init>(Attribute.java:168)
# nu.xom.Attribute.<init>(Attribute.java:70)
I've looked in the tutorial section on namespaces
(http://xom.nu/tutorial.xhtml#d0e335) and that code is using prefixes with
registering them in the mathml example.
So I figured that the prefixing was something people wanted and it was changed
such that you need to register the namespace prefix. I tried that:
---------------------------------------
Element root = new Element(ContentElements.ROOT_RESPONSE, NS);
root.addNamespaceDeclaration("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
root.addAttribute(new Attribute("xsi:schemaLocation",
"http://www.foo.org/transfer/content/0.6
http://services.foo.org/schema/content_0_6.xsd"));
// that string is on one line... my email client is wrapping it for some
reasons
---------------------------------------
Same expection - nu.xom.NamespaceConflictException "Attribute prefixes must be
declared"
So I went back to the tutorial and realized this: "You never have to worry
about
adding xmlns and xmlns:prefix attributes. XOM always handles that for you
automatically."
I thought I'd unit test the example in my environment to make sure it wasn't a
classpath or dependency issue. I can run the mathml example without any
issue.
I figure there the fact that "xsi" is a w3c standard, maybe this garners
special
treatment. But, I can't find any XOM examples that have the
xsi:schemaLocation
defined and I would expect the usage of it to be quite common.
Can someone tell me where I'm stuffing up? I'm running out of ideas quickly.
Thanks in advance,
Andy
/****************************************
* @author: Andrew Lenards
* @email: lenards AT email.arizona.edu
* @title: Systems Programmer, Principal
* @project: Tree of Life Web Project
* @website: http://tolweb.org/
* @dept: Dept. of Entomology
* @school: University of Arizona
* @geo-loc: Tucson, AZ 85721
***************************************/
- [XOM-interest] Unexpected NamespaceConflictException when adding xsi:schemaLocation attribute, lenards, 07/29/2008
Archive powered by MHonArc 2.6.24.