Examples of QDomDocument


Examples of com.trolltech.qt.xml.QDomDocument

    if (currentNote == null)
      return null;
     logger.log(logger.HIGH, "Entering NeverNote.rebuildNoteHTML");
    logger.log(logger.EXTREME, "Note guid: " +currentNoteGuid);
    logger.log(logger.EXTREME, "Note Text:" +currentNote);
    QDomDocument doc = new QDomDocument();
    QDomDocument.Result result = doc.setContent(currentNote.getContent());

    // Handle any errors
    if (!result.success) {
      logger.log(logger.LOW, "Error parsing document.  Attempting to restructure");
      Tidy tidy = new Tidy();
      TidyListener tidyListener = new TidyListener(logger);
      tidy.setMessageListener(tidyListener);
      tidy.getStderr().close()// the listener will capture messages
      tidy.setXmlTags(true);
     
      QTextCodec codec;
      codec = QTextCodec.codecForName("UTF-8");
          QByteArray unicode =  codec.fromUnicode(currentNote.getContent());
         
          logger.log(logger.MEDIUM, "Starting JTidy check");
          logger.log(logger.MEDIUM, "Start of JTidy Input");
          logger.log(logger.MEDIUM, currentNote.getContent());
          logger.log(logger.MEDIUM, "End Of JTidy Input");
      ByteArrayInputStream is = new ByteArrayInputStream(unicode.toByteArray());
          ByteArrayOutputStream os = new ByteArrayOutputStream();
          tidy.setInputEncoding("UTF-8");
      tidy.parse(is, os);
      String tidyContent = os.toString();
      if (tidyListener.errorFound) {
        logger.log(logger.LOW, "Restructure failed!!!");
      } else {
        doc = null;
        doc = new QDomDocument();
        result = doc.setContent(tidyContent);
      }
    }
    if (!result.success) {
      logger.log(logger.MEDIUM, "Parse error when rebuilding XML to HTML");
      logger.log(logger.MEDIUM, "Note guid: " +currentNoteGuid);
      logger.log(logger.MEDIUM, "Error: "+result.errorMessage);
      logger.log(logger.MEDIUM, "Line: " +result.errorLine + " Column: " +result.errorColumn);
      System.out.println("Error: "+result.errorMessage);
      System.out.println("Line: " +result.errorLine + " Column: " +result.errorColumn);
      logger.log(logger.EXTREME, "**** Start of unmodified note HTML");
      logger.log(logger.EXTREME, currentNote.getContent());
      logger.log(logger.EXTREME, "**** End of unmodified note HTML");
      formatError = true;
      readOnly = true;
      return currentNote.getContent();
    }

    if (tempFiles == null)
      tempFiles = new ArrayList<QTemporaryFile>();
    tempFiles.clear();
   
    doc = modifyTags(doc);
    if (addHighlight)
      doc = addHilight(doc);
    QDomElement docElem = doc.documentElement();
    docElem.setTagName("Body");
//    docElem.setAttribute("bgcolor", "green");
    logger.log(logger.EXTREME, "Rebuilt HTML:");
    logger.log(logger.EXTREME, doc.toString())
    logger.log(logger.HIGH, "Leaving NeverNote.rebuildNoteHTML");
    // Fix the stupid problem where inserting an <img> tag after an <a> tag (which is done
    // to get the <en-media> application tag to work properly) causes spaces to be inserted
    // between the <a> & <img>.  This messes things up later.  This is an ugly hack.
    StringBuffer html = new StringBuffer(doc.toString());
    for (int i=html.indexOf("<a en-tag=\"en-media\" ", 0); i>-1; i=html.indexOf("<a en-tag=\"en-media\" ", i)) {
      i=html.indexOf(">\n",i+1);
      int z = html.indexOf("<img",i);
      for (int j=z-1; j>i; j--)
        html.deleteCharAt(j);
View Full Code Here

Examples of com.trolltech.qt.xml.QDomDocument

    QColor yellow = QColor.yellow;
//    yellow.setAlphaF(0.4);
      p2.setBrush(yellow);
 
    // Get the recognition data from the note
      QDomDocument doc = new QDomDocument();
      doc.setContent(xml);
     
      // Go through all "item" nodes
    QDomNodeList anchors = doc.elementsByTagName("item");
    for (int i=0; i<anchors.length(); i++) {
      QDomElement element = anchors.at(i).toElement();
      int x = new Integer(element.attribute("x"));   // x coordinate
      int y = new Integer(element.attribute("y"));   // y coordinate
      int w = new Integer(element.attribute("w"));   // width
View Full Code Here

Examples of com.trolltech.qt.xml.QDomDocument

  // Rebuild the note HTML to something usable
  public List<String> scanNoteForResources(Note n) {
    logger.log(logger.HIGH, "Entering ListManager.scanNoteForResources");
    logger.log(logger.EXTREME, "Note guid: " +n.getGuid());
    QDomDocument doc = new QDomDocument();
    QDomDocument.Result result = doc.setContent(n.getContent());
    if (!result.success) {
      logger.log(logger.MEDIUM, "Parse error when scanning note for resources.");
      logger.log(logger.MEDIUM, "Note guid: " +n.getGuid());
      return null;
    }
       
    List<String> returnArray = new ArrayList<String>();
    QDomNodeList anchors = doc.elementsByTagName("en-media");
    for (int i=0; i<anchors.length(); i++) {
      QDomElement enmedia = anchors.at(i).toElement();
      if (enmedia.hasAttribute("type")) {
        QDomAttr hash = enmedia.attributeNode("hash");
        returnArray.add(hash.value().toString());
View Full Code Here

Examples of com.trolltech.qt.xml.QDomDocument

    logger = new ApplicationLogger(logname);
    conn = new DatabaseConnection(logger, u, i, r, uid, pswd, cpswd, 500);
    indexType = SCAN;
    guid = null;
    keepRunning = true;
    doc = new QDomDocument();
    workQueue=new LinkedBlockingQueue<String>(MAX_QUEUED_WAITING)
  }
View Full Code Here

Examples of com.trolltech.qt.xml.QDomDocument

  public String getValue() {
    return content;
  }
  // Validate the contents of the note.  Change unsupported things 
  public void validate() {
    doc = new QDomDocument();
    int br = content.lastIndexOf("</en-note>");
    content = new String(content.substring(0,br));
    String newContent;
    int k = content.indexOf("<en-note");
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.