[jdom-interest] namespace declaration is not appearing
Curtis Fornadley
curtisf at library.ucla.edu
Tue May 28 15:43:20 PDT 2002
Hi
Short version:
addNamespaceDeclaration() does not generate the declaration in the XML
when called a second time on the same namespace but on a child structure
Long Version:
I am using JDOM beta 8 to generate OAI 2.0 documents
I have this to genrate the root part
Namespace xmlns = Namespace.getNamespace("http://www.openarchives.org/OAI/2.0/");
Element root = new Element("OAI-PMH",xmlns);
jdocGetRecord = new Document(root);
Namespace xsi = Namespace.getNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
root.addNamespaceDeclaration(xsi);
Attribute attSchema = new Attribute("schemaLocation",
"http://www.openarchives.org/OAI/2.0/ " +
"http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd",
xsi);
root.setAttribute(attSchema);
Which generates:
<OAI-PMH
xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
etc.
BUT this code
Namespace oai_dc =
Namespace.getNamespace("oai_dc","http://www.openarchives.org/OAI/2.0/oai_dc/");
Namespace dc =
Namespace.getNamespace("dc","http://purl.org/dc/elements/1.1/");
// access to xsi namespace from above
Element dcElement = new Element("dc",oai_dc);
dcElement.addNamespaceDeclaration(dc);
dcElement.addNamespaceDeclaration(xsi); // this does not print out???
Attribute attDcSchema = new Attribute("schemaLocation",
"http://www.openarchives.org/OAI/2.0/oai_dc/ " +
"http://www.openarchives.org/OAI/2.0/oai_dc.xsd",
xsi);
dcElement.setAttribute(attDcSchema);
Generates:
<oai_dc:dc
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
Thus, dcElement.addNamespaceDeclaration(xsi) is NOT generating the
namespace declaration
I spoke with the OAI authers and they have this declaration in there so
that the DC portion can stand on it's own if necessary
Thanks for any help
Curtis Fornadley
310.206.9782
Fax: 310.206.5337
More information about the jdom-interest
mailing list