Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Setting schema declaration on root element

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Daniel Rohlfs" <drohlfs AT gmx.net>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Setting schema declaration on root element
  • Date: Wed, 29 Nov 2006 16:45:21 +0100

Hi, I'm new to this list and new to XOM (2+ Weeks now).

This is something I can't figure out.

I want the root element of my xml to look like this:
<root xsi:noNamespaceSchemaLocation="schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>

Adding the namespace declaration poses no problems with:
root.addNamespaceDeclaration("xsi",
"http://www.w3.org/2001/XMLSchema-instance";);

But the schema declaration, I can't get this to work.
If I add it like this:
Attribute schemaDecl = new Attribute("xsi:noNamespaceSchemaLocation",
"assetpos.xsd");
root.addAttribute(schemaDecl);

I get this error message:
nu.xom.NamespaceConflictException: Attribute prefixes must be declared.
at nu.xom.Attribute._setNamespace(Attribute.java:516)
at nu.xom.Attribute.<init>(Attribute.java:168)
at nu.xom.Attribute.<init>(Attribute.java:70)

When I try it like this:
Attribute schemaDecl = new Attribute("xsi", "noNamespaceSchemaLocation",
"assetpos.xsd", Attribute.Type.UNDECLARED);
root.addAttribute(schemaDecl);
I get the error message:
Unprefixed attribute xsi cannot be in default namespace
noNamespaceSchemaLocation

When I try to set the prefix like this:
root.setNamespacePrefix("xsi");
I get the error message:
nu.xom.NamespaceConflictException: xsi conflicts with existing prefix

If I try to get the prefix like this:
String prefix = root.getNamespacePrefix();
Then it returns a null value.

Any help would be heavily appreaciated, as I really can't figure this out.
I'm convinced it's not a XOM problem, but a problem of my stupidity... and
well I've hit a wall as I'm out of ideas now. And google doesn't tell me much
to the topic as well.

Thanks a lot in advance.

Daniel


--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!




Archive powered by MHonArc 2.6.24.

Top of Page