Examples of QDomNodeList


Examples of com.trolltech.qt.xml.QDomNodeList

    // 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
      int h = new Integer(element.attribute("h"));   // height
      QDomNodeList children = element.childNodes()// all children ("t" nodes).
     
      // Go through the children ("t" nodes)
      for (int j=0; j<children.length(); j++) {
          QDomElement child = children.at(j).toElement();
          if (child.nodeName().equalsIgnoreCase("t")) {
            String text = child.text();   // recognition text
            int weight = new Integer(child.attribute("w"))// recognition weight
            if (weight >= Global.getRecognitionWeight()) {   // Are we above the maximum?
             
View Full Code Here

Examples of com.trolltech.qt.xml.QDomNodeList

      tempFiles = new ArrayList<QTemporaryFile>();
    tempFiles.clear();
    QDomElement docElem = doc.documentElement();
   
    // Modify en-media tags
    QDomNodeList anchors = docElem.elementsByTagName("en-media");
    int enMediaCount = anchors.length();
    for (int i=enMediaCount-1; i>=0; --i) {
      QDomElement enmedia = anchors.at(i).toElement();
      if (enmedia.hasAttribute("type")) {
        QDomAttr attr = enmedia.attributeNode("type");
        QDomAttr hash = enmedia.attributeNode("hash");
        String[] type = attr.nodeValue().split("/");
        String appl = type[1];
       
        if (type[0] != null) {
          if (type[0].equals("image")) {
            modifyImageTags(doc, docElem, enmedia, hash);
          }
          if (!type[0].equals("image")) {
            modifyApplicationTags(doc, docElem, enmedia, hash, appl);
          }
        }
      }
    }
   
    // Modify todo tags
    anchors = docElem.elementsByTagName("en-todo");
    int enTodoCount = anchors.length();
    for (int i=enTodoCount-1; i>=0; i--) {
      QDomElement enmedia = anchors.at(i).toElement();
      modifyTodoTags(enmedia);
    }
   
    // Modify en-crypt tags
    anchors = docElem.elementsByTagName("en-crypt");
    int enCryptLen = anchors.length();
    for (int i=enCryptLen-1; i>=0; i--) {
      QDomElement enmedia = anchors.at(i).toElement();
      enmedia.setAttribute("contentEditable","false");
      enmedia.setAttribute("src", Global.getFileManager().getImageDirPath("encrypt.png"));
      enmedia.setAttribute("en-tag","en-crypt");
      enmedia.setAttribute("alt", enmedia.text());
      Global.cryptCounter++;
      enmedia.setAttribute("id", "crypt"+Global.cryptCounter.toString());
      String encryptedText = enmedia.text();
     
      // If the encryption string contains crlf at the end, remove them because they mess up the javascript.
      if (encryptedText.endsWith("\n"))
        encryptedText = encryptedText.substring(0,encryptedText.length()-1);
      if (encryptedText.endsWith("\r"))
        encryptedText = encryptedText.substring(0,encryptedText.length()-1);
     
      // Add the commands
      String hint = enmedia.attribute("hint");
      hint = hint.replace("'","&apos;");
      enmedia.setAttribute("onClick", "window.jambi.decryptText('crypt"+Global.cryptCounter.toString()+"', '"+encryptedText+"', '"+hint+"');");
      enmedia.setAttribute("onMouseOver", "style.cursor='hand'");
      enmedia.setTagName("img");
      enmedia.removeChild(enmedia.firstChild());   // Remove the actual encrypted text
    }

   
    // Modify link tags
    anchors = docElem.elementsByTagName("a");
    enCryptLen = anchors.length();
    for (int i=0; i<anchors.length(); i++) {
      QDomElement element = anchors.at(i).toElement();
      if (!element.attribute("href").toLowerCase().startsWith("latex://"))
        element.setAttribute("title", element.attribute("href"));
      else {
        element.setAttribute("title", element.attribute("title").toLowerCase().replace("http://latex.codecogs.com/gif.latex?",""));
      }
View Full Code Here

Examples of com.trolltech.qt.xml.QDomNodeList

      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.QDomNodeList

     
    doc.setContent(resourceBinary);
    QDomElement docElem = doc.documentElement();
     
    // look for text tags
    QDomNodeList anchors = docElem.elementsByTagName("t");
    for (int i=0; i<anchors.length() && keepRunning; i++) {
      if (interrupt) {
        if (interrupt) {
          processInterrupt();
        }
      }
      QDomElement enmedia = anchors.at(i).toElement();
      String weight = new String(enmedia.attribute("w"));
      String text = new String(enmedia.text()).toLowerCase();
      if (!text.equals("")) {
        conn.getWordsTable().addWordToNoteIndex(r.getNoteGuid(), text, "RESOURCE", new Integer(weight));
        uncommittedCount++;
View Full Code Here

Examples of com.trolltech.qt.xml.QDomNodeList

 
  // Parse through individual nodes
  public void parseChildren(QDomNode node) {
    for(; !node.isNull(); node = node.nextSibling()) {
      if (node.hasChildNodes()) {
        QDomNodeList l = node.childNodes();
        for (int i=0; i<l.size(); i++)
          parseChildren(l.at(i));
      }
      if (node.isText()) {
        scanWords(node);
      }
    }
View Full Code Here

Examples of com.trolltech.qt.xml.QDomNodeList

      System.out.println("Exiting");
      content = null;
      return;
    }
   
    QDomNodeList noteAnchors = doc.elementsByTagName("en-note");
    int noteCount = noteAnchors.length();
    for (int i=noteCount-1; i>=0; i--) {
      if (noteAnchors.at(i).toElement().hasAttribute("style")) {
        String style = noteAnchors.at(i).toElement().attribute("style");
        int startColor = style.indexOf("background-color:");
        if (startColor > -1) {
          String color = style.substring(startColor+17);
          color = color.substring(0,color.indexOf(";"));
          noteAnchors.at(i).toElement().setAttribute("bgcolor", color);
        }
      }
    }
   
    // Scan through tags node by node
    scanTags();
   
    // Scan again making sure we didn't miss any <a> tags.  Sometimes we do
    QDomNodeList anchorList = doc.elementsByTagName("a");
    int anchorCount = anchorList.length();
    for (int i=anchorCount-1; i>=0; i--) {
      QDomNode link = anchorList.at(i);
      link = fixLinkNode(link);
    }
   
    // Remove invalid elements & attributes
    // Modify en-media tags
    QDomNodeList anchors;
    for (String key : Global.invalidAttributes.keySet()) {
      anchors = doc.elementsByTagName(key);
      int enMediaCount = anchors.length();
      for (int i=enMediaCount-1; i>=0; i--) {
        QDomElement element = anchors.at(i).toElement();
        ArrayList<String> names = Global.invalidAttributes.get(element.nodeName().toLowerCase());
        if (names != null) { 
          for (int j=0; j<names.size(); j++) {
            element.removeAttribute(names.get(j));
          }
        }
      }
    }

    List<String> elements = Global.invalidElements;
    for (int j=0; j<elements.size(); j++) {
      anchors = doc.elementsByTagName(elements.get(j));
      int enMediaCount = anchors.length();
      for (int i=enMediaCount-1; i>=0; i--) {
        QDomElement element = anchors.at(i).toElement();
        element.setTagName("span");
      }
    }
    // Replace the XML carrage returns that the toString() creates.
    content = doc.toString().replace( "&#xd;", "" );
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.