private List disseminateListInternal(DSpaceObject dso, boolean addSchema) throws CrosswalkException, IOException, SQLException, AuthorizeException { if (dso.getType() != Constants.ITEM) throw new CrosswalkObjectNotSupported( "MODSDisseminationCrosswalk can only crosswalk an Item."); Item item = (Item) dso; initMap(); MetadataValue[] dc = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); List result = new ArrayList(dc.length); for (int i = 0; i < dc.length; i++) { // Compose qualified DC name - schema.element[.qualifier] // e.g. "dc.title", "dc.subject.lcc", "lom.Classification.Keyword" String qdc = dc[i].getMetadataField().getSchema() + "." + ((dc[i].getMetadataField().getQualifier() == null) ? dc[i].getMetadataField().getElement() : (dc[i].getMetadataField().getElement() + "." + dc[i].getMetadataField().getQualifier())); modsTriple trip = (modsTriple) modsMap.get(qdc); if (trip == null) log.warn("WARNING: " + getPluginInstanceName() + ": No MODS mapping for \"" + qdc + "\""); else { try { Element me = (Element) trip.xml.clone(); if (addSchema) me.setAttribute("schemaLocation", schemaLocation, XSI_NS); Iterator ni = trip.xpath.selectNodes(me).iterator(); if (!ni.hasNext()) log.warn( "XPath \"" + trip.xpath.getXPath() + "\" found no elements in \"" + outputUgly.outputString(me) + "\", qdc=" + qdc); while (ni.hasNext()) { Object what = ni.next(); if (what instanceof Element) ((Element) what).setText(dc[i].getValue()); else if (what instanceof Attribute) ((Attribute) what).setValue(dc[i].getValue()); else if (what instanceof Text) ((Text) what).setText(dc[i].getValue()); else log.warn("Got unknown object from XPath, class=" + what.getClass().getName()); } result.add(me); } catch (JDOMException je) { log.error( "Error following XPath in modsTriple: context=" + outputUgly.outputString(trip.xml) + ", xpath=" + trip.xpath.getXPath() + ", exception=" + je.toString()); } } } return result; }