Package org.jdom2.input

Examples of org.jdom2.input.SAXBuilder


   
    public XMLMatch(String location, String player)
    {
        try
        {
            SAXBuilder builder = new SAXBuilder();
           
            // Stub the entity resolver in order to avoid crashes when the
            // xml referenced dtd is not available
            builder.setEntityResolver(new EntityResolver()
            {
                @Override
                public InputSource resolveEntity(String arg0, String arg1)
                        throws SAXException, IOException
                {
                    return new InputSource(new StringReader(""));
                }
            });
           
            Map<Integer,SerializableAction> actions = new HashMap<Integer,SerializableAction>();
           
            // First get the moves history from the final state file
            {
                String filename = location + "/finalstate.xml";
                File file = new File(filename);
                if(!file.exists())
                {
                    throw new FileNotFoundException(filename);
                }
                Element root = builder.build(file).getRootElement();
                int player_id = getPlayerId(root,player);
                role = getRole(root,player_id);
                for(Element e : root.getChild("history").getChildren("step"))
                {
                    String s = e.getChildren("step-number").get(0).getText();
                    int stepnum = Integer.parseInt(s);
                    String action_term = e.getChildren("move").get(player_id).getText();
                    GroundFact fact = createAction(action_term,role);
                    actions.put(stepnum, new SerializableAction(fact));
                }
            }
           
            // Register the state-action couples by browsing the step_x.xml
            // files in the right order.
            int step = 1;
            while(true)
            {
                String filename = getStateFilename(location,step);
                File file = new File(filename);
               
                if(!file.exists())
                {
                    break;
                }
               
                Element root = builder.build(file).getRootElement();
                List<Element> states = root.getChildren("state");
                SerializableState state = getState(states.get(0));
                SerializableAction action = actions.get(step);
                if(action != null)
                {
View Full Code Here


    }

    // load the XML
    Element dataElem;
    try {
      dataElem = new SAXBuilder().build(xmlFile.toURI().toURL()).getRootElement();
    } catch (MalformedURLException e) {
      throw new AnalysisEngineProcessException(e);
    } catch (JDOMException e) {
      throw new AnalysisEngineProcessException(e);
    } catch (IOException e) {
View Full Code Here

    Map<String,Annotation> id2entity = new HashMap<>();
   
    // load the XML
    Element dataElem;
    try {
      dataElem = new SAXBuilder().build(xmlFile.toURI().toURL()).getRootElement();
    } catch (MalformedURLException e) {
      throw new AnalysisEngineProcessException(e);
    } catch (JDOMException e) {
      throw new AnalysisEngineProcessException(e);
    } catch (IOException e) {
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

    imageData = new HashMap<String,ImageData>();
    super.initLoader();
  }
  @Override
  protected void loadImagesFile(String fnm) {
    SAXBuilder builder = new SAXBuilder();
    String imsFNm = IMAGE_DIR + fnm;
    logger.info("Reading file: " + imsFNm);
    InputStream in = this.getClass().getResourceAsStream(imsFNm);
    try {
      Document document = builder.build(in);
      Element rootNode = document.getRootElement(); // images
      List<Element> imageList = rootNode.getChildren("image");
      for (Element image : imageList) {
        String name = image.getAttributeValue("name");
        ECrop crop;
View Full Code Here

    }

    private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException {
        LinkedList<String> result = new LinkedList<String>();
        try {
            Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in));
            XMLOutputter out = new XMLOutputter();

            for (String xp : xpaths) {
                XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content());
                for (Content node : xpath.evaluate(doc)) {
View Full Code Here

        rtdec);
  }

  @Test
    public void test_HighSurrogatePair() throws XMLStreamException, IOException, JDOMException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>&#x10000; &#x10000;</root>"));
     
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream sw = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(sw, "ISO-8859-1");
View Full Code Here

                   "<root>&#xd800;&#xdc00; &#xd800;&#xdc00;</root>" + format.getLineSeparator(), xml);
    }

    @Test
    public void test_HighSurrogatePairDecimal() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>&#x10000; &#65536;</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
View Full Code Here

                   "<root>&#xd800;&#xdc00; &#xd800;&#xdc00;</root>" + format.getLineSeparator(), xml);
    }

    @Test
    public void test_HighSurrogateAttPair() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#x10000;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
View Full Code Here

                   "<root att=\"&#xd800;&#xdc00; &#xd800;&#xdc00;\"/>" + format.getLineSeparator(), xml);
    }

    @Test
    public void test_HighSurrogateAttPairDecimal() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#65536;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
View Full Code Here

TOP

Related Classes of org.jdom2.input.SAXBuilder

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.