[jdom-interest] Serialization problems - possible bug?
Simon.Hall at transwareplc.com
Simon.Hall at transwareplc.com
Wed Jun 12 01:58:22 PDT 2002
Hello,
I am using JDOM beta 8 and am validating xml documents against schemas.
In our system the jdom document is serialized as a member of another
object.
The problem is that when the containing object is deserialized, one of the
namespaces (adlcpNS) is missing.
Could the problem be caused because there is no element in the document
that is currently a part of the adlcpNS namespace?
The code I use to construct the document is as follows:
Namespace defaultNS = Namespace.getNamespace(
Constants.IMSCP_ROOT_V1_P1_P2_NS);
Namespace xsiNS = Namespace.getNamespace(
Constants.XSI, Constants.XMLNS_XSI_NS );
Namespace adlcpNS = Namespace.getNamespace(
Constants.ADLCP, Constants.ADLCP_ROOT_V1_P2_NS );
// construct root
Element root = new Element(Constants.MANIFEST);
// add namespaces
root.addNamespaceDeclaration(defaultNS);
root.addNamespaceDeclaration(adlcpNS);
root.addNamespaceDeclaration(xsiNS);
// create the namespace location definitions
StringBuffer buff = new StringBuffer();
buff.append(Constants.IMSCP_ROOT_V1_P1_P2_NS)
.append(Constants.SPACE)
.append(Constants.IMSCP_ROOT_V1_P1_P2_XSD )
.append(Constants.SPACE)
.append(Constants.IMSMD_ROOT_V1_P2_P1_NS)
.append(Constants.SPACE)
.append(Constants.IMSMD_ROOT_V1_P2_P1_XSD)
.append(Constants.SPACE)
.append(Constants.ADLCP_ROOT_V1_P2_NS)
.append(Constants.SPACE)
.append(Constants.ADLCP_ROOT_V1_P2_XSD);
Attribute schemaLocation = new Attribute(Constants.SCHEMA_LOCATION,
buff.toString(), xsiNS );
root.setAttribute( schemaLocation );
// add additional attributes
root.setAttribute( Constants.IDENTIFIER, Constants.EMPTY_STRING );
root.setAttribute( Constants.VERSION, Constants.INITIAL_VERSION );
// create the organizations element
Element organizations = new Element(Constants.ORGANIZATIONS,
defaultNS );
organizations.setAttribute( Constants.DEFAULT,
Constants.EMPTY_STRING);
// create the resources element
Element resources = new Element(Constants.RESOURCES, defaultNS);
// add the organizations and resources to the root
root.addContent(organizations);
root.addContent(resources);
// create the new Document
Document doc = new Document(root);
Any suggestions would be appreciated.
Thanks,
Simon Hall
More information about the jdom-interest
mailing list