Opened 16 years ago
Closed 13 years ago
#82 closed defect (invalid)
problem with subtemplates and schema ordering
Reported by: | ajs6f | Owned by: | simon |
---|---|---|---|
Priority: | minor | Milestone: | v2.6.3 |
Component: | User interface (web) | Version: | v2.2.0 Final |
Keywords: | subtemplate, EditLib, DataManager | Cc: |
Description
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.
Change History (5)
comment:1 by , 16 years ago
Milestone: | v2.2.0 Final |
---|---|
Owner: | changed from | to
comment:2 by , 16 years ago
Milestone: | → v2.5.0 |
---|
Simon Pigot wants to contact the bug submitter to discuss the bug.
comment:3 by , 15 years ago
Milestone: | v2.5.0 → v2.5.1 |
---|
comment:4 by , 14 years ago
Milestone: | v2.5.1 → v2.6.2 |
---|
comment:5 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Code has changed almost entirely since this was reported - subtemplates are added in the correct place by the new code.
Subtemplates are not activated in trunk, 2.4.0