Package nu.xom

Examples of nu.xom.Element.toXML()


   
    // a very weird case but legal
    public void testXMLPrefixOnElement() {
        Element e = new Element("xml:test", "http://www.w3.org/XML/1998/namespace");
        assertEquals(0, e.getNamespaceDeclarationCount());
        assertEquals("<xml:test />", e.toXML());
        try {
            e.getNamespacePrefix(0);
            fail("Got prefix beyond bounds");
        }
        catch (IndexOutOfBoundsException success) {
View Full Code Here


    for(int i=0;i<n.size();i++) {
      Element e = (Element)n.get(i);
      if(excludeNodes.contains(e)) continue;
      if(e.getValue().length() == 0) continue;
      String xPoint = XOMTools.getXPointToNode(e, doc.getRootElement());
      String a = e.toXML();
      String b = XOMTools.getNodeAtXPoint(doc.getRootElement(), xPoint).toXML();
      if(!a.equals(b)) {
        System.err.println("Yikes!");
        System.err.println(a);
        System.err.println(b);
View Full Code Here

      // Different values in each field
      Element element = Util.buildElement(TEST_PREFIX, "newName", TEST_NAMESPACE,
        "This is an extensible element.");
      ExtensibleElement.Builder builder = new ExtensibleElement.Builder();
      builder.setXml(element.toXML());
      assertFalse(elementComponent.equals(builder.commit()));
    }
  }

  @Test
View Full Code Here

          Element e = (Element)epNodes.get(j);
          String fromto = e.getAttributeValue("cfrom") + ":" + e.getAttributeValue("cto");
          if(neMap.containsKey(fromto)) {
            String id = neMap.get(fromto).get(0);
            Element annot = (Element)saf.query("/saf/annot[@id='" + id + "']").get(0);
            System.out.println(annot.toXML());
            String xpfrom = annot.getAttributeValue("from");
            String xpto = annot.getAttributeValue("to");
            Nodes newAnnotNodes = newSaf.query("/saf/annot[@from='" + xpfrom + "'][@to='" + xpto + "']");
            System.out.println(xpfrom + "\t" + xpto + "\t" + newAnnotNodes.size());
            if(newAnnotNodes.size() > 0) {
View Full Code Here

      Document relDoc = new Builder().build(new File(paperDir, "relations.xml"));
      //Nodes annots = safDoc.query("/saf/annot[slot[@name='InChI'][.='" + inchiStr + "']]");
      Nodes annots = safDoc.query("/saf/annot[slot[@name='ontIDs'][contains(.,'" + ontID + "')]]");
      for(int i=0;i<annots.size();i++) {
        Element e = (Element)annots.get(i);
        System.out.println(e.toXML());
        String id = e.getAttributeValue("id");
        Nodes rels = relDoc.query("/relations/relation[item/@itemid='" + id + "']");
        for(int j=0;j<rels.size();j++) {
          hasRel = true;
          System.out.println("\t" + rels.get(j).toXML());
View Full Code Here

      } else {
        if(verbose) System.out.println("******************************************");
        if(verbose) System.out.println("Eeek: couldn't align");
        if(verbose) System.out.println(elem1.toXML());
        if(verbose) System.out.println("with");
        if(verbose) System.out.println(elem2.toXML());
        if(verbose) System.out.println("******************************************");
        List<String> strings1 = stringsForElement(elem1);
        List<String> strings2 = stringsForElement(elem2);
        StringListAlignment sla = new StringListAlignment(strings1, strings2);
        if(sla.isSuccess()) {
View Full Code Here

      String from = e.getAttributeValue("from");
      String to = e.getAttributeValue("to");
      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

      int start = Integer.parseInt(e.getAttributeValue("xtspanstart"));
      int end = Integer.parseInt(e.getAttributeValue("xtspanend"));
      if(start == end) continue;
      for(int j=start; j<end; j++) {
        if(charPosToCharPos.get(j) == -1) {
          System.out.println(e.toXML());
          break;
        }
      }
    }
  }
View Full Code Here

      //Element e = (Element)n.get(i);
      //if(excludeNodes.contains(e)) continue;
      //if(e.getValue().length() == 0) continue;
      Element e = (Element)doc.query("//PAPER").get(0);
      String xPoint = XOMTools.getXPointToNode(e, doc.getRootElement());
      String a = e.toXML();
      String b = XOMTools.getNodeAtXPoint(doc.getRootElement(), xPoint).toXML();
      if(!a.equals(b)) {
        System.out.println("Yikes!");
        System.out.println(a);
        System.out.println(b);
View Full Code Here

      if(annotNodes.size() != 0) {
         sTaggedPattern = Pattern.compile("^<s sid=\\\"\\d+\\\"><annotationART .+?>(.+)</annotationART></s>$");         
      } else {
        sTaggedPattern = Pattern.compile("^<s sid=\\\"\\d+\\\">(.+)</s>$");
      }
      String sTaggedSentence = sentenceElement.toXML();
      Matcher m = sTaggedPattern.matcher(sTaggedSentence);
      m.find();
      //System.out.println(m.group(0));
      String untaggedSentence = m.group(1);
      //System.out.println("untagged sentence: " + untaggedSentence);
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.