public void addAppletElement(String appletAID, String className) {
   Element servlet = doc.createElement(XmlTagNames.XML_APPLET_TAG);
   Element sName = doc.createElement(XmlTagNames.XML_APPLET_AID_TAG);
   sName.setTextContent(appletAID);
   Element sClass = doc.createElement(XmlTagNames.XML_APPLET_CLASS_TAG);
   sClass.setTextContent(className);
   servlet.appendChild(sClass);
   servlet.appendChild(sName);
   getAppletAppNode().appendChild(servlet);
 }
Exemplo n.º 2
0
  /**
   * Gets XML string for this definition so that it may be printed.
   *
   * @return XML node that can be saved of this word.
   */
  public Element getWordXMLNode(Document doc) {
    try {
      Element rootWordElement = doc.createElement("WordDefinitions");
      rootWordElement.setAttribute("word", this.word);
      rootWordElement.setAttribute("mainDefinition", this.getMainDefinition());
      if (this.otherDefinitions == null) {
        this.getDefinitions();
      }
      for (int i = 0; i < this.otherDefinitions.length; i++) {
        // main definition node
        Element definition = doc.createElement("Definition");

        // word
        Element word = doc.createElement("Word");
        word.setTextContent(otherDefinitions[i].getWord());

        // dictionary
        Element dictionary = doc.createElement("Dictionary");
        Element id = doc.createElement("Id");
        id.setTextContent(otherDefinitions[i].getId());
        Element source = doc.createElement("Name");
        source.setTextContent(otherDefinitions[i].getSource());
        dictionary.appendChild(id);
        dictionary.appendChild(source);

        // definition
        Element wordDefinition = doc.createElement("WordDefinition");
        wordDefinition.setTextContent(otherDefinitions[i].getDefinition());

        // append all the children
        definition.appendChild(word);
        definition.appendChild(dictionary);
        definition.appendChild(wordDefinition);
        rootWordElement.appendChild(definition);
      }
      return rootWordElement;
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;
    }
  }