[jdom-interest] Setting schema locations

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Mar 20 10:56:32 PST 2001


> What is the call to add a schema location specified with
> xsi:schemaLocation?
> 
> <treq:REQUEST 
> xmlns:treq="http://www.digitalesp.com/te/schemas" xmlns:xsi="
> http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="
> http://www.digitalesp.com/te/schemas C:
> \itp\workbench\DigitalESPTimeReporting\TimeReporting\schemas\t
> imerequest.xsd
> ">

To produce:

<treq:REQUEST xmlns:treq="http://www.digitalesp.com/te/schemas"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://www.digitalesp.com/te/schemas etc" />

Use:

Namespace digitalesq = Namespace.getNamespace("treq",
"http://www.digitalesp.com/te/schemas");

Namespace schema = Namespace.getNamespace(
"xsi", "http://www.w3.org/2000/10/XMLSchema-instance");

Element el = new Element("REQUEST", digitalesq);
el.addNamespaceDeclaration(schema);

Attribute att = new Attribute("schemaLocation", 
"http://www.digitalesp.com/te/schemas etc",
schema);

el.addAttribute(att);

XMLOutputter out = new XMLOutputter("  ", true);

out.output(el, System.out);



More information about the jdom-interest mailing list