Package edu.stanford.nlp.pipeline

Examples of edu.stanford.nlp.pipeline.CoreNLPProtos$Document$Builder


   */
  private static final Document process(final JDOMFactory factory,
      final XMLEventReader events) throws JDOMException {
    try {

      final Document document = factory.document(null);
      Element current = null;

      XMLEvent event = events.peek();

      if (XMLStreamConstants.START_DOCUMENT != event.getEventType()) {
        throw new JDOMException("JDOM requires that XMLStreamReaders " +
            "are at their beginning when being processed.");
      }



      while (event.getEventType() != XMLStreamConstants.END_DOCUMENT) {
        if (event.isStartDocument()) {
          document.setBaseURI(event.getLocation().getSystemId());
          document.setProperty("ENCODING_SCHEME",
              ((javax.xml.stream.events.StartDocument)event).getCharacterEncodingScheme());
          document.setProperty("STANDALONE", String.valueOf(
              ((javax.xml.stream.events.StartDocument)event).isStandalone()));
          //            document.setProperty("ENCODING",
          //                ((StartDocument)event).getEncoding());
        } else if (event instanceof javax.xml.stream.events.DTD) {
          //List<?> list = (List<?>)reader.getProperty("javax.xml.stream.entities");
          //System.out.println(list);
          final DocType dtype = DTDParser.parse(((javax.xml.stream.events.DTD)event).getDocumentTypeDeclaration(), factory);
          document.setDocType(dtype);
        } else if (event.isStartElement()) {
          final Element emt = processElement(factory, event.asStartElement());
          if (current == null) {
            document.setRootElement(emt);
            final DocType dt = document.getDocType();
            if (dt != null) {
              dt.setElementName(emt.getName());
            }
          } else {
            current.addContent(emt);
          }
          current = emt;
        } else if (event.isCharacters()) {
          final Characters chars = event.asCharacters();
          if (chars.isCData()) {
            current.addContent(factory.cdata(
                ((Characters)event).getData()));
          } else {
            current.addContent(factory.text(
                ((Characters)event).getData()));
          }
        } else if (event instanceof javax.xml.stream.events.Comment) {
          final Comment comment = factory.comment(
              ((javax.xml.stream.events.Comment)event).getText());
          if (current == null) {
            document.addContent(comment);
          } else {
            current.addContent(comment);
          }
        } else if (event.isEntityReference()) {
          current.addContent(factory.entityRef(
              ((javax.xml.stream.events.EntityReference)event).getName()));
        } else if (event.isProcessingInstruction()) {
          final ProcessingInstruction pi = factory.processingInstruction(
              ((javax.xml.stream.events.ProcessingInstruction)event).getTarget(),
              ((javax.xml.stream.events.ProcessingInstruction)event).getData());
          if (current == null) {
            document.addContent(pi);
          } else {
            current.addContent(pi);
          }
        } else if (event.isEndElement()) {
          current = current.getParentElement();
View Full Code Here


  public void testOutputDocumentFull() {
    DocType dt = new DocType("root");
    Comment comment = new Comment("comment");
    ProcessingInstruction pi = new ProcessingInstruction("jdomtest", "");
    Element root = new Element("root");
    Document doc = new Document();
    doc.addContent(dt);
    doc.addContent(comment);
    doc.addContent(pi);
    doc.addContent(root);
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String dtdec = "<!DOCTYPE root>";
    String commentdec = "<!--comment-->";
    String pidec = "<?jdomtest?>";
    String rtdec = "<root />";
View Full Code Here

  @Test
  public void testDeepNesting() {
    // need to get beyond 16 levels of XML.
    DocType dt = new DocType("root");
    Element root = new Element("root");
    Document doc = new Document();
    doc.addContent(dt);
    doc.addContent(root);
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String dtdec = "<!DOCTYPE root>";
    String lf = "\n";
   
    StringBuilder raw = new StringBuilder();
View Full Code Here

      if (START_DOCUMENT != state) {
        throw new JDOMException("JDOM requires that XMLStreamReaders " +
            "are at their beginning when being processed.");
      }

      final Document document = factory.document(null);

      while (state != END_DOCUMENT) {
        switch (state) {

          case START_DOCUMENT:
            // for the <?xml version="..." standalone=".."?>
            document.setBaseURI(stream.getLocation().getSystemId());
            document.setProperty("ENCODING_SCHEME",
                stream.getCharacterEncodingScheme());
            document.setProperty("STANDALONE",
                String.valueOf(stream.isStandalone()));
            document.setProperty("ENCODING",
                stream.getEncoding());
            break;

          case DTD:
            document.setDocType(DTDParser.parse(
                stream.getText(), factory));
            break;

          case START_ELEMENT:
            document.setRootElement(processElementFragment(factory, stream));
            break;

          case END_ELEMENT:
            throw new JDOMException("Unexpected XMLStream event at Document level: END_ELEMENT");
          case ENTITY_REFERENCE:
            throw new JDOMException("Unexpected XMLStream event at Document level: ENTITY_REFERENCE");
          case CDATA:
            throw new JDOMException("Unexpected XMLStream event at Document level: CDATA");
          case SPACE:
            throw new JDOMException("Unexpected XMLStream event at Document level: SPACE");
          case CHARACTERS:
            throw new JDOMException("Unexpected XMLStream event at Document level: CHARACTERS");

          case COMMENT:
            document.addContent(
                factory.comment(stream.getText()));
            break;

          case PROCESSING_INSTRUCTION:
            document.addContent(factory.processingInstruction(
                stream.getPITarget(), stream.getPIData()));
            break;

          default:
            throw new JDOMException("Unexpected XMLStream event " + state);
View Full Code Here

    /* Load the map. This is called in the main class upon game start */
    public void load(File loadFile) {
        try {
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(loadFile);
            Element root = document.getRootElement();

            for (Element tile : root.getChildren()) {
                int x = (int) Double.parseDouble(tile.getAttributeValue("x"));
                int y = (int) Double.parseDouble(tile.getAttributeValue("y"));
                tiles[x][y] = new Tile(TileType.valueOf(tile.getAttributeValue("type")), x, y, 32, 32);
View Full Code Here

        System.out.println("Loaded map: " + loadFile.getName());
    }

    public void save(File saveFile) {
        Document document = new Document();
        Element root = new Element("tiles");
        document.setRootElement(root);

        for (int x = 0; x < AMOUNT_TILES_WIDTH; x++) {
            for (int y = 0; y < AMOUNT_TILES_HEIGHT; y++) {
                Element tile = new Element("tile");
                System.out.println("X: " + tiles[x][y].getX() + " Y: " + tiles[x][y].getY() + " Type: " + String.valueOf(tiles[x][y].getType()));
View Full Code Here

  private static final String PLAYER = "player";
 
  public static Tree<String> buildDemoPokerTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/large_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
    return tree;
View Full Code Here

  }
 
  public static Tree<String> buildPokerTree(String filePath) throws JDOMException, IOException{
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build(filePath);
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
    return tree;
View Full Code Here

  }
 
  public static Tree<String> buildDemoPokerSmallTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/simple_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
    Tree<String> tree = new Tree<String>(root);
    return tree;
  }
View Full Code Here

                String cleanScmUrl = "not defined";
                try
                {
                    String content = ReleaseUtil.readXmlFile(pomFile, ls);
                    SAXBuilder builder = new SAXBuilder();
                    Document document = builder.build(new StringReader( content ));
                    Element root = document.getRootElement();

                    Element scmElement = root.getChild("scm", getNamespaceOrNull(root));

                    if(null != scmElement)
                    {
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.pipeline.CoreNLPProtos$Document$Builder

Copyright © 2018 www.massapicom. 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.