Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Defining schema location

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Daniel Garrido <djbgarrido AT gmail.com>
  • Cc: XOM-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Defining schema location
  • Date: Mon, 10 Mar 2008 20:28:09 -0700

Daniel Garrido wrote:
Hi!

I'd like to know how to create the root element with the following
definitions:

<cns:Constraints xmlns:cns="http://www.example.org/Constraints";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.example.org/Constraints
../../../Structures/Constraints/Constraints.xsd ">
...
</cns:Constraints>

I've already been able to write a xml with all namespace definitions,
but not with the schemaLocation. Nextly i'll post the code i'm using:

String namespace = "http://www.example.org/Constraints";;
String prefix = "cns:";
Element root = new Element(prefix + "Constraints", namespace);
root.addNamespaceDeclaration("xsi",
"http://www.w3.org/2001/XMLSchema-instance";);


There's no code there to add the attribute. You need to add the xsi:schemaLocation attribute, not the namespace declaration. (Adding the declaration won't hurt, but it's njot necessary.)


--
Elliotte Rusty Harold elharo AT metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/




Archive powered by MHonArc 2.6.24.

Top of Page