Package nu.xom

Examples of nu.xom.Element.detach()


      for(int i=0;i<paperNodes.size();i++) {
        Element e = (Element)paperNodes.get(i);
        Nodes idNodes = e.query("art:front/art:article-meta/art:article-id[@pub-id-type='publisher-id']", xpc);
        String name = idNodes.get(0).getValue();
        File outFile = new File(testDir, name + ".xml");
        e.detach();
        Document outDoc = new Document(e);
        new Serializer(new FileOutputStream(outFile)).write(outDoc);
        //XOMTools.clearNamespaces(outDoc.getRootElement());
        //Document sciXML = XSLTransform.toDocument(xslt.transform(outDoc));
        //File sciXMLFile = new File(testDir, name + ".sci.xml");
View Full Code Here


          ee = ((Element)nn.get(0)).getChildElements("slot");
          for(int j=0;j<ee.size();j++) {
            Element eee = ee.get(j);
            String name = eee.getAttributeValue("name");
            if(!noCopySlots.contains(name)) {
              eee.detach();
              e.appendChild(eee);
            }
          }
          //System.out.println(e.toXML());
        } else if(nn.size() > 1) {
View Full Code Here

      }
     
      n = autoSaf.query("/saf/annot[slot[@name='type']/.='ONT']");
      for(int i=0;i<n.size();i++) {
        Element e = (Element)n.get(i);
        e.detach();
        saf.getRootElement().appendChild(e);
      }
      SafTools.numberSaf(saf, "oscar", "o");
     
      Serializer ser = new Serializer(System.out);
View Full Code Here

      String [] translated = translateXPoints(from, to);
      if(translated == null) {
        System.out.println("Couldn't translate annot:");
        System.out.println(e.toXML());
        System.out.println();
        e.detach();
      } else {
        e.addAttribute(new Attribute("from", translated[0]));
        e.addAttribute(new Attribute("to", translated[1]));
      }
    }
View Full Code Here

        if(n.get(i).query(".//ArticleTitle").size() == 0) continue;
        if(n.get(i).query(".//AbstractText").size() == 0) continue;
        if(n.get(i).query(".//PMID").size() == 0) continue;
        String id = n.get(i).query(".//PMID").get(0).getValue();
        Element elem = (Element)n.get(i);
        elem.detach();
        Document d = new Document(elem);
        Document out = XSLTransform.toDocument(xslt.transform(d));
        docs.put(id, SciXMLDocument.makeFromDoc(out));
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

      Element e = (Element)proxyNodes.get(i);
      ParentNode eParent = e.getParent();
      int index = eParent.indexOf(e);
      int pin = Integer.parseInt(e.getAttributeValue("pinumber"));
      ProcessingInstruction pi = procInstructions.get(pin);
      e.detach();
      eParent.insertChild(pi, index);
    }       
  }
 
  public Document getSciXML() {
View Full Code Here

      String toXPoint = annot.getAttributeValue("to");
     
      fromXPoint = transformXPoint(fromXPoint);
      toXPoint = transformXPoint(toXPoint);
      if(fromXPoint == null || toXPoint == null) {
        annot.detach();
      } else {
        annot.addAttribute(new Attribute("from", fromXPoint));
        annot.addAttribute(new Attribute("to", toXPoint));
      }
    }
View Full Code Here

        public void deleteScrap(String sid) throws Exception {
                Nodes n = doc.query("//snippet[@id='" + sid + "']");
                if (n.size() == 1) {
                        Element p = (Element) n.get(0).getParent();
                        p.detach();
                        writeScrapBook();
                }
        }

        public void setSnippetProperty(String sid, String property,
View Full Code Here

        private void refreshNavElements() {
                Nodes n = doc.query("//scrapbook");
                Element nav = (Element) n.get(0);
                XOMTools.insertAfter(nav, makeNavElement("show"));
                nav.detach();
        }

}
View Full Code Here

        for(int j = 0; j < sentenceChildren.size(); j++) {
          //System.out.println(sentenceChildren.get(j));
        }
        ParentNode parent = sentenceElement.getParent();
        int childIndex = parent.indexOf(sentenceElement);
        sentenceElement.detach();
       
        //Elements sentenceContent = sentenceElement.getChildElements();
        //System.out.println("content of sentence: " + sentenceContent);
        ArrayList<Attribute> attArray = new ArrayList<Attribute>();
        attArray.add(new Attribute("atype", "GSC"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.