Package org.jdom2.input

Examples of org.jdom2.input.StAXEventBuilder

From a JDOM perspective XMLStreamReaders are more efficient than XMLEventReaders. Where possible use an XMLStreamReader.

If you happen to be looking at the source code, pay careful attention to the imports so you know what type of instance is being processed, whether it is a StAX class, or a JDOM class, because there are name conflicts. @author Rolf Lear


    protected List<String> trans = null;

    public KeyboardLayout(InputStream is) throws Exception
    {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(is);
        loadData(document.getRootElement());
    }
View Full Code Here


    this.annotatorNames = annotatorNames;
  }

  public Collection<KnowtatorAnnotation> parse(URI knowtatorXML) throws JDOMException, IOException {

    Element annotationsElem = new SAXBuilder().build(knowtatorXML.toURL()).getRootElement();

    // parse <annotation> elements
    Set<String> ignoredAnnotators = new HashSet<String>();
    Map<String, KnowtatorAnnotation> annotations = new HashMap<String, KnowtatorAnnotation>();
    for (Element annotationElem : annotationsElem.getChildren("annotation")) {
View Full Code Here

   * @param url Target URL.
   * @return The HTML document.
   * @throws Exception
   */
  Document loadURL(URL url) throws Exception{
    SAXBuilder builder=new SAXBuilder();
    Document xml=null;
    HttpURLConnection con=(HttpURLConnection) url.openConnection();
    con.setInstanceFollowRedirects(true);
   
    InputStream in;
    try
    {
       in = con.getInputStream();
    }
    catch(Exception e)
    {
      in=con.getErrorStream();
    }
    String encoding = con.getContentEncoding();
    encoding = encoding == null ? "UTF-8" : encoding;
    if(encoding.equals("gzip"))
    {
      in=new GZIPInputStream(con.getInputStream());
      encoding="UTF-8";
    }
   
    String body = IOUtils.toString(in, encoding).replace(" & ", "&amp;");
    for(int i=0;i<this.attempts;i++)
    {
      try
      {
        xml=(Document) builder.build(new StringReader(body));
        i+=this.attempts+1;
      }
      catch(JDOMParseException ex)
      {
        int line=ex.getLineNumber();
View Full Code Here

  /**
   *
   */
  private void openSQList()
  {
    SAXBuilder sxb = new SAXBuilder();
    try {
      this.root = sxb.build(new File(SQCalculator.xmlPath)).getRootElement();
    } catch (JDOMException | IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   * @param lang A formated tag language (<b>Ex : </b>Fr-FR, En-EN). Use locale.toLanguageTag() method to be sure of your parameter.
   * </b>
   */
  private void openLangFile()
  {
    SAXBuilder sxb = new SAXBuilder();
    try {
      this.root = sxb.build(new File(Language.xmlPath)).getRootElement();
      this.openLocaleLang();
    } catch (JDOMException | IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      {
        System.out.println("-----------Checking file: "+file.getName()+ " "+String.valueOf(x)+"/"+String.valueOf(files.size())+"--------------");
        x++;
        try
        {
          SAXBuilder builder=new SAXBuilder();
          Document xml=(Document)builder.build(file);
          ArrayList<Element> words=new ArrayList<Element>();
          for(Element word:xml.getDescendants(new ElementFilter("wf")))
            words.add(word);
          for(int w=0;w<words.size();w++)
          {
View Full Code Here

     * @throws JDOMException
     * @throws IOException
     */
    private Element htmlStringToElement( String html ) throws JDOMException, IOException
    {
        SAXBuilder builder = new SAXBuilder( CYBERNEKO_PARSER, true );
        Document doc = builder.build( new StringReader( html ) );
        Element element = doc.getRootElement();
        return element;
    }
View Full Code Here

            try
            {
                Element root = layout.getAsElement();
                File file = new File(layout.name + ".xml");
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                Format format = Format.getPrettyFormat();
                format.setEncoding("utf-16");
                format.setTextMode(Format.TextMode.TRIM);
                XMLOutputter outputter = new XMLOutputter(format);
                outputter.output(new Document(root), fileOutputStream);
                fileOutputStream.close();
            } catch (Exception e)
            {
View Full Code Here

        CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
        XMLOutputter output = new XMLOutputter(processor);
       
        StringWriter out = new StringWriter();
       
        Format fmt = Format.getRawFormat();
        fmt.setExpandEmptyElements( false );
        fmt.setLineSeparator( LINEBREAK );

        output.setFormat( fmt );
        output.outputElementContent( m_document.getRootElement(), out );
       
        String result = out.toString();
View Full Code Here

                File file = new File(layout.name + ".xml");
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                Format format = Format.getPrettyFormat();
                format.setEncoding("utf-16");
                format.setTextMode(Format.TextMode.TRIM);
                XMLOutputter outputter = new XMLOutputter(format);
                outputter.output(new Document(root), fileOutputStream);
                fileOutputStream.close();
            } catch (Exception e)
            {
                e.printStackTrace();
            }
View Full Code Here

TOP

Related Classes of org.jdom2.input.StAXEventBuilder

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.