#82: problem with subtemplates and schema ordering
-----------------------------------------------+----------------------------
Reporter: ajs6f | Owner: geonetwork-devel@lists.sourceforge.net
Type: defect | Status: new
Priority: minor | Milestone: v2.2.0 Final
Component: User interface (web) | Version: v2.2.0 Final
Keywords: subtemplate, EditLib, DataManager |
-----------------------------------------------+----------------------------
In org.fao.geonet.kernel.DataManager.addElement(Dbms dbms, String id,
String ref, String name, String childName, String currVersion)
we find:
if (childName.startsWith("_s"))
{
// add subtemplate
String sid = childName.substring(2);
Element subtemplate = XmlSerializer.select(dbms,
"Metadata", sid);
el.addContent(subtemplate);
}
else
{
// normal element
Element child = editLib.addElement(schema, el,
name);
MetadataSchema mds = editLib.getSchema(schema);
if (!childName.equals(""))
{
// or element
String uChildName =
editLib.getUnqualifiedName(childName);
String prefix = editLib.getPrefix(childName);
String ns = editLib.getNamespace(childName,md,mds);
if (prefix.equals("")) {
prefix = editLib.getPrefix(el.getName());
ns = editLib.getNamespace(el.getName(),md,mds);
}
Element orChild = new Element(uChildName,prefix,ns);
child.addContent(orChild);
//--- add mandatory sub-tags
editLib.fillElement(schema, child, orChild);
}
}
Sorry if that gets banged up by the web form. The point is that non-
subtemplate element additions get added to the instance by
EditLib.addElement(schema, el, name), which puts the new element in proper
schema order. Subtemplate-produced elements, however, get added by
el.addContent(subtemplate), a JDOM method which simply adds them to the
end of their enclosing parent's children. You can see this go wrong out of
the box by adding a gmd:pointOfContact element to an ISO19139 instance. It
gets added at the end of gmd:DataIdentification or
gmd:ServiceIdentification, which is invalid. You can work around the
problem by operating without subtemplates, or only use subtemplates that
are legal at the end of their enclosing parent (like the example
gmd:DistributionInfo) but the best fix would be to replace the JDOM call
with the EditLib call, unless that breaks something else.
--
Ticket URL: <http://trac.osgeo.org/geonetwork/ticket/82>
GeoNetwork opensource Developer website <http://trac.osgeo.org/geonetwork>
GeoNetwork opensource is a standards based, Free and Open Source catalog application to manage spatially referenced resources through the web. It provides powerful metadata editing and search functions as well as an embedded interactive web map viewer. This website contains information related to the development of the software.