Пример #1
0
 public static Map<String, String> getTitleInfo(String pid, FedoraAccess fedoraAccess)
     throws XPathExpressionException, IOException {
   Map<String, String> map = new HashMap<String, String>();
   Document biblioMods = fedoraAccess.getBiblioMods(pid);
   XPath xpath = FACTORY.newXPath();
   xpath.setNamespaceContext(new FedoraNamespaceContext());
   XPathExpression expr = xpath.compile("//mods:titleInfo/mods:title");
   NodeList set = (NodeList) expr.evaluate(biblioMods, XPathConstants.NODESET);
   for (int i = 0, ll = set.getLength(); i < ll; i++) {
     Node node = set.item(i);
     if (node.getNodeType() == Node.ELEMENT_NODE) {
       Element elm = (Element) node;
       if (elm.hasAttributeNS(FedoraNamespaces.BIBILO_MODS_URI, "type")) {
         String type = elm.getAttributeNS(FedoraNamespaces.BIBILO_MODS_URI, "type");
         map.put(type, elm.getTextContent().trim());
       } else {
         if (!map.containsKey("default")) {
           map.put("default", elm.getTextContent().trim());
         }
       }
     }
   }
   return map;
 }