Package org.w3c.tidy

Examples of org.w3c.tidy.Tidy


     *
     * @return a <code>tidy</code> HTML parser
     */
    public static Tidy getParser() {
        log.debug("Start : getParser1");
        Tidy tidy = new Tidy();
        tidy.setInputEncoding("UTF8");
        tidy.setOutputEncoding("UTF8");
        tidy.setQuiet(true);
        tidy.setShowWarnings(false);

        if (log.isDebugEnabled()) {
            log.debug("getParser1 : tidy parser created - " + tidy);
        }

View Full Code Here


        catch ( Exception e )
        {
            log.warn("Download failed. " + e.getMessage());
        }

        Tidy tidy = new Tidy();
        tidy.setQuiet(true);
        tidy.setShowWarnings(false);



        if ( resultsFile == null || !resultsFile.exists() )
        {
            log.info( resultsFileName + " could not be downloaded. Using the template to create anew");
            resultsFile = new File(project.getBasedir(), "src/main/resources/" + resultsFileName);
        }

        FileInputStream is = new FileInputStream( resultsFile );
        Document document = tidy.parseDOM(is, null);
        is.close();

        File reportsDir = new File(targetDirectory, "surefire-reports");
        if ( !reportsDir.exists() )
        {
            log.warn("No surefire-reports directory here");
            return;
        }

        ArrayList files = (ArrayList) FileUtils.getFiles(reportsDir, "TEST-*.xml", null, true);
        if ( files.size() > 0 )
        {
            document = insertNewColumn(document);
            if ( document == null )
            {
                throw new MojoFailureException("Main table cannot be found in the " + resultsFileName + ". The file may be corrupted");
            }
        }

        for ( Iterator itr=files.iterator(); itr.hasNext(); )
        {
            File file = (File) itr.next();
            log.debug("working on " + file.getAbsolutePath() );
            document = processFile(document, file);
        }


        // Use a Transformer for output
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();

        // write the document back into a temporary file.
        File tempFile = new File(targetDirectory, "ResultsSummary-2.html");
        FileOutputStream os = new FileOutputStream( tempFile );
        DOMSource source = new DOMSource(document);
        StreamResult result = new StreamResult(os);
        transformer.transform(source, result);

        os.flush();
        os.close();

        // tidy the document and create/replace ResultsSummary.html in the target directory
        resultsFile = new File(targetDirectory, resultsFileName);
        is = new FileInputStream( tempFile );
        os = new FileOutputStream( resultsFile );
        tidy.parse(is, os);
        is.close();
        os.close();

        // delete the temp file.
        tempFile.delete();
View Full Code Here

   * @return  a <code>tidy</code> HTML parser
   */
  protected static Tidy getParser()
  {
    catClass.debug("Start : getParser1");
    Tidy tidy = new Tidy();
    tidy.setCharEncoding(org.w3c.tidy.Configuration.UTF8);
    tidy.setQuiet(true);

    if(catClass.isDebugEnabled())
    {
      catClass.debug("getParser1 : tidy parser created - " + tidy);
    }
View Full Code Here

   *@return   a <code>tidy</code> HTML parser
   ***************************************/
  public static Tidy getParser()
  {
    catClass.debug("Start : getParser1");
    Tidy tidy = new Tidy();
    tidy.setCharEncoding(org.w3c.tidy.Configuration.UTF8);
    tidy.setQuiet(true);
    tidy.setShowWarnings(false);

    if(catClass.isDebugEnabled())
      catClass.debug("getParser1 : tidy parser created - " + tidy);

    catClass.debug("End : getParser1");
View Full Code Here

   *
   *@return   !ToDo (Return description)
   ***************************************/
  public static Document createEmptyDoc()
  {
    return new Tidy().createEmptyDocument();
  }
View Full Code Here

  * @return  a <code>tidy</code> HTML parser
  */
  protected static Tidy getParser()
  {
   catClass.debug("Start : getParser1");
   Tidy tidy = new Tidy();
   tidy.setCharEncoding(org.w3c.tidy.Configuration.UTF8);
   tidy.setQuiet(true);
   if(catClass.isDebugEnabled())
   {
    catClass.debug("getParser1 : tidy parser created - " + tidy);
   }
   catClass.debug("End : getParser1");
View Full Code Here

    public void generate()
    throws IOException, SAXException, ProcessingException {
        try
        {
            // Setup an instance of Tidy.
            Tidy tidy = new Tidy();
            tidy.setXmlOut(true);

            if (this.properties == null) {
                tidy.setXHTML(true);
            } else {
                tidy.setConfigurationFromProps(this.properties);
            }

            //Set Jtidy warnings on-off
            tidy.setShowWarnings(getLogger().isWarnEnabled());
            //Set Jtidy final result summary on-off
            tidy.setQuiet(!getLogger().isInfoEnabled());
            //Set Jtidy infos to a String (will be logged) instead of System.out
            StringWriter stringWriter = new StringWriter();
            PrintWriter errorWriter = new PrintWriter(stringWriter);
            tidy.setErrout(errorWriter);

            // Extract the document using JTidy and stream it.

            if (inputSource != null)
                requestStream = this.inputSource.getInputStream();

            org.w3c.dom.Document doc = tidy.parseDOM(new BufferedInputStream(requestStream), null);

            // FIXME: Jtidy doesn't warn or strip duplicate attributes in same
            // tag; stripping.
            XMLUtils.stripDuplicateAttributes(doc, null);
View Full Code Here

   *
   * @param resource
   */
  public void process(String resource) {

    Tidy tidy = new Tidy();
    ByteArrayOutputStream out = null;
    BufferedOutputStream output = null;
    BufferedOutputStream wikiOutput = null;
    StreamSource streamSource = null;

    tidy.setXmlOut(true);
    try {
      out = new ByteArrayOutputStream();
      URL u = new URL(baseURL + resource);
      Document doc = tidy.parseDOM(
          new BufferedInputStream(u.openStream()), out);
      out.close();
      // let's extract the div element with class="wiki-content
      // maincontent"
      NodeList nodeList = doc.getElementsByTagName("div");
View Full Code Here

     *
     * @throws Exception DOCUMENT ME!
     */
    public void tidy(URL url, File file, File err, boolean xhtml)
        throws Exception {
        Tidy tidy = new Tidy();
        tidy.setXmlOut(xhtml);
        tidy.setErrout(new PrintWriter(new FileWriter(err.getAbsolutePath()), true));

        BufferedInputStream in = new BufferedInputStream(url.openStream());
        FileOutputStream out = new FileOutputStream(file.getAbsolutePath());
        tidy.parse(in, out);
    }
View Full Code Here

        }
        catch (Exception e) {
            log.warn("Download failed. " + e.getMessage());
        }

        Tidy tidy = new Tidy();
        tidy.setQuiet(true);
        tidy.setShowWarnings(false);

        if ( resultsFile == null || !resultsFile.exists() ) {
            log.info( resultsFileName + " could not be downloaded. Using the template to create anew");
            resultsFile = new File(project.getBasedir(), "src/main/resources/" + resultsFileName);
        }

        FileInputStream is = new FileInputStream( resultsFile );
        Document document = tidy.parseDOM(is, null);
        is.close();

        File reportsDir = new File(targetDirectory, "surefire-reports");
        if ( !reportsDir.exists() ) {
            log.warn("No surefire-reports directory here");
            return;
        }

        ArrayList files = (ArrayList) FileUtils.getFiles(reportsDir, "TEST-*.xml", null, true);
        if ( files.size() > 0 ) {
            document = insertNewColumn(document);
            if ( document == null ) {
                throw new MojoFailureException("Main table cannot be found in the " + resultsFileName + ". The file may be corrupted");
            }
        }

        for ( Iterator itr=files.iterator(); itr.hasNext(); ) {
            File file = (File) itr.next();
            log.debug("working on " + file.getAbsolutePath() );
            document = processFile(document, file);
        }

        // Use a Transformer for output
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();

        // write the document back into a temporary file.
        File tempFile = new File(targetDirectory, "ResultsSummary-2.html");
        FileOutputStream os = new FileOutputStream( tempFile );
        DOMSource source = new DOMSource(document);
        StreamResult result = new StreamResult(os);
        transformer.transform(source, result);

        os.flush();
        os.close();

        // tidy the document and create/replace ResultsSummary.html in the target directory
        resultsFile = new File(targetDirectory, resultsFileName);
        is = new FileInputStream( tempFile );
        os = new FileOutputStream( resultsFile );
        tidy.parse(is, os);
        is.close();
        os.close();

        // delete the temp file.
        tempFile.delete();
View Full Code Here

TOP

Related Classes of org.w3c.tidy.Tidy

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.