Пример #1
0
    public void startElement(String uri, String localName, String qname, Attributes atts) {
      super.startElement(uri, localName, qname, atts);

      if (localName.equals(DataExport.FIELD_EXPORT)) {
        String type = atts.getValue(DataExport.EXPORT_TYPE);
        textImport = (type != null && type.equals(DataExport.EXPORT_TYPE_TEXT));
      } else if (localName.equals(DataRecord.ENCODING_RECORD)) {
        // begin of record
        record = dataAccess.getPersistence().createNewRecord();
        fieldsInImport = new ArrayList<String>();
        return;
      } else {
        if (atts.getValue("key") != null && atts.getValue("key").equalsIgnoreCase("true")) {
          overrideKeyField = localName;
        }
      }
    }
Пример #2
0
  // Beginn eines Element-Tags
  public void startElement(String uri, String localName, String qname, Attributes atts) {
    try {
      if (uri.equals("http://www.nmichael.de/elwiz")) {

        // Elemente des elwiz-Namensraums

        if (!localName.equals("option")) { // Hauptelement
          // Namen ermitteln
          String name = null;
          for (int i = 0; i < atts.getLength(); i++)
            if (atts.getLocalName(i).equals("name")) name = atts.getValue(i);

          // Element suchen
          for (int i = 0; i < options.size(); i++)
            if (((ElwizOption) options.get(i)).name.equals(name)) {
              this.option = (ElwizOption) options.get(i);
              break;
            }

        } else { // Unterelement

          // Position des Unterelements für Zugriff auf options-Vektor ermitteln
          int pos = -1;
          for (int i = 0; i < atts.getLength(); i++)
            if (atts.getLocalName(i).equals("pos")) pos = EfaUtil.string2int(atts.getValue(i), -1);

          if (option != null)
            switch (option.type) {
              case ElwizOption.O_OPTIONAL: // optional
                JCheckBox o1 = (JCheckBox) option.components.get(pos);
                if (!o1.isSelected()) skip = true;
                break;
              case ElwizOption.O_SELECT: // select
                JRadioButton o2 = (JRadioButton) option.components.get(pos);
                if (!o2.isSelected()) skip = true;
                ElwizSingleOption eso = (ElwizSingleOption) option.options.get(pos);
                if (!skip && eso.value != null) f.write(eso.value);
                break;
              case ElwizOption.O_VALUE: // value
                JTextField o3 = (JTextField) option.components.get(pos);
                f.write(o3.getText().trim());
                break;
            }
        }

      } else {

        // Elemente des XSLT-Namensraums

        if (skip) return; // Element unterdrücken?

        f.write("<" + qname);
        for (int i = 0; i < atts.getLength(); i++) {
          f.write(
              " "
                  + atts.getLocalName(i)
                  + "=\""
                  + EfaUtil.replace(atts.getValue(i), "<", "&lt;", true)
                  + "\"");
        }
        if (localName.equals("stylesheet"))
          f.write(
              " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"");
        f.write(">");
      }
    } catch (IOException e) {
    }
  }